diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index b46b2fb..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM mcr.microsoft.com/devcontainers/rust:2-1-trixie -RUN sudo apt update && sudo apt upgrade -y -RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash -RUN cargo binstall -y wasm-tools -RUN cargo binstall -y wkg -RUN cargo binstall -y wac-cli -RUN cargo binstall -y wasmtime-cli diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7b2ada4..0060426 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,10 +1,8 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/rust { - "name": "http", - "build": { - "dockerfile": "Dockerfile" - }, + "name": "componentized-http", + "image": "mcr.microsoft.com/devcontainers/rust", // Use 'mounts' to make the cargo cache persistent in a Docker Volume. "mounts": [ { @@ -23,7 +21,7 @@ "ghcr.io/devcontainers/features/github-cli:1": {} }, // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "cargo check", + "postCreateCommand": "./scripts/init-devcontainer.sh", // Configure tool-specific properties. "customizations": { // Configure properties specific to VS Code. diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version.yaml index 88dcb77..7321cf4 100644 --- a/.github/workflows/bump-version.yaml +++ b/.github/workflows/bump-version.yaml @@ -26,7 +26,7 @@ jobs: - name: Install tools run: | make tools - echo "${PWD}/target/tools/bin" >> "${GITHUB_PATH}" + make -s tools-path >> "${GITHUB_PATH}" - name: Bump version # also fetches the wit dependencies for the new version, and builds and tests the components run: scripts/bump-version.sh "${VERSION}" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 160bb08..cd547f3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,7 +21,7 @@ jobs: # the versions pinned in tools/Cargo.toml, on the path for later steps run: | make tools - echo "${PWD}/target/tools/bin" >> "${GITHUB_PATH}" + make -s tools-path >> "${GITHUB_PATH}" - name: Sync wit run: make wit - name: Check for drift in generated wit @@ -73,7 +73,7 @@ jobs: - name: Install tools run: | make tools - echo "${PWD}/target/tools/bin" >> "${GITHUB_PATH}" + make -s tools-path >> "${GITHUB_PATH}" - name: Install cosign uses: sigstore/cosign-installer@v4.1.2 - name: Download components.tar diff --git a/Makefile b/Makefile index a5af19e..8e35ec1 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ export RUST_BACKTRACE ?= 1 export WASMTIME_BACKTRACE_DETAILS ?= 1 COMPONENTS_DIR := target/components -TOOLS_DIR := target/tools +TOOLS_DIR := target/tools/$(shell rustc --print host-tuple) # absolute, tools also run from other directories, e.g. `cd components && wkg fetch` export PATH := $(abspath $(TOOLS_DIR))/bin:$(PATH) @@ -12,7 +12,7 @@ export PATH := $(abspath $(TOOLS_DIR))/bin:$(PATH) CARGO_INSTALL := $(if $(shell command -v cargo-binstall 2> /dev/null),cargo binstall --no-confirm --disable-telemetry,cargo install) COMPONENTS = $(sort $(foreach file,$(wildcard $(addprefix components/*/,wit/*.constants.wit *.properties *.wac *.wkg Cargo.toml)),$(word 2,$(subst /, ,$(file))))) -TOOLS := componentized-constants-cli static-config wac-cli wasm-tools wkg +TOOLS := componentized-constants-cli static-config wac-cli wasm-tools wasmtime-cli wkg export WKG_CONFIG_FILE := $(abspath .config/wasm-pkg/config.toml) @@ -41,7 +41,7 @@ test: components tool_version = $(shell sed -n 's/^$(1) = "=\(.*\)"$$/\1/p' tools/Cargo.toml) -# a stamp naming the version of a tool installed in target/tools/bin, e.g. `wkg@0.16.1`, the binary +# a stamp naming the version of a tool installed in $(TOOLS_DIR)/bin, e.g. `wkg@0.16.1`, the binary # does not say which version it is. Bumping the pinned version names a stamp that does not exist yet, # so the tool is installed again. tool = $(TOOLS_DIR)/.installed/$(1)@$(call tool_version,$(1)) @@ -49,6 +49,10 @@ tool = $(TOOLS_DIR)/.installed/$(1)@$(call tool_version,$(1)) .PHONY: tools ## Install the cli tools pinned in tools/Cargo.toml tools: $(foreach name,$(TOOLS),$(call tool,$(name))) +.PHONY: tools-path ## Print the directory of the installed tools for this platform, to add to the PATH +tools-path: + @echo $(abspath $(TOOLS_DIR))/bin + define INSTALL_TOOL $(call tool,$1): diff --git a/README.md b/README.md index f062d89..0bc9b8b 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ make components The build creates each component in [`components`](./components) into `target/components`, e.g. the client at `target/components/client/client.wasm`, along with `target/components/interface.wasm`, the `componentized:http` WIT package. Each component is also built with debug info, e.g. `target/components/client/client.debug.wasm`. -The cli tools the build uses, [`static-config`](https://github.com/componentized/static-config), [`wasm-tools`](https://github.com/bytecodealliance/wasm-tools), [`wac`](https://github.com/bytecodealliance/wac) and [`wkg`](https://github.com/bytecodealliance/wasm-pkg-tools), are pinned in [`tools/Cargo.toml`](./tools/Cargo.toml) and installed into `target/tools` as needed, or ahead of time with `make tools`. Dependabot bumps the pinned versions. +The cli tools the build uses, [`static-config`](https://github.com/componentized/static-config), [`wasm-tools`](https://github.com/bytecodealliance/wasm-tools), [`wac`](https://github.com/bytecodealliance/wac), [`wasmtime`](https://github.com/bytecodealliance/wasmtime) and [`wkg`](https://github.com/bytecodealliance/wasm-pkg-tools), are pinned in [`tools/Cargo.toml`](./tools/Cargo.toml) and installed into `target/tools/`, e.g. `target/tools/aarch64-apple-darwin`, as needed, or ahead of time with `make tools`. Dependabot bumps the pinned versions. ## Community diff --git a/scripts/init-devcontainer.sh b/scripts/init-devcontainer.sh new file mode 100755 index 0000000..59f0186 --- /dev/null +++ b/scripts/init-devcontainer.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Setup script run once for new devcontainers to init the environment. + +set -euo pipefail + +curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash + +cargo check + +echo "export \"PATH=$(make -s tools-path):${PATH}\"" >> ~/.bashrc +make tools diff --git a/tools/Cargo.toml b/tools/Cargo.toml index 6b91f90..5991273 100644 --- a/tools/Cargo.toml +++ b/tools/Cargo.toml @@ -17,6 +17,7 @@ componentized-constants-cli = "=0.1.0-dev" static-config = "=0.2.0" wac-cli = "=0.11.0" wasm-tools = "=1.259.0" +wasmtime-cli = "=49.0.2" wkg = "=0.16.1" # not a member of the repository's workspace