From 8488da84c33dfcc7b98df9b7e29eb0b0f54849c4 Mon Sep 17 00:00:00 2001 From: Sebastian Rollen Date: Wed, 16 Jun 2021 23:13:09 -0400 Subject: [PATCH] actions --- .github/workflows/ci.yml | 128 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 27 +++++++ 2 files changed, 155 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ded65b9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,128 @@ +on: + push: + branches: + - main + paths: + - 'Cargo.toml' + - 'Cargo.lock' + - 'Dockerfile' + - 'src/**' + pull_request: + paths: + - 'Cargo.toml' + - 'Cargo.lock' + - 'Dockerfile' + - 'src/**' + +name: Continuous integration + +jobs: + cancel-previous: + name: Cancel Previous Runs + runs-on: ubuntu-latest + steps: + - name: Cancel actions + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Cache + uses: actions/cache@v2 + id: cache + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Setup git credentials + uses: fusion-engineering/setup-git-credentials@v2 + with: + credentials: ${{secrets.GIT_USER_CREDENTIALS}} + - name: Setup toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Install rustfmt + run: rustup component add rustfmt + - name: Run check + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + needs: [fmt] + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Cache + uses: actions/cache@v2 + id: cache + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Setup git credentials + uses: fusion-engineering/setup-git-credentials@v2 + with: + credentials: ${{secrets.GIT_USER_CREDENTIALS}} + - name: Setup toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Install clippy + run: rustup component add clippy + - name: Run clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + coverage: + name: Test & Coverage + runs-on: ubuntu-latest + needs: [fmt, clippy] + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Cache + uses: actions/cache@v2 + id: cache + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Setup git credentials + uses: fusion-engineering/setup-git-credentials@v2 + with: + credentials: ${{secrets.GIT_USER_CREDENTIALS}} + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Install tarpaulin + run: cargo install cargo-tarpaulin + - name: Generate coverage + run: cargo tarpaulin --out Xml + - name: Upload to codecov + uses: codecov/codecov-action@v1 + with: + token: ${{secrets.CODECOV_TOKEN}} + fail_ci_if_error: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..24e502a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Release +on: + push: + branches: + - main + +jobs: + deploy: + name: Tag if new release + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Read version number + id: read_toml + uses: outcome-co/action-read-toml@v2.0.10 + with: + path: Cargo.toml + key: package.version + - name: Set tag env variable + run: echo IMAGE_TAG=v${{steps.read_toml.outputs.package_version}} >> $GITHUB_ENV + - uses: ncipollo/release-action@v1 + continue-on-error: true + with: + allowUpdates: false + tag: ${{ env.IMAGE_TAG }} + token: ${{ secrets.GITHUB_TOKEN }}