From 9d8137cb84aeef467f2bc3c5d5f3ed0e20705659 Mon Sep 17 00:00:00 2001 From: sunchengzhu <36075573+sunchengzhu@users.noreply.github.com> Date: Thu, 21 Sep 2023 23:09:12 +0800 Subject: [PATCH] ci: use `Cache of Cargo` for workflows (#1445) --- .github/workflows/openzeppelin_test_11.yml | 25 ++++++++++++++--- .github/workflows/openzeppelin_test_16_19.yml | 25 ++++++++++++++--- .../openzeppelin_test_1_5_and_12_15.yml | 25 ++++++++++++++--- .github/workflows/openzeppelin_test_6_10.yml | 26 +++++++++++++++--- .github/workflows/v3_core_test.yml | 27 +++++++++++++++---- 5 files changed, 107 insertions(+), 21 deletions(-) diff --git a/.github/workflows/openzeppelin_test_11.yml b/.github/workflows/openzeppelin_test_11.yml index 444ce5db1..b4a8efc6d 100644 --- a/.github/workflows/openzeppelin_test_11.yml +++ b/.github/workflows/openzeppelin_test_11.yml @@ -97,13 +97,18 @@ jobs: restore-keys: | ${{ runner.os }}-node_modules- - - name: Cache of the axon binary + - name: Cache of Cargo uses: actions/cache@v3 with: path: | - target/debug/axon - target/release/axon - key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Build Axon in the development profile + run: cargo build - name: Deploy Local Network of Axon run: | @@ -117,6 +122,18 @@ jobs: --config devtools/chain/config.toml \ >> /tmp/log 2>&1 & + - name: Check Axon Status Before Test + run: | + response=$(curl -s -w "\n%{http_code}" http://localhost:8000 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"web3_clientVersion","params": [],"id":1}') + http_code=$(echo "$response" | tail -n1) + response_body=$(echo "$response" | sed '$d') + if [[ "$http_code" -ne 200 ]]; then + echo "Axon status check failed with HTTP status code: $http_code" + exit 1 + else + echo "$response_body" + fi + - name: Run prepare id: runtest run: | diff --git a/.github/workflows/openzeppelin_test_16_19.yml b/.github/workflows/openzeppelin_test_16_19.yml index e2c1fb844..b01c1d346 100644 --- a/.github/workflows/openzeppelin_test_16_19.yml +++ b/.github/workflows/openzeppelin_test_16_19.yml @@ -97,13 +97,18 @@ jobs: restore-keys: | ${{ runner.os }}-node_modules- - - name: Cache of the axon binary + - name: Cache of Cargo uses: actions/cache@v3 with: path: | - target/debug/axon - target/release/axon - key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Build Axon in the development profile + run: cargo build - name: Deploy Local Network of Axon run: | @@ -117,6 +122,18 @@ jobs: --config devtools/chain/config.toml \ >> /tmp/log 2>&1 & + - name: Check Axon Status Before Test + run: | + response=$(curl -s -w "\n%{http_code}" http://localhost:8000 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"web3_clientVersion","params": [],"id":1}') + http_code=$(echo "$response" | tail -n1) + response_body=$(echo "$response" | sed '$d') + if [[ "$http_code" -ne 200 ]]; then + echo "Axon status check failed with HTTP status code: $http_code" + exit 1 + else + echo "$response_body" + fi + - name: Run prepare id: runtest run: | diff --git a/.github/workflows/openzeppelin_test_1_5_and_12_15.yml b/.github/workflows/openzeppelin_test_1_5_and_12_15.yml index 17b0c4288..4c048668f 100644 --- a/.github/workflows/openzeppelin_test_1_5_and_12_15.yml +++ b/.github/workflows/openzeppelin_test_1_5_and_12_15.yml @@ -98,13 +98,18 @@ jobs: restore-keys: | ${{ runner.os }}-node_modules- - - name: Cache of the axon binary + - name: Cache of Cargo uses: actions/cache@v3 with: path: | - target/debug/axon - target/release/axon - key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Build Axon in the development profile + run: cargo build - name: Deploy Local Network of Axon run: | @@ -118,6 +123,18 @@ jobs: --config devtools/chain/config.toml \ >> /tmp/log 2>&1 & + - name: Check Axon Status Before Test + run: | + response=$(curl -s -w "\n%{http_code}" http://localhost:8000 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"web3_clientVersion","params": [],"id":1}') + http_code=$(echo "$response" | tail -n1) + response_body=$(echo "$response" | sed '$d') + if [[ "$http_code" -ne 200 ]]; then + echo "Axon status check failed with HTTP status code: $http_code" + exit 1 + else + echo "$response_body" + fi + - name: Run prepare id: runtest run: | diff --git a/.github/workflows/openzeppelin_test_6_10.yml b/.github/workflows/openzeppelin_test_6_10.yml index 29e8ff1c7..759fa6a12 100644 --- a/.github/workflows/openzeppelin_test_6_10.yml +++ b/.github/workflows/openzeppelin_test_6_10.yml @@ -97,13 +97,18 @@ jobs: restore-keys: | ${{ runner.os }}-node_modules- - - name: Cache of the axon binary + - name: Cache of Cargo uses: actions/cache@v3 with: path: | - target/debug/axon - target/release/axon - key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Build Axon in the development profile + run: cargo build - name: Deploy Local Network of Axon run: | @@ -116,6 +121,19 @@ jobs: ./target/debug/axon run \ --config devtools/chain/config.toml \ >> /tmp/log 2>&1 & + + - name: Check Axon Status Before Test + run: | + response=$(curl -s -w "\n%{http_code}" http://localhost:8000 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"web3_clientVersion","params": [],"id":1}') + http_code=$(echo "$response" | tail -n1) + response_body=$(echo "$response" | sed '$d') + if [[ "$http_code" -ne 200 ]]; then + echo "Axon status check failed with HTTP status code: $http_code" + exit 1 + else + echo "$response_body" + fi + - name: Run prepare id: runtest run: | diff --git a/.github/workflows/v3_core_test.yml b/.github/workflows/v3_core_test.yml index 090fa82e6..dc9917c84 100644 --- a/.github/workflows/v3_core_test.yml +++ b/.github/workflows/v3_core_test.yml @@ -82,17 +82,21 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 20.x - - id: yarn-cache run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - name: Cache of the axon binary + - name: Cache of Cargo uses: actions/cache@v3 with: path: | - target/debug/axon - target/release/axon - key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Build Axon in the development profile + run: cargo build - name: Deploy Local Network of Axon run: | @@ -105,6 +109,19 @@ jobs: ./target/debug/axon run \ --config devtools/chain/config.toml \ >> /tmp/log 2>&1 & + + - name: Check Axon Status Before Test + run: | + response=$(curl -s -w "\n%{http_code}" http://localhost:8000 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"web3_clientVersion","params": [],"id":1}') + http_code=$(echo "$response" | tail -n1) + response_body=$(echo "$response" | sed '$d') + if [[ "$http_code" -ne 200 ]]; then + echo "Axon status check failed with HTTP status code: $http_code" + exit 1 + else + echo "$response_body" + fi + - name: Install dependencies run: | cd /home/runner/work/axon/axon/v3-core