Skip to content

Constant uptime

Constant uptime #761

Workflow file for this run

name: Fmt and Clippy
# This job runs rustfmt and clippy linting,
on:
push:
branches: main
pull_request:
branches: main
workflow_dispatch: # allows manual trigger
env:
RUST_FMT_VERSION: nightly-2023-04-01-x86_64-unknown-linux-gnu
CRATE_TO_RUST_VERSION_MAP: '{}'
DEFAULT_RUST_VERSION: "1.76"
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
name: 'Detect changes'
outputs:
crates: ${{ steps.filter.outputs.changes }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
notification-server/Cargo.toml:
- 'notification-server/**'
- '.github/**'
"lint_fmt":
name: lint:fmt
runs-on: ubuntu-latest
if: needs.changes.outputs.crates != '[]'
needs: [changes]
strategy:
fail-fast: false
matrix:
crates: ${{ fromJSON(needs.changes.outputs.crates) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup default ${{ env.RUST_FMT_VERSION }}
rustup component add rustfmt
- name: Format
run: |
cargo fmt --manifest-path=${{ matrix.crates }} -- --check
"lint_clippy":
name: lint:clippy
needs: [changes, lint_fmt]
if: needs.changes.outputs.crates != '[]'
strategy:
fail-fast: false
matrix:
crates: ${{ fromJSON(needs.changes.outputs.crates) }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
run: |
RUST_VERSION=$(echo '${{ env.CRATE_TO_RUST_VERSION_MAP }}' | jq -r '.["${{ matrix.crates }}"] // "${{ env.DEFAULT_RUST_VERSION }}"')
rustup default $RUST_VERSION
rustup component add clippy
- name: Clippy
run: |
cargo clippy --manifest-path ${{ matrix.crates }} --locked -- -D warnings
tests:
name: tests
runs-on: ubuntu-latest
needs: [changes, lint_fmt]
strategy:
fail-fast: false
matrix:
crates: ${{ fromJSON(needs.changes.outputs.crates) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
run: |
RUST_VERSION=$(echo '${{ env.CRATE_TO_RUST_VERSION_MAP }}' | jq -r '.["${{ matrix.crates }}"] // "${{ env.DEFAULT_RUST_VERSION }}"')
rustup default $RUST_VERSION
- name: Setup dependencies
if: matrix.crates == 'notification-server/Cargo.toml'
run: |
cd notification-server
make
- name: Cargo tests
run: |
cargo test --manifest-path ${{ matrix.crates }} --locked