Include job status in Discord notification #142
Workflow file for this run
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
name: Rust | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
CARGO_TERM_COLOR: always | |
# don't install husky hooks during CI as they are only needed for for pre-push | |
CARGO_HUSKY_DONT_INSTALL_HOOKS: true | |
jobs: | |
lint: | |
name: Formatting and linting | |
strategy: | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install Rust nightly | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: rustfmt | |
- name: Install cargo-make | |
uses: taiki-e/install-action@cargo-make | |
- name: Check typos | |
uses: crate-ci/typos@master | |
- name: Install cargo-make | |
uses: taiki-e/install-action@cargo-make | |
- name: Check formatting | |
run: cargo make fmt-check | |
- name: Lint dependencies | |
uses: EmbarkStudios/cargo-deny-action@v1 | |
clippy: | |
name: Clippy | |
strategy: | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install Rust nightly | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: clippy | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
env: | |
cache-name: ci | |
with: | |
shared-key: ubuntu-latest-${{ env.cache-name }}-stable | |
- name: Install cargo-make | |
uses: taiki-e/install-action@cargo-make | |
- name: Check clippy | |
run: cargo make clippy | |
check: | |
name: Check | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install Rust stable | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
env: | |
cache-name: ci | |
with: | |
shared-key: ${{ matrix.os }}-${{ env.cache-name }}-stable | |
- name: Install cargo-make | |
uses: taiki-e/install-action@cargo-make | |
- name: Check | |
run: cargo make check | |
env: | |
RUST_BACKTRACE: full | |
test: | |
name: Test | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install Rust stable | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
env: | |
cache-name: ci | |
with: | |
shared-key: ${{ matrix.os }}-${{ env.cache-name }}-stable | |
- name: Install cargo-make | |
uses: taiki-e/install-action@cargo-make | |
- name: Test | |
run: cargo make test | |
env: | |
RUST_BACKTRACE: full | |
# Send Discord notification after every other job | |
notification: | |
name: Discord notification | |
needs: [lint, clippy, check, test] | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Setup notification | |
uses: 8BitJonny/gh-get-current-pr@v2.2.0 | |
id: pr | |
- name: Actions Status Discord | |
uses: sarisia/actions-status-discord@v1.12.0 | |
with: | |
url: ${{ steps.pr.outputs.pr_url }} | |
webhook: ${{ secrets.FO_DISCORD_WEB_DEVELOPMENT_WEBHOOK }} | |
title: ${{ steps.pr.outputs.pr_title }} | |
status: ${{ contains(needs.*.result, 'failure') && 'failure' || contains(needs.*.result, 'cancelled') && 'cancelled' || contains(needs.*.result, 'skipped') && 'skipped' || 'success' }} |