Skip to content

Spec sync

Spec sync #281

Workflow file for this run

# ********************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************/
# Comprehensive combination of checks, linting, feature-checks, testing to be run on merge and on PR
# Upload test results for potential re-use in publication workflow, returns the corresponding download URL as an output on workflow_call
name: Cargo
on:
push:
branches:
- main
pull_request:
paths:
- "src/**"
- "Cargo.*"
- "build.rs"
- "deny.toml"
workflow_call:
outputs:
test_results_url:
description: "URL of the test results artifact"
value: ${{ jobs.nextest.outputs.test_results_url }}
doctest_results_url:
description: "URL of the doctest results artifact"
value: ${{ jobs.doctest.outputs.test_results_url }}
workflow_dispatch:
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
RUST_TOOLCHAIN: ${{ vars.RUST_TOOLCHAIN || 'stable' }}
RUSTFLAGS: -Dwarnings
CARGO_TERM_COLOR: always
jobs:
deny:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: EmbarkStudios/cargo-deny-action@v2
with:
rust-version: ${{ env.RUST_TOOLCHAIN }}
command: check
arguments: --all-features
# [impl->req~up-language-ci-build~1]
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Run cargo check
run: |
cargo check --all --tests
# [impl->req~up-language-ci-linter~1]
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- name: Run cargo fmt
run: |
cargo fmt --all -- --check
# [impl->req~up-language-ci-linter~1]
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: clippy
- name: Run cargo clippy
run: |
cargo clippy --version
cargo clippy --tests --examples
# [impl->req~up-language-ci-api-docs~1]
docu:
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Run rustdoc
run: |
cargo doc --no-deps --all-features
feature-check:
# Comprehensive check on dependencies for all feature flag combinations, excluding development dependencies
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
- name: Run cargo hack powerset
run: |
cargo hack check --feature-powerset --no-dev-deps
# [impl->req~up-language-ci-test~1]
nextest:
# Subset of feature-combos, on only one OS - more complete testing in test-featurematrix.yaml
outputs:
test_results_url: ${{ steps.test_results.outputs.artifact-url }}
runs-on: ubuntu-latest
env:
NEXTEST_EXPERIMENTAL_LIBTEST_JSON: 1
strategy:
matrix:
feature-flags: ["", "--no-default-features", "--all-features"]
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- uses: Swatinem/rust-cache@v2
# Using nextest because it's faster than built-in test
- uses: taiki-e/install-action@nextest
- name: Run cargo nextest
run: |
cargo nextest run --message-format libtest-json-plus ${{ matrix.feature-flags }} > testresults${{ matrix.feature-flags }}.json
- name: Upload all-features test results artifact
id: test_results
if: matrix.feature-flags == '--all-features'
uses: actions/upload-artifact@v4
with:
name: test-results
path: testresults--all-features.json
# [impl->req~up-language-ci-test~1]
doctest:
# Run doctests separately, as nextest doesn't yet (https://github.com/nextest-rs/nextest/issues/16)
outputs:
test_results_url: ${{ steps.doctest_results.outputs.artifact-url }}
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Run doc tests
run: |
RUSTC_BOOTSTRAP=1 cargo test --doc --all-features -- -Z unstable-options --format json --report-time > doctestresults--all-features.json
- name: Upload doctest results artifact
id: doctest_results
uses: actions/upload-artifact@v4
with:
name: doctest-results
path: doctestresults--all-features.json