diff --git a/.github/scripts/simfmt-check b/.github/scripts/simfmt-check deleted file mode 100755 index bf29526..0000000 --- a/.github/scripts/simfmt-check +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -say() { - printf 'simfmt-check: %s\n' "$1" -} - -err() { - say "$1" >&2 - exit 1 -} - -need_cmd() { - if ! check_cmd "$1"; then - err "need '$1' (command not found)" - fi -} - -check_cmd() { - command -v "$1" &>/dev/null -} - -usage() { - cat >&2 <] [--check] - $(basename "$0") -f [--check] - -Options: - -all, --all Format every .simf file recursively. Defaults to the - current directory. - -d, --directory Directory to search with -all or --all. - -f, --file Format exactly one file. - --check Pass --check to simfmt without modifying files. - -h, --help Show this help text. - -Set SIMFMT_BIN to use a simfmt executable other than the one on PATH. -EOF - exit 2 -} - -require_value() { - local option="$1" - local value="${2:-}" - - if [ -z "$value" ]; then - err "${option} requires an argument" - fi -} - -main() { - local format_all=false - local check=false - local directory="$PWD" - local file='' - local simfmt_bin="${SIMFMT_BIN:-simfmt}" - local -a simfmt_args=() - - while [ "$#" -gt 0 ]; do - case "$1" in - -all|--all) - format_all=true - ;; - -d|--directory) - require_value "$1" "${2:-}" - directory="$2" - shift - ;; - -f|--file) - require_value "$1" "${2:-}" - file="$2" - shift - ;; - --check) - check=true - ;; - -h|--help) - usage - ;; - *) - err "unknown option: $1" - ;; - esac - shift - done - - if [ "$format_all" = true ] && [ -n "$file" ]; then - err 'use either -all or -f, not both' - fi - - if [ "$format_all" = false ] && [ "$directory" != "$PWD" ]; then - err '-d requires -all' - fi - - if [ "$format_all" = false ] && [ -z "$file" ]; then - usage - fi - - need_cmd "$simfmt_bin" - - if [ "$check" = true ]; then - simfmt_args+=(--check) - fi - - if [ "$format_all" = true ]; then - [ -d "$directory" ] || err "no such directory: $directory" - say "Formatting .simf files under $directory" - find "$directory" -type f -name '*.simf' -exec "$simfmt_bin" "${simfmt_args[@]}" -- '{}' + - return - fi - - [ -f "$file" ] || err "no such file: $file" - if [[ "$file" != *.simf ]]; then - say "warning: $file is not a .simf file" - fi - "$simfmt_bin" "${simfmt_args[@]}" -- "$file" -} - -main "$@" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 83b518d..155e067 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,15 +33,15 @@ jobs: run: | #!/usr/bin/env bash set -euo pipefail - - bash -n install .github/scripts/simfmt-check + + bash -n install - name: Install ShellCheck when unavailable shell: bash run: | #!/usr/bin/env bash set -euo pipefail - + if command -v shellcheck >/dev/null 2>&1; then exit 0 fi @@ -59,60 +59,11 @@ jobs: run: | #!/usr/bin/env bash set -euo pipefail - - shellcheck install .github/scripts/simfmt-check - versions: - name: Resolve released versions - runs-on: ubuntu-latest - permissions: - contents: read - outputs: - simplex: ${{ steps.versions.outputs.simplex }} - simfmt: ${{ steps.versions.outputs.simfmt }} - simfmt-available: ${{ steps.versions.outputs.simfmt-available }} - steps: - - id: versions - name: Resolve latest releases - shell: bash - env: - GH_TOKEN: ${{ github.token }} - run: | - #!/usr/bin/env bash - set -euo pipefail - - api_args=( - --fail - --silent - --show-error - --location - --proto '=https' - --tlsv1.2 - --header 'Accept: application/vnd.github+json' - --header 'X-GitHub-Api-Version: 2022-11-28' - ) - - if [ -n "$GH_TOKEN" ]; then - api_args+=(--header "Authorization: Bearer $GH_TOKEN") - fi - - simplex_json="$(curl "${api_args[@]}" https://api.github.com/repos/BlockstreamResearch/smplx/releases/latest)" - simplex_tag="$(jq -er '.tag_name | strings | select(length > 0)' <<< "$simplex_json")" - printf 'simplex=%s\n' "${simplex_tag#v}" >> "$GITHUB_OUTPUT" - - if simfmt_json="$(curl "${api_args[@]}" https://api.github.com/repos/BlockstreamResearch/simfmt/releases/latest 2>/dev/null)" && - simfmt_tag="$(jq -er 'select((.assets | length) > 0) | .tag_name | strings | select(length > 0)' <<< "$simfmt_json")"; then - printf 'simfmt=%s\n' "${simfmt_tag#v}" >> "$GITHUB_OUTPUT" - printf 'simfmt-available=true\n' >> "$GITHUB_OUTPUT" - else - printf 'simfmt=\n' >> "$GITHUB_OUTPUT" - printf 'simfmt-available=false\n' >> "$GITHUB_OUTPUT" - printf 'simfmt has no precompiled GitHub release yet; simfmt jobs will be skipped.\n' - fi + shellcheck install install-simplex: - name: Install Simplex (${{ matrix.os }}, ${{ matrix.mode }}) - needs: versions + name: Install Simplex (${{ matrix.os }}) runs-on: ${{ matrix.os }} permissions: contents: read @@ -122,107 +73,37 @@ jobs: os: - ubuntu-latest - macos-latest - mode: - - latest - - explicit steps: - name: Checkout uses: actions/checkout@v7.0.1 with: persist-credentials: false - - id: selection - name: Select component version - shell: bash - env: - MODE: ${{ matrix.mode }} - SIMPLEX_VERSION: ${{ needs.versions.outputs.simplex }} - run: | - if [ "$MODE" = explicit ]; then - printf 'components=simplex@%s\n' "$SIMPLEX_VERSION" >> "$GITHUB_OUTPUT" - else - printf 'components=simplex\n' >> "$GITHUB_OUTPUT" - fi - - - id: toolchain - name: Install Simplex with the local action + - id: default + name: Install the default Simplex release uses: ./ - with: - components: ${{ steps.selection.outputs.components }} - - - name: Verify Simplex installation - shell: bash - env: - INSTALLED_VERSION: ${{ steps.toolchain.outputs.simplex-version }} - SIMFMT_VERSION: ${{ steps.toolchain.outputs.simfmt-version }} - run: | - #!/usr/bin/env bash - set -euo pipefail - - test -n "$INSTALLED_VERSION" - test -z "$SIMFMT_VERSION" - simplex --version | grep --fixed-strings "$INSTALLED_VERSION" - install-simfmt: - name: Install simfmt (${{ matrix.os }}, ${{ matrix.mode }}) - needs: versions - if: needs.versions.outputs.simfmt-available == 'true' - runs-on: ${{ matrix.os }} - permissions: - contents: read - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - macos-latest - mode: - - latest - - explicit - steps: - - name: Checkout - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - - id: selection - name: Select component version - shell: bash - env: - MODE: ${{ matrix.mode }} - SIMFMT_VERSION: ${{ needs.versions.outputs.simfmt }} - run: | - #!/usr/bin/env bash - set -euo pipefail - - if [ "$MODE" = explicit ]; then - printf 'components=simfmt@%s\n' "$SIMFMT_VERSION" >> "$GITHUB_OUTPUT" - else - printf 'components=simfmt\n' >> "$GITHUB_OUTPUT" - fi - - - id: toolchain - name: Install simfmt with the local action + - id: explicit + name: Reinstall the resolved Simplex release explicitly uses: ./ with: - components: ${{ steps.selection.outputs.components }} + components: simplex@${{ steps.default.outputs.simplex-version }} - - name: Verify simfmt installation + - name: Verify Simplex installations shell: bash env: - INSTALLED_VERSION: ${{ steps.toolchain.outputs.simfmt-version }} - SIMPLEX_VERSION: ${{ steps.toolchain.outputs.simplex-version }} + DEFAULT_VERSION: ${{ steps.default.outputs.simplex-version }} + EXPLICIT_VERSION: ${{ steps.explicit.outputs.simplex-version }} run: | #!/usr/bin/env bash set -euo pipefail - - test -n "$INSTALLED_VERSION" - test -z "$SIMPLEX_VERSION" - simfmt --version | grep --fixed-strings "$INSTALLED_VERSION" + + test -n "$DEFAULT_VERSION" + test "$DEFAULT_VERSION" = "$EXPLICIT_VERSION" + simplex --version | grep --fixed-strings "$DEFAULT_VERSION" fixture: name: Example project - needs: versions runs-on: ubuntu-latest timeout-minutes: 30 permissions: @@ -244,7 +125,7 @@ jobs: run: | #!/usr/bin/env bash set -euo pipefail - + rustc --version > "$RUNNER_TEMP/rustc-before" cargo --version > "$RUNNER_TEMP/cargo-before" @@ -252,17 +133,25 @@ jobs: name: Install Simplex with the local action uses: ./ with: - components: simplex@${{ needs.versions.outputs.simplex }} + components: simplex - - name: Verify Rust and Cargo were not changed + - name: Verify the installed toolchain shell: bash + env: + SIMPLEX_VERSION: ${{ steps.toolchain.outputs.simplex-version }} run: | #!/usr/bin/env bash set -euo pipefail - + + test -n "$SIMPLEX_VERSION" + simplex --version | grep --fixed-strings "$SIMPLEX_VERSION" test "$(cat "$RUNNER_TEMP/rustc-before")" = "$(rustc --version)" test "$(cat "$RUNNER_TEMP/cargo-before")" = "$(cargo --version)" + - name: Check SimplicityHL formatting + working-directory: example + run: simplex fmt --check + - name: Generate contract artifacts working-directory: example run: simplex build @@ -275,52 +164,6 @@ jobs: working-directory: example run: simplex test -v - formatting: - name: SimplicityHL formatting with ${{ matrix.mode }} cargo-binstall - needs: versions - if: needs.versions.outputs.simfmt-available == 'true' - runs-on: ubuntu-latest - permissions: - contents: read - strategy: - matrix: - include: - - mode: default - - mode: explicit - binstall-version: "1.21.1" - steps: - - name: Checkout - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - - id: toolchain - name: Install all components with the local action - uses: ./ - with: - components: simplex@${{ needs.versions.outputs.simplex }},simfmt@${{ needs.versions.outputs.simfmt }} - binstall-version: ${{ matrix.binstall-version }} - - - name: Check action outputs - shell: bash - env: - SIMPLEX_VERSION: ${{ steps.toolchain.outputs.simplex-version }} - SIMFMT_VERSION: ${{ steps.toolchain.outputs.simfmt-version }} - run: | - #!/usr/bin/env bash - set -euo pipefail - - test -n "$SIMPLEX_VERSION" - test -n "$SIMFMT_VERSION" - - - name: Check SimplicityHL formatting - shell: bash - run: | - #!/usr/bin/env bash - set -euo pipefail - - .github/scripts/simfmt-check -all -d "$GITHUB_WORKSPACE" --check - invalid-inputs: name: Invalid input handling runs-on: ubuntu-latest @@ -332,56 +175,24 @@ jobs: with: persist-credentials: false - - id: missing - name: Reject empty components - continue-on-error: true - uses: ./ - with: - components: "" - - - id: unknown - name: Reject an unknown component - continue-on-error: true - uses: ./ - with: - components: unknown - - - id: duplicate - name: Reject a duplicate component - continue-on-error: true - uses: ./ - with: - components: simplex,simplex - - - id: malformed - name: Reject a malformed version - continue-on-error: true - uses: ./ - with: - components: simplex@ - - - id: nonexistent - name: Reject a nonexistent release - continue-on-error: true - uses: ./ - with: - components: simplex@0.0.0-does-not-exist - - - name: Verify every invalid input failed - if: always() + - name: Reject invalid component inputs shell: bash env: - MISSING: ${{ steps.missing.outcome }} - UNKNOWN: ${{ steps.unknown.outcome }} - DUPLICATE: ${{ steps.duplicate.outcome }} - MALFORMED: ${{ steps.malformed.outcome }} - NONEXISTENT: ${{ steps.nonexistent.outcome }} + GITHUB_TOKEN: ${{ github.token }} run: | #!/usr/bin/env bash set -euo pipefail - - test "$MISSING" = failure - test "$UNKNOWN" = failure - test "$DUPLICATE" = failure - test "$MALFORMED" = failure - test "$NONEXISTENT" = failure + + invalid_inputs=( + unknown + simplex,simplex + simplex@ + simplex@0.0.0-does-not-exist + ) + + for components in "${invalid_inputs[@]}"; do + if COMPONENTS="$components" GITHUB_OUTPUT="$RUNNER_TEMP/invalid-output" ./install; then + printf 'expected components=%s to fail\n' "$components" >&2 + exit 1 + fi + done diff --git a/README.md b/README.md index e960e29..6a492eb 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ # SimplicityHL toolchain -This action installs precompiled [Simplex][1] -and [Simfmt][2] binaries. It does not -install, select, or modify Rust or Cargo. +This action installs a precompiled [Simplex][1] toolchain. It does not install, +select, or modify Rust or Cargo. ## Usage -Set up the Rust version required by your project separately, then select the -SimplicityHL components to install: +Set up the Rust version required by your project separately. With no component +input, the action installs the latest stable Simplex release: ```yaml steps: @@ -20,12 +19,10 @@ steps: - id: toolchain name: Install SimplicityHL tools - uses: BlockstreamResearch/simplicityhl-toolchain@v1 - with: - components: simplex@0.0.10,simfmt@0.0.2 + uses: BlockstreamResearch/simplicityhl-toolchain@v0.0.3 - run: simplex --version - - run: simfmt --version + - run: simplex fmt --check ``` For security-sensitive workflows, pin actions to the full commit SHA of the @@ -35,59 +32,43 @@ release you reviewed instead of a movable tag. ### `components` -Required. A comma-separated list containing `simplex`, `simfmt`, or both. Add -`@VERSION` to an entry to install a specific release: +Optional. A comma-separated component list that currently supports `simplex`. +Add `@VERSION` to install a specific release: ```yaml -components: simplex,simfmt -components: simplex@0.0.10 -components: simplex@v0.0.10,simfmt@0.0.2 +components: simplex +components: simplex@0.0.13 +components: simplex@v0.0.13 ``` -An entry without a version resolves the latest stable release. Empty entries, -unknown components, duplicates, and malformed versions are rejected. - -### `binstall-version` - -Optional. Version of `cargo-binstall` used to download and install the precompiled `simfmt` binary. Defaults to `1.22.0` and is ignored unless `simfmt` is selected. +Omitting the input, or passing an empty or whitespace-only value, installs the +latest stable Simplex release. Empty entries within a non-empty list, unknown +components, duplicates, and malformed versions are rejected. ## Outputs | Output | Description | | --- | --- | -| `simplex-version` | Installed Simplex version, or empty if it was not selected. | -| `simfmt-version` | Installed simfmt version, or empty if it was not selected. | +| `simplex-version` | Installed Simplex version. | ```yaml - id: toolchain - uses: BlockstreamResearch/simplicityhl-toolchain@v1 + uses: BlockstreamResearch/simplicityhl-toolchain@v0.0.3 with: - components: simplex,simfmt + components: simplex@0.0.13 -- run: printf '%s / %s\n' "$SIMPLEX_VERSION" "$SIMFMT_VERSION" +- run: printf 'Simplex %s\n' "$SIMPLEX_VERSION" env: SIMPLEX_VERSION: ${{ steps.toolchain.outputs.simplex-version }} - SIMFMT_VERSION: ${{ steps.toolchain.outputs.simfmt-version }} ``` ## Precompiled binaries only -* Simplex is installed through `simplexup`. -* Simfmt is installed by the standalone -precompiled `cargo-binstall` executable with only its official crate-metadata release strategy enabled. +Simplex is installed through `simplexup`. -Supported platforms are determined by each project's published release assets. +Supported platforms are determined by the published Simplex release assets. The action does not maintain a separate architecture table. See the -[Simplex releases][3] and [Simfmt releases][4]. - -## Development and releases - -After checking out this repository, workflows can test the unpublished action -with `uses: ./`. The action implementation is the root `install` script; the -separate `.github/scripts/simfmt-check` helper is used only for repository -format checks. +[Simplex releases][2]. [1]: https://github.com/BlockstreamResearch/smplx -[2]: https://github.com/BlockstreamResearch/simfmt -[3]: https://github.com/BlockstreamResearch/smplx/releases -[4]: https://github.com/BlockstreamResearch/simfmt/releases \ No newline at end of file +[2]: https://github.com/BlockstreamResearch/smplx/releases diff --git a/action.yml b/action.yml index f984660..f7a0864 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,6 @@ name: SimplicityHL toolchain author: Blockstream Research -description: Install precompiled Simplex and Simfmt binaries +description: Install a precompiled Simplex toolchain branding: icon: terminal @@ -9,33 +9,19 @@ branding: inputs: components: description: >- - Required comma-separated list of components. Each entry is simplex, - simfmt, simplex@VERSION, or simfmt@VERSION. - required: true - - binstall-version: - description: >- - Version of cargo-binstall to install (e.g. 1.2.3 or v1.2.3). Defaults to 1.22.0. + Optional comma-separated list of components. Currently supports simplex + and simplex@VERSION. required: false - default: "1.22.0" + default: "simplex" outputs: simplex-version: - description: Installed Simplex version, or empty when Simplex was not selected + description: Installed Simplex version value: ${{ steps.install.outputs.simplex-version }} - simfmt-version: - description: Installed simfmt version, or empty when simfmt was not selected - value: ${{ steps.install.outputs.simfmt-version }} runs: using: composite steps: - - name: Install cargo-binstall - if: contains(inputs.components, 'simfmt') - uses: cargo-bins/cargo-binstall@v1.22.0 - with: - version: ${{ inputs.binstall-version }} - - id: install name: Install SimplicityHL components shell: bash diff --git a/install b/install index b9a4360..aec27b5 100755 --- a/install +++ b/install @@ -170,41 +170,6 @@ install_simplex() { printf -v "$output_variable" '%s' "$installed_version" } -install_simfmt() { - local requested_version="$1" - local output_variable="$2" - local cargo_home - local package='simfmt' - local version_label='latest' - local version_output - local installed_version - local -a args=( - --strategies crate-meta-data - --no-confirm - --force - --min-tls-version 1.2 - ) - - cargo_home="${CARGO_HOME:-$HOME/.cargo}" - append_path "$cargo_home/bin" - need_cmd cargo-binstall - - if [ -n "$requested_version" ]; then - package="simfmt@$requested_version" - version_label="$requested_version" - fi - - say "installing simfmt@$version_label from a precompiled release" - if ! cargo-binstall "${args[@]}" "$package"; then - err "failed to install simfmt@$version_label for $(uname -s)/$(uname -m); verify the version and architecture at https://github.com/BlockstreamResearch/simfmt/releases" - fi - - need_cmd simfmt - version_output="$(simfmt --version)" - installed_version="$(reported_version simfmt "$version_output")" - printf -v "$output_variable" '%s' "$installed_version" -} - main() { local components="${COMPONENTS:-}" local entry @@ -212,15 +177,12 @@ main() { local version local has_version local simplex_selected=false - local simfmt_selected=false local simplex_requested_version='' - local simfmt_requested_version='' local simplex_version='' - local simfmt_version='' local -a entries=() if [ -z "$(trim "$components")" ]; then - err "'components' is a required input" + components='simplex' fi if [[ "$components" == ,* || "$components" == *, || "$components" == *,,* ]]; then @@ -264,13 +226,6 @@ main() { simplex_selected=true simplex_requested_version="$version" ;; - simfmt) - if [ "$simfmt_selected" = true ]; then - err "duplicate component: 'simfmt'" - fi - simfmt_selected=true - simfmt_requested_version="$version" - ;; *) err "unknown component: '$component'" ;; @@ -280,12 +235,8 @@ main() { if [ "$simplex_selected" = true ]; then install_simplex "$simplex_requested_version" simplex_version fi - if [ "$simfmt_selected" = true ]; then - install_simfmt "$simfmt_requested_version" simfmt_version - fi write_key_value_out simplex-version "$simplex_version" - write_key_value_out simfmt-version "$simfmt_version" say 'done' }