From bd5acb4862c1f9fea32c27f30b214a53d30aea67 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 30 Oct 2024 16:00:10 -0700 Subject: [PATCH 01/10] Testing GHA --- .github/workflows/build-test.yml | 97 ++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/build-test.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..07c68d9 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,97 @@ +# Licensed under the Apache-2.0 license + +name: Build and Test + +on: + push: + branches: ["main"] + pull_request: + workflow_call: + workflow_dispatch: + +jobs: + build_and_test: + runs-on: ubuntu-24.04 + + env: + CARGO_INCREMENTAL: 0 + SCCACHE_VERSION: 0.3.3 + SCCACHE_GHA_CACHE_TO: sccache-caliptra-mcu-sw + SCCACHE_GHA_CACHE_FROM: sccache-caliptra-mcu-sw + # CPTRA_COVERAGE_PATH: /tmp + + # Change this to a new random value if you suspect the cache is corrupted + SCCACHE_C_CUSTOM_CACHE_BUSTER: 8b42a6e70ec4 + + # Compiler warnings should fail to compile + EXTRA_CARGO_CONFIG: "target.'cfg(all())'.rustflags = [\"-Dwarnings\"]" + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Test commit name + run: | + echo "Build-Test: release_ref=$(git rev-parse HEAD)" + + - name: Install required packages + run: | + sudo apt-get update -qy && \ + sudo apt-get install build-essential curl gcc-multilib gcc-riscv64-unknown-elf git + + - name: Restore sccache binary + uses: actions/cache/restore@v3 + id: sccache_bin_restore + with: + path: ~/.cargo/bin/sccache + key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }} + + - name: Install sccache + if: steps.sccache_bin_restore.outputs.cache-hit != 'true' + run: | + cargo install sccache --version ${SCCACHE_VERSION} --no-default-features --features=gha --locked + + # Save the sccache binary immediately so we can reuse it in future runs + # even if the rest of the current run fails. + - name: Save sccache binary + uses: actions/cache/save@v3 + if: steps.sccache_bin_restore.outputs.cache-hit != 'true' + with: + path: ~/.cargo/bin/sccache + key: ${{ steps.sccache_bin_restore.outputs.cache-primary-key }} + + - name: Configure sccache + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('RUSTC_WRAPPER', process.env.HOME + '/.cargo/bin/sccache'); + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - name: Check that Cargo.lock doesn't need to be updated + # Note: this isn't the same as checking that Cargo.lock is up to date + # (cargo update --locked), which makes sure that every package is the + # latest published version. This is just ensuring that every + # dependency has an entry in Cargo.lock that is compatible with the + # version requirements in all Cargo.toml files. + run: | + # This works because cargo tree requires a Cargo.lock with no required updates + cargo tree --locked > /dev/null || ( + echo "Please include required changes to Cargo.lock in your pull request" + # Without the --locked flag, cargo will do the minimal possible update to Cargo.lock + cargo tree > /dev/null 2> /dev/null + # Print out the differences to ease debugging + git diff Cargo.lock + exit 1 + ) + + - name: Install toolchains + run: rustup update && \ + rustup target add --toolchain nightly riscv32imc-unknown-none-elf && \ + rustup component add llvm-tools --toolchain nightly + + - name: Run precheckin + run: | + cargo xtask precheckin \ No newline at end of file From 2ec5344c99c0d6899b30eccdd5a34507e61ed13b Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 30 Oct 2024 16:02:13 -0700 Subject: [PATCH 02/10] Run on gha --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 07c68d9..f53cfe1 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -4,7 +4,7 @@ name: Build and Test on: push: - branches: ["main"] + branches: ["main", "gha"] pull_request: workflow_call: workflow_dispatch: From 8ca3cded7eac485c39a61cde136c73377d436c2c Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 30 Oct 2024 16:05:22 -0700 Subject: [PATCH 03/10] Update sccache --- .github/workflows/build-test.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f53cfe1..ac1e384 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -15,7 +15,7 @@ jobs: env: CARGO_INCREMENTAL: 0 - SCCACHE_VERSION: 0.3.3 + SCCACHE_VERSION: 0.8.2 SCCACHE_GHA_CACHE_TO: sccache-caliptra-mcu-sw SCCACHE_GHA_CACHE_FROM: sccache-caliptra-mcu-sw # CPTRA_COVERAGE_PATH: /tmp @@ -87,10 +87,8 @@ jobs: exit 1 ) - - name: Install toolchains - run: rustup update && \ - rustup target add --toolchain nightly riscv32imc-unknown-none-elf && \ - rustup component add llvm-tools --toolchain nightly + - name: Install llvm-tools + run: rustup component add llvm-tools --toolchain nightly - name: Run precheckin run: | From c2c68684ec419b467df68726b242399ce8f77f90 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 30 Oct 2024 16:16:50 -0700 Subject: [PATCH 04/10] Build first to install toolchains --- .github/workflows/build-test.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index ac1e384..5c3aee2 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -86,10 +86,15 @@ jobs: git diff Cargo.lock exit 1 ) + - name: Run cargo build + run: | + cargo --config "$EXTRA_CARGO_CONFIG" build --locked + sccache --show-stats - name: Install llvm-tools - run: rustup component add llvm-tools --toolchain nightly + run: rustup toolchain install rustup component add llvm-tools --toolchain nightly - name: Run precheckin run: | - cargo xtask precheckin \ No newline at end of file + cargo --config "$EXTRA_CARGO_CONFIG" xtask precheckin + sccache --show-stats \ No newline at end of file From 5fec5da7a10348396d35a810a3219cebed646700 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 30 Oct 2024 16:10:30 -0700 Subject: [PATCH 05/10] mdbook-gha --- .github/workflows/docs.yml | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..4a8e87e --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,63 @@ +# Licensed under the Apache-2.0 license + +# Sample workflow for building and deploying a mdBook site to GitHub Pages +# +# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html +# +name: Deploy mdBook site to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: [$default-branch] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + env: + MDBOOK_VERSION: 0.4.40 + steps: + - uses: actions/checkout@v4 + - name: Install mdBook + run: | + curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh + rustup update + cargo install --version ${MDBOOK_VERSION} mdbook + cargo install mdbook-mermaid + - name: Setup Pages + id: pages + uses: actions/configure-pages@v5 + - name: Build with mdBook + run: cd docs && mdbook build + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./docs/book + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file From 7e18ffae27868d79932fcaf5dda2c285aa15d152 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 30 Oct 2024 16:18:26 -0700 Subject: [PATCH 06/10] Add docs build --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4a8e87e..07fe3e6 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -9,7 +9,7 @@ name: Deploy mdBook site to Pages on: # Runs on pushes targeting the default branch push: - branches: [$default-branch] + branches: [$default-branch, gha] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From 8996b3874ca5ead9ce56c6eaa6a72460c2e47290 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 30 Oct 2024 16:20:17 -0700 Subject: [PATCH 07/10] Typo fix --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 5c3aee2..a656d01 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -92,7 +92,7 @@ jobs: sccache --show-stats - name: Install llvm-tools - run: rustup toolchain install rustup component add llvm-tools --toolchain nightly + run: rustup component add llvm-tools --toolchain nightly - name: Run precheckin run: | From 50e0d430ce00ca5ed6b01907efa23e7b5f9ccb47 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 30 Oct 2024 16:21:46 -0700 Subject: [PATCH 08/10] rustup update instead --- .github/workflows/build-test.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index a656d01..e8a5b90 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -39,7 +39,9 @@ jobs: - name: Install required packages run: | sudo apt-get update -qy && \ - sudo apt-get install build-essential curl gcc-multilib gcc-riscv64-unknown-elf git + sudo apt-get install build-essential curl gcc-multilib gcc-riscv64-unknown-elf git \ + curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh + rustup update - name: Restore sccache binary uses: actions/cache/restore@v3 @@ -86,13 +88,6 @@ jobs: git diff Cargo.lock exit 1 ) - - name: Run cargo build - run: | - cargo --config "$EXTRA_CARGO_CONFIG" build --locked - sccache --show-stats - - - name: Install llvm-tools - run: rustup component add llvm-tools --toolchain nightly - name: Run precheckin run: | From 72025735c2473a8bfd74a2f66d190ec19f5c6215 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 30 Oct 2024 16:33:50 -0700 Subject: [PATCH 09/10] Rename deploy docs --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 07fe3e6..b8a702e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -4,7 +4,7 @@ # # To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html # -name: Deploy mdBook site to Pages +name: Deploy docs on: # Runs on pushes targeting the default branch From f7e712574b9a25f5cc853e4ad4ef69d771b7169f Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 30 Oct 2024 16:42:03 -0700 Subject: [PATCH 10/10] Remove test branch from docs deploy and testing --- .github/workflows/build-test.yml | 2 +- .github/workflows/docs.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index e8a5b90..91965d7 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -4,7 +4,7 @@ name: Build and Test on: push: - branches: ["main", "gha"] + branches: ["main"] pull_request: workflow_call: workflow_dispatch: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b8a702e..1873ba5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -9,7 +9,7 @@ name: Deploy docs on: # Runs on pushes targeting the default branch push: - branches: [$default-branch, gha] + branches: [main] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: