From 3c87a2632fbcbc92ed56610ede440d8c8547f28e Mon Sep 17 00:00:00 2001 From: jofas Date: Thu, 15 Dec 2022 17:56:47 +0100 Subject: [PATCH] new actions setup --- .github/workflows/benchmarks.yml | 40 +++++++++++++++++++++++++ .github/workflows/build.yml | 51 ++++++++++++++++---------------- .github/workflows/codecov.yml | 23 ++++++++++++++ 3 files changed, 88 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/benchmarks.yml create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml new file mode 100644 index 0000000..9dfeadb --- /dev/null +++ b/.github/workflows/benchmarks.yml @@ -0,0 +1,40 @@ +name: Benchmark +on: + push: + branches: + - main + pull_request: + branches: + - main +permissions: + contents: write +jobs: + Benchmark: + runs-on: ubuntu-latest + container: + image: rust:latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Load cached dependencies + uses: Swatinem/rust-cache@v2 + - name: Run benchmark + run: cargo bench -- --output-format bencher > bench.txt + - name: Load previous runs from cache + uses: actions/cache@v3 + with: + path: cache/benchmarks + key: benchmark-${{ runner.os }}-${{ github.run_id }} + restore-keys: benchmark-${{ runner.os }} + - name: Save benchmark + uses: benchmark-action/github-action-benchmark@v1 + with: + tool: 'cargo' + output-file-path: bench.txt + external-data-json-path: cache/benchmarks/benchmarks.json + github-token: ${{ secrets.GITHUB_TOKEN }} + save-data-file: ${{ github.event_name != 'pull_request' }} + comment-always: true + comment-on-alert: true + fail-on-alert: false + alert-threshold: '150%' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d583924..36625f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,45 +1,44 @@ name: Build on: [push] +permissions: + contents: write jobs: - Cleanup: + CleanupAndTest: runs-on: ubuntu-latest container: image: rust:latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - name: Add cargo features run: rustup component add rustfmt clippy - - name: Clippy fix - run: cargo clippy --all-features --all-targets --fix - - name: Fmt - run: cargo fmt + - name: Checkout repository + uses: actions/checkout@v3 + with: + path: repo + - name: Load cached dependencies + uses: Swatinem/rust-cache@v2 + with: + key: clippy + - name: Fmt + clippy + run: | + cd repo + cargo clippy --all-features --all-targets --fix + cargo fmt - name: Toc run: | curl https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc -o gh-md-toc chmod a+x gh-md-toc - ./gh-md-toc --insert --no-backup --hide-footer --skip-header README.md + ./gh-md-toc --insert --no-backup --hide-footer --skip-header repo/README.md rm gh-md-toc - name: Apply cleanup uses: EndBug/add-and-commit@v9 with: message: 'applying code formatting, lint fixes and toc creation' - Build: - runs-on: ubuntu-latest - container: - image: xd009642/tarpaulin:latest - options: --security-opt seccomp=unconfined - needs: Cleanup - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Add clippy - run: rustup component add clippy + cwd: repo - name: Fail build if clippy finds any error or warning - run: cargo clippy --all-features --all-targets -- -D warnings - - name: Generate code coverage - run: cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml - - name: Upload to codecov.io - uses: codecov/codecov-action@v2 - with: - fail_ci_if_error: true + run: | + cd repo + cargo clippy --all-features --all-targets -- -D warnings -D clippy::pedantic + - name: Run test suite + run: | + cd repo + cargo test diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..b369021 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,23 @@ +name: Codecov +on: [push] +permissions: + contents: write +jobs: + Codecov: + runs-on: ubuntu-latest + container: + image: xd009642/tarpaulin:latest + options: --security-opt seccomp=unconfined + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Load cached dependencies + uses: Swatinem/rust-cache@v2 + with: + key: tarpaulin + - name: Generate code coverage + run: cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml + - name: Upload to codecov.io + uses: codecov/codecov-action@v3 + with: + fail_ci_if_error: true