refactor: Fix new clippy warnings/errors #97
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: [push, pull_request] | |
name: Test and Release | |
jobs: | |
clippy_check: | |
name: Clippy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- run: rustup component add clippy | |
- uses: actions-rs/clippy-check@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
args: --all-features | |
build_and_test: | |
name: Test Noxious | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Cargo cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build release | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --all-features | |
- name: Run cargo-tarpaulin | |
uses: actions-rs/[email protected] | |
with: | |
version: "0.16.0" | |
args: "--ignore-tests --out Lcov -- --test-threads 1" | |
- name: Coveralls | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path-to-lcov: './lcov.info' | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v1 | |
with: | |
name: code-coverage-report | |
path: cobertura.xml | |
semantic_release: | |
name: Semantic Release | |
needs: [build_and_test, clippy_check] | |
if: github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Cargo cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Setup Node for semantic release | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "14" | |
- name: Install semantic release | |
run: npm install -g semantic-release @semantic-release/exec @semantic-release/git | |
- name: Run semantic release | |
id: semantic_release | |
shell: bash | |
run: | | |
semantic-release | |
TAG=$(git --no-pager tag --points-at HEAD) | |
echo "::set-output name=tag::$TAG" | |
echo "::set-output name=version::${TAG:1}" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
- name: Upload executable | |
uses: actions/upload-artifact@v2 | |
with: | |
name: noxious-server-${{ runner.os }}-${{ github.sha }} | |
path: ./target/release/noxious-server | |
retention-days: 1 | |
# TODO: remove this from here and move it to the build artifacts workflow | |
# So that we are sure that the version numbers are updated in the binary | |
- name: Upload executable to release | |
uses: svenstaro/upload-release-action@v1-release | |
if: steps.semantic_release.outputs.tag != '' | |
with: | |
repo_token: ${{ secrets.PAT }} | |
file: ./target/release/noxious-server | |
asset_name: noxious-server-${{ steps.semantic_release.outputs.tag }}-linux-amd64 | |
tag: ${{ steps.semantic_release.outputs.tag }} | |
overwrite: true | |
- name: Dispatch Build Image | |
uses: peter-evans/repository-dispatch@v1 | |
if: steps.semantic_release.outputs.tag != '' | |
with: | |
token: ${{ secrets.PAT }} | |
event-type: build-artifacts | |
client-payload: '{"tag": "${{ steps.semantic_release.outputs.tag }}", "version": "${{ steps.semantic_release.outputs.version }}" }' |