Skip to content

Merge pull request #3 from tsionyx/infinite #139

Merge pull request #3 from tsionyx/infinite

Merge pull request #3 from tsionyx/infinite #139

Workflow file for this run

name: Rust CI
on:
push:
branches:
- master
- dev
- release/*
#branches-ignore: [ 'temp/*' ]
pull_request:
branches: [ master ]
# https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow
workflow_dispatch:
env:
RUST_VERSIONS: "['1.74.0','stable','beta']"
APT_DEPENDENCIES: "['libasound2-dev']"
jobs:
get-env-vars:
name: Get Environment vars
runs-on: ubuntu-latest
outputs:
RUST_VERSIONS: ${{ env.RUST_VERSIONS }}
APT_DEPENDENCIES: ${{ env.APT_DEPENDENCIES }}
steps:
- run: echo "null"
fmt:
name: Verify formatting with `rustfmt` on rust '${{ matrix.rust }}'
runs-on: ubuntu-latest
needs: [ get-env-vars ]
strategy:
matrix:
# https://github.com/orgs/community/discussions/46785#discussioncomment-4909718
# https://github.com/actions/runner/issues/2372#issuecomment-1591370444
rust: ${{ fromJSON(needs.get-env-vars.outputs.RUST_VERSIONS) }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
components: rustfmt
override: true
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Static analysis with `clippy` on rust '${{ matrix.rust }}'
runs-on: ubuntu-latest
needs: [ get-env-vars ]
strategy:
matrix:
rust: ${{ fromJSON(needs.get-env-vars.outputs.RUST_VERSIONS) }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install deps
# https://github.com/orgs/community/discussions/27125#discussioncomment-3254720
if: ${{ fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES)[0] != null }}
run: sudo apt-get -y install ${{ join(fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES), ' ') }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
components: clippy
override: true
# Not using the fixed Cargo.lock results
# in too frequent changes and low cache usage.
# Should be enabled for binary crates which tracks
# Cargo.lock in the repository.
#
#- name: Generate Cargo.lock before the hash
# uses: actions-rs/cargo@v1
# with:
# command: generate-lockfile
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: ""
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets -- -D warnings
- name: Run cargo clippy with all features
uses: actions-rs/cargo@v1
#uses: actions-rs/clippy-check@v1 # TODO: annotating does not work: "Error: Resource not accessible by integration"
with:
command: clippy
#token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --all-targets --all-features -- -D warnings
test:
name: Test Suite on rust '${{ matrix.rust }}'
runs-on: ubuntu-latest
needs: [ get-env-vars, fmt, clippy ]
strategy:
matrix:
rust: ${{ fromJSON(needs.get-env-vars.outputs.RUST_VERSIONS) }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install deps
if: ${{ fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES)[0] != null }}
run: sudo apt-get -y install ${{ join(fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES), ' ') }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
#- name: Generate Cargo.lock before the hash
# uses: actions-rs/cargo@v1
# with:
# command: generate-lockfile
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: ""
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-targets --all-features --workspace
# - name: Run cargo test (ignored)
# uses: actions-rs/cargo@v1
# with:
# command: test
# args: --all-targets --all-features --workspace -- --ignored