Skip to content

refactor: add support to define_tedge_config for (optionally) multi-value fields #6313

refactor: add support to define_tedge_config for (optionally) multi-value fields

refactor: add support to define_tedge_config for (optionally) multi-value fields #6313

name: Pull Request Checks
on:
workflow_dispatch:
pull_request:
merge_group:
env:
CARGO_TERM_COLOR: always
jobs:
block-fixup:
name: Block fixup commits
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Block Fixup Commit Merge
# https://github.com/13rac1/block-fixup-merge-action
uses: 13rac1/[email protected]
# JOB to run change detection
changes:
name: Filter changes
runs-on: ubuntu-20.04
# Set job outputs to values from filter step
outputs:
rust: ${{ steps.filter.outputs.rust || 'true' }}
workflows: ${{ steps.filter.outputs.workflows || 'true' }}
docs: ${{ steps.filter.outputs.docs || 'true' }}
continue-on-error: true
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
if: ${{ github.event_name == 'pull_request' }}
# https://github.com/dorny/paths-filter
id: filter
with:
filters: |
rust:
- 'crates/**'
- 'plugins/**'
- 'Cargo.*'
workflows:
- '.github/workflows/**'
docs:
- 'docs/**'
#
# Checking that Cargo.lock is up to date
#
check-lockfile-uptodate:
name: Check whether Cargo.lock is up to date
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'pull_request' }}
outputs:
locks: ${{ steps.filter.outputs.locks }}
steps:
- uses: actions/checkout@v4
- name: Retrieve MSRV from workspace Cargo.toml
id: rust_version
uses: SebRollen/[email protected]
with:
file: Cargo.toml
field: "workspace.package.rust-version"
- name: Enable toolchain via github action
uses: dtolnay/rust-toolchain@master
with:
targets: armv7-unknown-linux-gnueabihf
toolchain: ${{ steps.rust_version.outputs.value }}
- uses: Swatinem/rust-cache@v2
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
locks:
- '**/Cargo.toml'
- name: Check whether lockfile is up to date
if: steps.filter.outputs.locks == 'true'
run: cargo check --locked
udeps:
name: Check for unused dependencies
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Run cargo-udeps
run: |
cargo install --git https://github.com/est31/cargo-udeps --locked
cargo udeps --all-features --all-targets
dependency-sort:
name: Sort dependencies
runs-on: ubuntu-20.04
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: Install taplo
run: cargo install taplo-cli
- name: Check Cargo.toml formatting
run: taplo fmt --check
cargo-fmt:
name: Run cargo fmt
runs-on: ubuntu-20.04
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Nightly toolchain is needed for cargo fmt since issue: https://github.com/thin-edge/thin-edge.io/issues/1660
# dtolnay/rust-toolchain is preferred over actions-rs/toolchain is currently not maintained and currently using
# deprecated GHA api (see https://github.com/actions-rs/toolchain/issues/219).
# However since dtolnay/rust-toolchain does not support the 'override' option, an additional call to
# rustup override is required (see https://github.com/dtolnay/rust-toolchain/issues/29#issuecomment-1412903426)
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Cargo fmt --version
run: cargo fmt --version
- name: Cargo fmt
run: cargo fmt -- --check
cargo-clippy:
name: Run cargo clippy
runs-on: ubuntu-20.04
env:
RUSTFLAGS: -D warnings
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Enable cache
# https://github.com/marketplace/actions/rust-cache
uses: Swatinem/rust-cache@v2
- name: Cargo clippy
run: |
cargo clippy --version
cargo clippy --all-targets --all-features
cargo-audit:
name: Run cargo audit
runs-on: ubuntu-20.04
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: Cargo audit
run: cargo audit
# Only run check if the project still compiles on MSRV, test are run on stable
check-msrv:
name: Run cargo check on MSRV
runs-on: ubuntu-20.04
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Retrieve MSRV from workspace Cargo.toml
id: rust_version
uses: SebRollen/[email protected]
with:
file: Cargo.toml
field: "workspace.package.rust-version"
- name: Enable rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust_version.outputs.value }}
- name: Enable cache
uses: Swatinem/rust-cache@v2
- name: Run `cargo check`
run: cargo check --all-targets --all-features
cargo-test:
name: Run cargo test
runs-on: ubuntu-20.04
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Check disk space before setting up
run: df -BM
- name: Reclaim some disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf /opt/hostedtoolcache
- name: Check disk space after freeing
run: df -BM
- name: Checkout
uses: actions/checkout@v4
- name: Retrieve MSRV from workspace Cargo.toml
id: rust_version
uses: SebRollen/[email protected]
with:
file: Cargo.toml
field: "workspace.package.rust-version"
- name: Enable toolchain via github action
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Enable cache
uses: Swatinem/rust-cache@v2
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: cargo llvm-cov
run: cargo llvm-cov nextest --no-fail-fast --locked --all-features --all-targets --codecov --output-path codecov.json
# https://github.com/rust-lang/cargo/issues/6669
- name: cargo test --doc
run: cargo test --locked --all-features --doc
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Check disk space after completing workflow
run: df -BM
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
typos:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/[email protected]
continue-on-error: true
- run: exit 0
doc:
runs-on: ubuntu-latest
name: nightly / doc
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Enable cache
uses: Swatinem/rust-cache@v2
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: cargo doc
run: cargo doc --no-deps --all-features --workspace
markdown:
# Validate that the markdown is correct before merging as errors will cause
# the publishing of the docs to github pages to fail
runs-on: ubuntu-latest
name: Check markdown
needs: changes
if: ${{ needs.changes.outputs.docs == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
# use tedge-docs nodejs version for guidance, though it is not mandatory
# https://github.com/thin-edge/tedge-docs
node-version: '>=18.0'
- run: npx docusaurus-mdx-checker
working-directory: docs