From fd009c1a7db10df077f7892eeda334fc78040aa7 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sat, 22 Jul 2023 15:48:17 +1000 Subject: [PATCH 1/2] Enable dependabot for cargo and GHA Signed-off-by: Jiahao XU --- .github/dependabot.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8bb6408 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +# Dependabot dependency version checks / updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + # Workflow files stored in the + # default location of `.github/workflows` + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "daily" From a79bc8a10552084e809afe4dfb8be3bbd2e615eb Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sat, 22 Jul 2023 15:58:31 +1000 Subject: [PATCH 2/2] Add CI for pull requests and pushs to branches Signed-off-by: Jiahao XU --- .github/workflows/ci.yml | 76 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7e90135 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,76 @@ +name: CI + +on: + merge_group: + pull_request: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse + +jobs: + test: + strategy: + fail-fast: false + matrix: + include: + - flags: "" + - flags: --release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install latest rust + run: rustup toolchain install stable --no-self-update --profile minimal + - name: Create Cargo.lock + run: cargo update + + - uses: Swatinem/rust-cache@v2 + env: + RUSTFLAGS: ${{ steps.retrieve-rustflags.outputs.RUSTFLAGS }} + + - name: Test + run: cargo test ${{ matrix.flags }} + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install latest rust + run: rustup toolchain install stable --no-self-update --profile minimal --component rustfmt,clippy + - name: Ignore dev-dependencies + run: | + sed 's/\[dev-dependencies\]/[workaround-avoid-dev-deps]/g' Cargo.toml >Cargo.toml.tmp + mv Cargo.toml.tmp Cargo.toml + - name: Create Cargo.lock + run: cargo update + + - uses: Swatinem/rust-cache@v2 + env: + RUSTFLAGS: ${{ steps.retrieve-rustflags.outputs.RUSTFLAGS }} + + - name: lint + run: | + cargo clippy --no-deps -- -D clippy::all + cargo doc --no-deps + cargo fmt --all -- --check + + # Dummy job to have a stable name for the "all tests pass" requirement + tests-pass: + name: Tests pass + needs: + - test + - lint + if: always() # always run even if dependencies fail + runs-on: ubuntu-latest + steps: + # fail if ANY dependency has failed or been skipped or cancelled + - if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')" + run: exit 1 + - run: exit 0