Skip to content

Commit

Permalink
ci: install Rust and other dependencies within the main job script
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardosm committed Apr 20, 2024
1 parent dc6e4e7 commit 13636ae
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 26 deletions.
26 changes: 8 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: ./ci/install-lint-deps.sh
- name: Run auxilary lints
- name: Run job
run: ./ci/lint-aux.sh

extract-changelog:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Extract changelog
- name: Run job
run: ./ci/extract-changelog.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
Expand All @@ -52,18 +50,14 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: ./ci/install-rust.sh stable.txt --profile minimal -c rustfmt
- name: Run rustfmt
run: cargo fmt --all -- --check
- name: Run job
run: ./ci/rustfmt.sh

clippy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: ./ci/install-rust.sh stable.txt --profile minimal -c clippy
- name: Run clippy
- name: Run job
run: ./ci/clippy.sh

build-and-test:
Expand All @@ -75,18 +69,14 @@ jobs:
- rust-version: stable.txt
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: ./ci/install-rust.sh "${{ matrix.rust-version }}" --profile minimal
- name: Build and test
run: ./ci/build-and-test.sh
- name: Run job
run: ./ci/build-and-test.sh "${{ matrix.rust-version }}"

package-crates:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: ./ci/install-rust.sh stable.txt --profile minimal
- name: Package crates
- name: Run job
run: ./ci/package-crates.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
24 changes: 24 additions & 0 deletions ci/build-and-test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail

. ci/utils.sh

if [ "$#" -ne 1 ]; then
echo_stderr "Usage: $0 <rust_version>"
exit 1
fi
rust_version="$1"

begin_group "Install Rust"
./ci/install-rust.sh "$rust_version" --profile minimal
# shellcheck disable=SC1090
. "$HOME/.cargo/env"
end_group

export RUSTDOCFLAGS="-D warnings"

begin_group "Fetch dependencies"
cargo fetch --locked
end_group

begin_group "Build"
cargo build --workspace --all-targets --frozen
end_group

begin_group "Test"
cargo test --workspace --frozen
end_group

begin_group "Doc"
cargo doc --workspace --frozen
end_group
13 changes: 13 additions & 0 deletions ci/clippy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail

. ci/utils.sh

begin_group "Install Rust"
./ci/install-rust.sh stable.txt --profile minimal -c clippy
# shellcheck disable=SC1090
. "$HOME/.cargo/env"
end_group

begin_group "Fetch dependencies"
cargo fetch --locked
end_group

begin_group "Run clippy"
cargo clippy --workspace --all-targets --frozen -- -D warnings
end_group
7 changes: 0 additions & 7 deletions ci/install-lint-deps.sh

This file was deleted.

1 change: 0 additions & 1 deletion ci/install-rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ fi

echo "Installing Rust $rust_version"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$rust_version" "$@"
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
6 changes: 6 additions & 0 deletions ci/lint-aux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ 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

crates=(
rsjsonnet-lang
rsjsonnet-front
Expand Down
6 changes: 6 additions & 0 deletions ci/package-crates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ set -euo pipefail

. ci/utils.sh

begin_group "Install Rust"
./ci/install-rust.sh stable.txt --profile minimal
# shellcheck disable=SC1090
. "$HOME/.cargo/env"
end_group

pkgs_dir="packages"
if [ -e "$pkgs_dir" ]; then
echo "$pkgs_dir already exists"
Expand Down
14 changes: 14 additions & 0 deletions ci/rustfmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail

. ci/utils.sh

begin_group "Install Rust"
./ci/install-rust.sh stable.txt --profile minimal -c rustfmt
# shellcheck disable=SC1090
. "$HOME/.cargo/env"
end_group

begin_group "Check formatting"
cargo fmt --all -- --check
end_group

0 comments on commit 13636ae

Please sign in to comment.