diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000..07c68d98 --- /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 diff --git a/Cargo.lock b/Cargo.lock index 1d2e71de..dafe260e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "0.6.15"