From d59e3e12109966c23890a9de66943e855b3ecfd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 20 Jan 2025 12:39:19 +0100 Subject: [PATCH] Prepare for self-hosted runner (#551) - [x] Does not require a CHANGELOG entry --- .github/install-deps.sh | 15 ++++ .github/workflows/changelog.yml | 4 +- .github/workflows/check-features.yml | 20 ++--- .github/workflows/check-migrations.yml | 20 ++--- .github/workflows/clippy.yml | 18 +++-- .github/workflows/cmd.yml | 21 ++--- .github/workflows/fmt.yml | 8 +- .github/workflows/release.yml | 2 + .github/workflows/test.yml | 108 ++++++++----------------- 9 files changed, 101 insertions(+), 115 deletions(-) create mode 100755 .github/install-deps.sh diff --git a/.github/install-deps.sh b/.github/install-deps.sh new file mode 100755 index 0000000000..5e056ef536 --- /dev/null +++ b/.github/install-deps.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +sudo apt update +sudo apt install --assume-yes openssl pkg-config g++ make cmake protobuf-compiler libssl-dev libclang-dev libudev-dev git + +# Free space on the runner +df -h +sudo apt -y autoremove --purge +sudo apt -y autoclean +sudo rm -rf /usr/share/dotnet +sudo rm -rf /opt/ghc +sudo rm -rf "/usr/local/share/boost" +sudo rm -rf "$AGENT_TOOLSDIRECTORY" +df -h + diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 52b6801f9b..e92088bccf 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -43,7 +43,9 @@ jobs: uses: actions/checkout@v4 - name: Verify - run: .github/changelog-processor.py CHANGELOG.md --validate-changelog + run: | + sudo apt install python3 + .github/changelog-processor.py CHANGELOG.md --validate-changelog # This will only run if all the tests in its "needs" array passed. # Add this as your required job, becuase if the matrix changes size (new things get added) diff --git a/.github/workflows/check-features.yml b/.github/workflows/check-features.yml index 6b67389ca7..87bed37014 100644 --- a/.github/workflows/check-features.yml +++ b/.github/workflows/check-features.yml @@ -18,20 +18,22 @@ jobs: runs-on: ubuntu-22.04 steps: - - name: Install stable Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - - - name: Install Zepter - run: cargo install --locked -q zepter && zepter --version - - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 # Dont clone historic commits. + - name: Set rust version via common env file + run: cat .github/env >> $GITHUB_ENV + + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: "${{env.RUST_STABLE_VERSION}}" + + - name: Install Zepter + run: cargo install --locked -q zepter && zepter --version + - name: Check features run: | zepter run check diff --git a/.github/workflows/check-migrations.yml b/.github/workflows/check-migrations.yml index 948ae5bf10..cf96df3f74 100644 --- a/.github/workflows/check-migrations.yml +++ b/.github/workflows/check-migrations.yml @@ -88,18 +88,18 @@ jobs: echo "EXTRA_FLAGS=$EXTRA_FLAGS" >> $GITHUB_ENV echo "CHECKS=$CHECKS" >> $GITHUB_ENV - - name: Install Protoc - uses: arduino/setup-protoc@v1.3.0 - with: - version: "3.6.1" + - name: Install updates and dependencies + run: .github/install-deps.sh - - name: Add wasm32-unknown-unknown target - run: rustup target add wasm32-unknown-unknown - shell: bash + - name: Set rust version via common env file + run: cat .github/env >> $GITHUB_ENV - - name: Add rust-src component - run: rustup component add rust-src - shell: bash + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@master + with: + targets: "wasm32-unknown-unknown" + components: "rust-src" + toolchain: "${{env.RUST_STABLE_VERSION}}" - name: Run ${{ matrix.runtime.name }} Runtime Checks #uses: "paritytech/try-runtime-gha@v0.2.0" diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index a5dc42a6eb..c733fe7ac4 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -16,20 +16,20 @@ jobs: runs-on: ubuntu-22.04 steps: - - name: Install updates and protobuf-compiler - run: sudo apt update && sudo apt install --assume-yes cmake protobuf-compiler - - name: Checkout uses: actions/checkout@v4 + - name: Install updates and dependencies + run: .github/install-deps.sh + - name: Set rust version via common env file run: cat .github/env >> $GITHUB_ENV - name: Install stable toolchain - run: | - rustup toolchain install $RUST_STABLE_VERSION --profile minimal --component clippy - cargo --version - cargo clippy --version + uses: dtolnay/rust-toolchain@master + with: + components: "clippy" + toolchain: "${{env.RUST_STABLE_VERSION}}" - name: Fetch cache uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 @@ -37,7 +37,9 @@ jobs: shared-key: "fellowship-cache-clippy" - name: Clippy - run: cargo clippy --all-targets --locked -q + run: | + cargo clippy --version + cargo clippy --all-targets --locked -q env: RUSTFLAGS: "-D warnings" SKIP_WASM_BUILD: 1 diff --git a/.github/workflows/cmd.yml b/.github/workflows/cmd.yml index e30982abee..28bde3352b 100644 --- a/.github/workflows/cmd.yml +++ b/.github/workflows/cmd.yml @@ -125,6 +125,7 @@ jobs: CMD: ${{ steps.get-pr-comment.outputs.group2 }} # to avoid "" around the command run: | echo 'help<> $GITHUB_OUTPUT + sudo apt install python3 python3 .github/scripts/cmd/cmd.py $CMD >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT @@ -217,14 +218,8 @@ jobs: env: JOB_NAME: 'cmd' if: ${{ startsWith(github.event.comment.body, '/cmd') && !contains(github.event.comment.body, '--help') && contains(needs.fellows.outputs.github-handles, github.event.sender.login) }} - runs-on: ${{ startsWith(github.event.comment.body, '/cmd bench') && 'gitrun-001' || 'ubuntu-22.04' }} + runs-on: ${{ startsWith(github.event.comment.body, '/cmd bench') && 'self-hosted' || 'ubuntu-22.04' }} steps: - - name: Install updates and protobuf-compiler - if: startsWith(github.event.comment.body, '/cmd bench') - run: | - sudo apt update && sudo apt install --assume-yes \ - openssl pkg-config g++ make cmake protobuf-compiler curl libssl-dev libclang-dev libudev-dev git jq - - name: Get command uses: actions-ecosystem/action-regex-match@v2 id: get-pr-comment @@ -274,14 +269,19 @@ jobs: repository: ${{ needs.get-pr-branch.outputs.repo }} ref: ${{ needs.get-pr-branch.outputs.pr-branch }} + - name: Install updates and dependencies + if: startsWith(github.event.comment.body, '/cmd bench') + run: .github/install-deps.sh + - name: Set rust version via common env file run: cat .github/env >> $GITHUB_ENV - - name: Install Rust + - name: Install nightly toolchain uses: dtolnay/rust-toolchain@master + if: startsWith(steps.get-pr-comment.outputs.group2, 'fmt') || startsWith(steps.get-pr-comment.outputs.group2, 'bench') with: - targets: "wasm32-unknown-unknown,x86_64-unknown-linux-musl" - components: "rust-src rustfmt clippy" + targets: "wasm32-unknown-unknown" + components: "rust-src, rustfmt" toolchain: "nightly-${{env.RUST_NIGHTLY_VERSION}}" - name: Install dependencies for bench @@ -306,6 +306,7 @@ jobs: echo "github.ref: ${{ github.ref }}" echo "Running command: $CMD on branch ${{ needs.get-pr-branch.outputs.pr-branch }}" git remote -v + sudo apt install python3 python3 .github/scripts/cmd/cmd.py $CMD git status git diff diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml index 2b115bd863..dd90b93a13 100644 --- a/.github/workflows/fmt.yml +++ b/.github/workflows/fmt.yml @@ -24,8 +24,14 @@ jobs: run: cat .github/env >> $GITHUB_ENV - name: Install nightly toolchain + uses: dtolnay/rust-toolchain@master + with: + targets: "wasm32-unknown-unknown" + components: "rustfmt" + toolchain: "nightly-${{env.RUST_NIGHTLY_VERSION}}" + + - name: Install taplo run: | - rustup toolchain install "nightly-$RUST_NIGHTLY_VERSION" --profile minimal --component rustfmt cargo install taplo-cli --version $TAPLO_VERSION - name: Rustfmt (check) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9d5deb9e7f..e97ee37494 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,7 @@ jobs: echo "should-release=$(.github/changelog-processor.py CHANGELOG.md --should-release)" >> $GITHUB_OUTPUT echo "version=$(.github/changelog-processor.py CHANGELOG.md --print-latest-version)" >> $GITHUB_OUTPUT cat $GITHUB_OUTPUT + runtime-matrix: needs: [ collect-release-information ] if: needs.collect-release-information.outputs.should-release == '1' @@ -32,6 +33,7 @@ jobs: TASKS=$(echo $(cat .github/workflows/runtimes-matrix.json) | sed 's/ //g' ) echo $TASKS echo "runtime=$TASKS" >> $GITHUB_OUTPUT + build-runtimes: needs: [ runtime-matrix ] continue-on-error: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3f39ff79cf..6bc4e525ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,32 +53,21 @@ jobs: matrix: runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }} steps: - - name: Install updates and protobuf-compiler - run: sudo apt update && sudo apt install --assume-yes cmake protobuf-compiler - - - name: Free space on the runner - run: | - df -h - sudo apt -y autoremove --purge - sudo apt -y autoclean - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - df -h - - name: Checkout uses: actions/checkout@v4 + - name: Install updates and dependencies + run: .github/install-deps.sh + - name: Set rust version via common env file run: cat .github/env >> $GITHUB_ENV - name: Install stable toolchain - run: | - rustup install $RUST_STABLE_VERSION - rustup default $RUST_STABLE_VERSION - rustup target add wasm32-unknown-unknown - rustup component add rust-src + uses: dtolnay/rust-toolchain@master + with: + targets: "wasm32-unknown-unknown" + components: "rust-src" + toolchain: "${{env.RUST_STABLE_VERSION}}" - name: Fetch cache uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 @@ -132,32 +121,21 @@ jobs: with: access_token: ${{ github.token }} - - name: Install updates and protobuf-compiler - run: sudo apt update && sudo apt install --assume-yes cmake protobuf-compiler - - - name: Free space on the runner - run: | - df -h - sudo apt -y autoremove --purge - sudo apt -y autoclean - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - df -h - - name: Checkout uses: actions/checkout@v4 + - name: Install updates and dependencies + run: .github/install-deps.sh + - name: Set rust version via common env file run: cat .github/env >> $GITHUB_ENV - name: Install stable toolchain - run: | - rustup install $RUST_STABLE_VERSION - rustup default $RUST_STABLE_VERSION - rustup target add wasm32-unknown-unknown - rustup component add rust-src + uses: dtolnay/rust-toolchain@master + with: + targets: "wasm32-unknown-unknown" + components: "rust-src" + toolchain: "${{env.RUST_STABLE_VERSION}}" - name: Fetch cache uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 @@ -178,32 +156,21 @@ jobs: with: access_token: ${{ github.token }} - - name: Install updates and protobuf-compiler - run: sudo apt update && sudo apt install --assume-yes cmake protobuf-compiler - - - name: Free space on the runner - run: | - df -h - sudo apt -y autoremove --purge - sudo apt -y autoclean - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - df -h - - name: Checkout uses: actions/checkout@v4 + - name: Install updates and dependencies + run: .github/install-deps.sh + - name: Set rust version via common env file run: cat .github/env >> $GITHUB_ENV - name: Install stable toolchain - run: | - rustup install $RUST_STABLE_VERSION - rustup default $RUST_STABLE_VERSION - rustup target add wasm32-unknown-unknown - rustup component add rust-src + uses: dtolnay/rust-toolchain@master + with: + targets: "wasm32-unknown-unknown" + components: "rust-src" + toolchain: "${{env.RUST_STABLE_VERSION}}" - name: Fetch cache uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 @@ -226,32 +193,21 @@ jobs: with: access_token: ${{ github.token }} - - name: Install updates and protobuf-compiler - run: sudo apt update && sudo apt install --assume-yes cmake protobuf-compiler - - - name: Free space on the runner - run: | - df -h - sudo apt -y autoremove --purge - sudo apt -y autoclean - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - df -h - - name: Checkout uses: actions/checkout@v4 + - name: Install updates and dependencies + run: .github/install-deps.sh + - name: Set rust version via common env file run: cat .github/env >> $GITHUB_ENV - name: Install stable toolchain - run: | - rustup install $RUST_STABLE_VERSION - rustup default $RUST_STABLE_VERSION - rustup target add wasm32-unknown-unknown - rustup component add rust-src + uses: dtolnay/rust-toolchain@master + with: + targets: "wasm32-unknown-unknown" + components: "rust-src" + toolchain: "${{env.RUST_STABLE_VERSION}}" - name: Fetch cache uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0