diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b848f2d..825a876 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,10 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - name: Install lint utilities + run: sudo npm install -g markdownlint-cli + - name: Install Rust + run: ./ci/install-rust.sh stable.txt --profile minimal - name: Run job run: ./ci/lint-aux.sh @@ -39,8 +43,9 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - name: Run job - run: ./ci/extract-changelog.sh + - name: Install Rust + run: ./ci/install-rust.sh stable.txt --profile minimal + - run: ./ci/extract-changelog.sh - name: Upload artifact uses: actions/upload-artifact@v4 with: @@ -52,15 +57,17 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - name: Run job - run: ./ci/rustfmt.sh + - name: Install Rust + run: ./ci/install-rust.sh stable.txt --profile minimal + - run: cargo fmt --all -- --check clippy: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - name: Run job - run: ./ci/clippy.sh + - name: Install Rust + run: ./ci/install-rust.sh stable.txt --profile minimal + - run: ./ci/clippy.sh build-and-test: runs-on: ubuntu-22.04 @@ -71,15 +78,17 @@ jobs: - rust-version: stable.txt steps: - uses: actions/checkout@v4 - - name: Run job - run: ./ci/build-and-test.sh "${{ matrix.rust-version }}" + - name: Install Rust + run: ./ci/install-rust.sh "${{ matrix.rust-version }}" --profile minimal + - run: ./ci/build-and-test.sh package-crates: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - name: Run job - run: ./ci/package-crates.sh + - name: Install Rust + run: ./ci/install-rust.sh stable.txt --profile minimal + - run: ./ci/package-crates.sh - name: Upload artifact uses: actions/upload-artifact@v4 with: @@ -90,17 +99,17 @@ jobs: build-dist-linux: runs-on: ubuntu-22.04 env: - IMAGE_NAME: quay.io/pypa/manylinux2014_x86_64 + DOCKER_IMAGE: quay.io/pypa/manylinux2014_x86_64 steps: - uses: actions/checkout@v4 - - name: Pull image - run: docker pull "$IMAGE_NAME" + - name: Pull Docker image + run: docker pull "$DOCKER_IMAGE" - name: Build run: | docker run \ -v "$(pwd):/workdir" \ -w /workdir \ - "$IMAGE_NAME" \ + "$DOCKER_IMAGE" \ bash ./ci/build-dist-linux.sh - name: Upload artifact uses: actions/upload-artifact@v4 @@ -114,17 +123,17 @@ jobs: build-dist-windows: runs-on: ubuntu-22.04 env: - IMAGE_NAME: debian:12-slim + DOCKER_IMAGE: debian:12-slim steps: - uses: actions/checkout@v4 - - name: Pull image - run: docker pull "$IMAGE_NAME" + - name: Pull Docker image + run: docker pull "$DOCKER_IMAGE" - name: Build run: | docker run \ -v "$(pwd):/workdir" \ -w /workdir \ - "$IMAGE_NAME" \ + "$DOCKER_IMAGE" \ bash ./ci/build-dist-windows.sh - name: Upload artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7b85e2b..d1ad09d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,8 @@ jobs: version: ${{ steps.get-version.outputs.version }} steps: - uses: actions/checkout@v4 + - name: Install Rust + run: ./ci/install-rust.sh stable.txt --profile minimal - id: get-version run: ./ci/get-release-version.sh @@ -97,6 +99,8 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - name: Install Rust + run: ./ci/install-rust.sh stable.txt --profile minimal - name: Publish env: CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} diff --git a/ci/build-and-test.sh b/ci/build-and-test.sh index 4a910df..3595311 100755 --- a/ci/build-and-test.sh +++ b/ci/build-and-test.sh @@ -3,17 +3,6 @@ set -euo pipefail . ci/utils.sh -if [ "$#" -ne 1 ]; then - echo_stderr "Usage: $0 " - exit 1 -fi -rust_version="$1" - -begin_group "Install Rust" -./ci/install-rust.sh "$rust_version" --profile minimal -. ci/cargo-env.sh -end_group - export RUSTDOCFLAGS="-D warnings" begin_group "Fetch dependencies" diff --git a/ci/clippy.sh b/ci/clippy.sh index adc1c45..374f3f3 100755 --- a/ci/clippy.sh +++ b/ci/clippy.sh @@ -3,11 +3,6 @@ set -euo pipefail . ci/utils.sh -begin_group "Install Rust" -./ci/install-rust.sh stable.txt --profile minimal -c clippy -. ci/cargo-env.sh -end_group - begin_group "Fetch dependencies" cargo fetch --locked end_group diff --git a/ci/get-release-version.sh b/ci/get-release-version.sh index e13bc16..fb1607a 100755 --- a/ci/get-release-version.sh +++ b/ci/get-release-version.sh @@ -3,13 +3,6 @@ set -euo pipefail . ci/utils.sh -begin_group "Install Rust" -./ci/install-rust.sh stable.txt --profile minimal -c clippy -. ci/cargo-env.sh -end_group - -begin_group "Get release version" - if [[ "$GITHUB_REF" != "refs/tags/v"* ]]; then echo "Invalid ref: $GITHUB_REF" exit 1 @@ -28,4 +21,3 @@ if [ "$tag_version" != "$crate_version" ]; then fi echo "version=$tag_version" >> "$GITHUB_OUTPUT" -end_group diff --git a/ci/install-rust.sh b/ci/install-rust.sh index e87ffce..cddb0ac 100755 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -10,3 +10,7 @@ fi echo "Installing Rust $rust_version" curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$rust_version" "$@" + +if [ -z "${GITHUB_PATH+x}" ] + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" +fi diff --git a/ci/lint-aux.sh b/ci/lint-aux.sh index 94d91fc..fc897e5 100755 --- a/ci/lint-aux.sh +++ b/ci/lint-aux.sh @@ -3,17 +3,6 @@ set -euo pipefail . ci/utils.sh -begin_group "Install lint utilities" -sudo apt-get update -sudo apt-get install -y --no-install-recommends shellcheck -sudo npm install -g markdownlint-cli -end_group - -begin_group "Install Rust" -./ci/install-rust.sh stable.txt --profile minimal -. ci/cargo-env.sh -end_group - crates=( rsjsonnet-lang rsjsonnet-front diff --git a/ci/package-crates.sh b/ci/package-crates.sh index d3395e7..ac2d465 100755 --- a/ci/package-crates.sh +++ b/ci/package-crates.sh @@ -3,11 +3,6 @@ set -euo pipefail . ci/utils.sh -begin_group "Install Rust" -./ci/install-rust.sh stable.txt --profile minimal -. ci/cargo-env.sh -end_group - pkgs_dir="packages" if [ -e "$pkgs_dir" ]; then echo "$pkgs_dir already exists" diff --git a/ci/publish-crates.sh b/ci/publish-crates.sh index a696b18..fe4ff4a 100755 --- a/ci/publish-crates.sh +++ b/ci/publish-crates.sh @@ -3,11 +3,6 @@ set -euo pipefail . ci/utils.sh -begin_group "Install Rust" -./ci/install-rust.sh stable.txt --profile minimal -c clippy -. ci/cargo-env.sh -end_group - begin_group "Fetch dependencies" cargo fetch --locked end_group diff --git a/ci/rustfmt.sh b/ci/rustfmt.sh deleted file mode 100755 index 1c7a9f4..0000000 --- a/ci/rustfmt.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -. ci/utils.sh - -begin_group "Install Rust" -./ci/install-rust.sh stable.txt --profile minimal -c rustfmt -. ci/cargo-env.sh -end_group - -begin_group "Check formatting" -cargo fmt --all -- --check -end_group