Skip to content

Commit 7a2b647

Browse files
committed
Add CI
1 parent 2081c27 commit 7a2b647

18 files changed

+1152
-15
lines changed

.github/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (c) 2024 Contributors to the Eclipse Foundation
2+
#
3+
# See the NOTICE file(s) distributed with this work for additional
4+
# information regarding copyright ownership.
5+
#
6+
# This program and the accompanying materials are made available under the
7+
# terms of the Apache License Version 2.0 which is available at
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# SPDX-License-Identifier: Apache-2.0
11+
12+
# This is the configuration used by GitHub for automatically creating release notes
13+
# from pull requests based on their labels
14+
# see https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
15+
16+
changelog:
17+
exclude:
18+
labels:
19+
- duplicate
20+
- wontfix
21+
- invalid
22+
authors:
23+
- octocat
24+
categories:
25+
- title: "🛠️ Breaking Changes"
26+
labels:
27+
- "breaking change"
28+
- title: "✨ Features"
29+
labels:
30+
- enhancement
31+
- title: "🐛 Bug Fixes"
32+
labels:
33+
- bug
34+
- title: "📚 Documentation"
35+
labels:
36+
- documentation
37+
- title: "Other Changes"
38+
labels:
39+
- "*"

.github/workflows/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Which automations do we run?
2+
3+
This file is meant to provide an overview and explainer on what the up-subscription-rust workflow automation strategy is, and what the different workflow elements do.
4+
5+
__A general note:__ All workflows will use the `stable` version of the Rust toolchain, unless the GitHub actions variable `RUST_TOOLCHAIN` is set to pin a specific Rust version (e.g. ```RUST_TOOLCHAIN=1.76.0```).
6+
7+
At this time, there are three events that will initiate a workflow run:
8+
9+
## PRs and merges to main
10+
11+
We want a comprehensive but also quick check&test workflow. This should be testing all relevant/obvious feature sets, run on all major OSes, and of course include all the Rust goodness around cargo check, fmt, clippy and so on.
12+
13+
This is implemented in [`check.yaml`](check.yaml)
14+
15+
## Release publication
16+
17+
We want exhaustive tests and all possible checks, as well as creation of license reports, collection of quality artifacts and publication to crates.io. This workflow pulls in other pieces like the build workflow. An actual release is triggered by pushing a tag that begins with 'v', else this workflow just generates and collects artifacts on workflow level. This will also publish to crates.io if the CRATES_TOKEN secret is set.
18+
19+
This is implemented in [`release.yaml`](release.yaml)
20+
21+
## Nightly, out of everyone's way
22+
23+
All the tests we can think of, however long they might take. For instance, we can build up-subscription-rust for different architectures - this might not really create many insights, but doesn't hurt to try either, and fits nicely into a nightly build schedule.
24+
25+
This is implemented in [`nightly.yaml`](nightly.yaml)
26+
27+
## Further workflow modules
28+
29+
In addition to the main workflows described above, there exist a number of modules that are used by these main workflows. They can also be run standalone, and are intendet to make composing the capabilities of our main workflows simpler. These are:
30+
31+
- `verify-msrv.yaml` - checks if the MSRV ('Minimum Supported Rust Version) declared in Cargo.toml is correct
32+
- `coverage.yaml` - collects test code coverage, and can optionally upload the results to codecov.io
33+
- Will publish coverage data to CodeCov if `${{ secrets.CODECOV_TOKEN }}` is set
34+
- outputs: download URL for the workflow-generated coverage info file
35+
- `license-report.yaml` - create a license report for `up-rust` and all its dependencies in html format
36+
- outputs: download URL for the workflow-generated license report
37+
- `test-featurematrix.yaml` - Test all feature combinations on a range of OS platforms
38+
- `x-build.yaml` - Run release builds on multiple architecture targets

.github/workflows/check.yaml

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# ********************************************************************************
2+
# Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************/
13+
14+
# Comprehensive combination of checks, linting, feature-checks, testing to be run on merge and on PR
15+
# Upload test results for potential re-use in publication workflow, returns the corresponding download URL as an output on workflow_call
16+
17+
name: Cargo
18+
19+
on:
20+
push:
21+
branches:
22+
- main
23+
pull_request:
24+
paths:
25+
- "src/**"
26+
- "Cargo.*"
27+
- "deny.toml"
28+
workflow_call:
29+
inputs:
30+
package:
31+
description: "Which rust package to check"
32+
required: false
33+
default: '"*"' # for some reason, this default is ignored, so we have to repeat the pattern below
34+
type: string
35+
outputs:
36+
test_results_url:
37+
description: "URL of the test results artifact"
38+
value: ${{ jobs.nextest.outputs.test_results_url }}
39+
doctest_results_url:
40+
description: "URL of the doctest results artifact"
41+
value: ${{ jobs.doctest.outputs.test_results_url }}
42+
43+
concurrency:
44+
group: ${{ github.ref }}-${{ github.workflow }}
45+
cancel-in-progress: true
46+
47+
env:
48+
RUST_TOOLCHAIN: ${{ vars.RUST_TOOLCHAIN || 'stable' }}
49+
RUSTFLAGS: -Dwarnings
50+
CARGO_TERM_COLOR: always
51+
52+
jobs:
53+
deny:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
- uses: dtolnay/rust-toolchain@master
58+
with:
59+
toolchain: ${{ env.RUST_TOOLCHAIN }}
60+
- uses: taiki-e/install-action@cargo-deny
61+
- name: Run cargo deny check
62+
run: |
63+
cargo deny check
64+
65+
check:
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v4
69+
- uses: dtolnay/rust-toolchain@master
70+
with:
71+
toolchain: ${{ env.RUST_TOOLCHAIN }}
72+
- name: Run cargo check
73+
run: |
74+
cargo check --package ${{ inputs.package || '"*"' }} --all --tests
75+
76+
fmt:
77+
runs-on: ubuntu-latest
78+
steps:
79+
- uses: actions/checkout@v4
80+
- uses: dtolnay/rust-toolchain@master
81+
with:
82+
toolchain: ${{ env.RUST_TOOLCHAIN }}
83+
components: rustfmt
84+
- name: Run cargo fmt
85+
run: |
86+
cargo fmt --package ${{ inputs.package || '"*"' }} --all -- --check
87+
88+
clippy:
89+
runs-on: ubuntu-latest
90+
steps:
91+
- uses: actions/checkout@v4
92+
- uses: dtolnay/rust-toolchain@master
93+
with:
94+
toolchain: ${{ env.RUST_TOOLCHAIN }}
95+
components: clippy
96+
- name: Run cargo clippy
97+
run: |
98+
cargo clippy --version
99+
cargo clippy --tests --examples
100+
101+
docu:
102+
runs-on: ubuntu-latest
103+
env:
104+
RUSTDOCFLAGS: -Dwarnings
105+
steps:
106+
- uses: actions/checkout@v4
107+
- uses: dtolnay/rust-toolchain@master
108+
with:
109+
toolchain: ${{ env.RUST_TOOLCHAIN }}
110+
- name: Run rustdoc
111+
run: |
112+
cargo doc --package ${{ inputs.package || '"*"' }} --no-deps --all-features
113+
114+
feature-check:
115+
# Comprehensive check on dependencies for all feature flag combinations, excluding development dependencies
116+
needs: check
117+
# do not run for package 'up-subscription' - the cargo hack module does not properly support --package="*" at the moment, so different approach than the other instances
118+
if: inputs.package != 'up-subscription'
119+
runs-on: ubuntu-latest
120+
steps:
121+
- uses: actions/checkout@v4
122+
- uses: dtolnay/rust-toolchain@master
123+
with:
124+
toolchain: ${{ env.RUST_TOOLCHAIN }}
125+
- uses: Swatinem/rust-cache@v2
126+
- uses: taiki-e/install-action@cargo-hack
127+
- name: Run cargo hack powerset
128+
run: |
129+
cargo hack check --feature-powerset --no-dev-deps
130+
131+
nextest:
132+
# Subset of feature-combos, on only one OS - more complete testing in test-featurematrix.yaml
133+
outputs:
134+
test_results_url: ${{ steps.test_results.outputs.artifact-url }}
135+
runs-on: ubuntu-latest
136+
env:
137+
NEXTEST_EXPERIMENTAL_LIBTEST_JSON: 1
138+
strategy:
139+
matrix:
140+
feature-flags: ["", "--no-default-features", "--all-features"]
141+
steps:
142+
- uses: actions/checkout@v4
143+
- uses: dtolnay/rust-toolchain@master
144+
with:
145+
toolchain: ${{ env.RUST_TOOLCHAIN }}
146+
- uses: Swatinem/rust-cache@v2
147+
# Using nextest because it's faster than built-in test
148+
- uses: taiki-e/install-action@nextest
149+
- name: Run cargo nextest
150+
run: |
151+
cargo nextest run --package ${{ inputs.package || '"*"' }} --message-format libtest-json-plus ${{ matrix.feature-flags }} > testresults${{ matrix.feature-flags }}.json
152+
- name: Upload all-features test results artifact
153+
id: test_results
154+
if: matrix.feature-flags == '--all-features'
155+
uses: actions/upload-artifact@v4
156+
with:
157+
name: test-results
158+
path: testresults--all-features.json
159+
160+
doctest:
161+
# Run doctests separately, as nextest doesn't yet (https://github.com/nextest-rs/nextest/issues/16)
162+
outputs:
163+
test_results_url: ${{ steps.doctest_results.outputs.artifact-url }}
164+
runs-on: ubuntu-latest
165+
env:
166+
RUSTDOCFLAGS: -Dwarnings
167+
steps:
168+
- uses: actions/checkout@v4
169+
- uses: dtolnay/rust-toolchain@master
170+
with:
171+
toolchain: ${{ env.RUST_TOOLCHAIN }}
172+
- name: Run doc tests
173+
run: |
174+
RUSTC_BOOTSTRAP=1 cargo test --package ${{ inputs.package || '"*"' }} --doc --all-features -- -Z unstable-options --format json --report-time > doctestresults--all-features.json
175+
- name: Upload doctest results artifact
176+
id: doctest_results
177+
uses: actions/upload-artifact@v4
178+
with:
179+
name: doctest-results
180+
path: doctestresults--all-features.json

.github/workflows/coverage.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# ********************************************************************************
2+
# Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************/
13+
14+
# Run all test for all features to collect test code coverage information
15+
# Upload coverage info for potential re-use in publication workflow, returns the corresponding download URL as an output on workflow_call
16+
# Can publish coverage info to CodeCov platform, this is controlled by setting CODECOV_TOKEN secret in the github workspace
17+
18+
name: Test coverage
19+
20+
on:
21+
workflow_call:
22+
inputs:
23+
package:
24+
description: "Which rust package to check"
25+
required: false
26+
default: '"*"' # for some reason, this default is ignored, so we have to repeat the pattern below
27+
type: string
28+
outputs:
29+
test_coverage_url:
30+
description: 'URL of the test coverage artifact'
31+
value: ${{ jobs.coverage.outputs.test_coverage_url }}
32+
workflow_dispatch:
33+
34+
env:
35+
RUST_TOOLCHAIN: ${{ vars.RUST_TOOLCHAIN || 'stable' }}
36+
RUSTFLAGS: -Dwarnings
37+
CARGO_TERM_COLOR: always
38+
39+
jobs:
40+
coverage:
41+
name: collect
42+
runs-on: ubuntu-latest
43+
outputs:
44+
test_coverage_url: ${{ steps.test_coverage_html.outputs.artifact-url }}
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: dtolnay/rust-toolchain@master
48+
with:
49+
toolchain: ${{ env.RUST_TOOLCHAIN }}
50+
- name: Install cargo-tarpaulin
51+
uses: taiki-e/install-action@cargo-tarpaulin
52+
- uses: Swatinem/rust-cache@v2
53+
54+
- name: Run tests and report code coverage
55+
run: |
56+
# enable nightly features so that we can also include Doctests
57+
RUSTC_BOOTSTRAP=1 cargo tarpaulin --package ${{ inputs.package || '"*"' }} -o xml -o lcov -o html --doc --tests
58+
59+
- name: Upload coverage report (lcov)
60+
uses: actions/upload-artifact@v4
61+
id: test_coverage_lcov
62+
with:
63+
name: code-coverage-lcov
64+
path: lcov.info
65+
- name: Upload coverage report (xml)
66+
uses: actions/upload-artifact@v4
67+
id: test_coverage_xml
68+
with:
69+
name: code-coverage-xml
70+
path: cobertura.xml
71+
- name: Upload coverage report (html)
72+
uses: actions/upload-artifact@v4
73+
id: test_coverage_html
74+
with:
75+
name: code-coverage-html
76+
path: tarpaulin-report.html
77+
78+
- name: Upload coverage reports to Codecov
79+
env:
80+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
81+
if: env.CODECOV_TOKEN != ''
82+
uses: codecov/[email protected]
83+
with:
84+
token: ${{ secrets.CODECOV_TOKEN }}
85+
slug: ${{ vars.GITHUB_REPOSITORY }}
86+
files: lcov.info

0 commit comments

Comments
 (0)