Skip to content

Commit 71ff4e2

Browse files
committed
worflow upgrade
1 parent 088e0de commit 71ff4e2

File tree

12 files changed

+337
-124
lines changed

12 files changed

+337
-124
lines changed

.github/workflows/benches.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
1-
name: Benches
1+
name: Rust benches
22

33
on:
4-
push:
5-
branches: [ main, develop ]
6-
4+
workflow_call:
5+
inputs:
6+
toolchain:
7+
description: 'rust toolchain'
8+
required: false
9+
default: 'stable'
10+
type: string
11+
# options:
12+
# - stable
13+
# - nightly
14+
# - beta
715

816
env:
917
CARGO_TERM_COLOR: always
1018

1119
jobs:
1220
bench:
13-
name: Run benches for Lattice QCD rs
21+
name: Run criterion benches
1422
runs-on: ubuntu-latest
15-
# env:
16-
# CRITERION_TOKEN: ${{ secrets.CRITERION_TOKEN }}
1723
steps:
1824
- name: Checkout
1925
uses: actions/checkout@v4
20-
- name: Install Rust stable toolchain
26+
27+
- name: Install Rust toolchain
2128
uses: actions-rs/toolchain@v1
2229
with:
23-
toolchain: stable
30+
toolchain: ${{ inputs.toolchain }}
31+
default: true
32+
2433
- name: Run benchmarks
25-
run: |
26-
# run benchmarks and save baseline in a directory called "new"
27-
cargo bench
34+
run: cargo bench --verbose
35+
2836
# - name: Upload benchmarks
37+
# env:
38+
# CRITERION_TOKEN: ${{ secrets.CRITERION_TOKEN }}
2939
# run: |
3040
# # upload the files
3141
# bash <(curl -s https://criterion.dev/bash)

.github/workflows/clippy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: clippy check
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
features_flag:
7+
description: 'feature flag used on the cargo command'
8+
required: false
9+
default: '--all-features'
10+
type: string
11+
toolchain:
12+
description: 'rust toolchain'
13+
required: false
14+
type: string
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
19+
jobs:
20+
linter:
21+
name: lint code with clippy on nightly
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Install Rust nightly toolchain
29+
uses: actions-rs/toolchain@v1
30+
with:
31+
toolchain: ${{ inputs.toolchain }}
32+
components: cargo, clippy
33+
default: true
34+
35+
- name: Linter
36+
run: cargo clippy --all --verbose --tests ${{ inputs.features_flag }} -- --no-deps --deny warnings
37+
38+
- name: Linter release
39+
run: cargo clippy --all --verbose --tests --release ${{ inputs.features_flag }} -- --no-deps --deny warnings

.github/workflows/coverage.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@ name: coverage
33
env:
44
CARGO_TERM_COLOR: always
55

6-
on:
7-
push:
6+
on:
7+
workflow_call:
8+
inputs:
9+
profile_file_name_prefix:
10+
description: 'prefix of the LLVM profile file'
11+
required: true
12+
default: 'profile'
13+
type: string
14+
features_flag:
15+
description: 'feature flag used on the cargo command'
16+
required: true
17+
default: '--all-features'
18+
type: string
819

920
jobs:
1021
coverage:
@@ -25,12 +36,13 @@ jobs:
2536
run: curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf -
2637

2738
- name: Generate code coverage
39+
env:
40+
RUSTFLAGS: -Cinstrument-coverage
41+
RUSTDOCFLAGS: -Cinstrument-coverage -Zunstable-options --persist-doctests target/debug/doctestbins
42+
LLVM_PROFILE_FILE: ${{ inputs.profile_file_name_prefix }}-%p-%m.profraw
2843
run: |
29-
export RUSTFLAGS="-Cinstrument-coverage"
30-
export RUSTDOCFLAGS="-Cinstrument-coverage -Zunstable-options --persist-doctests target/debug/doctestbins"
31-
export LLVM_PROFILE_FILE="lattice_qcd_rs-%p-%m.profraw"
32-
cargo +nightly test --verbose --all --no-default-features --features="serde-serialize"
33-
cargo +nightly test --verbose --all --no-default-features --features="serde-serialize" --examples
44+
cargo +nightly test --verbose --all ${{ inputs.features_flag }}
45+
cargo +nightly test --verbose --all ${{ inputs.features_flag }} --examples
3446
3547
- name: parse code coverage
3648
run: ./grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info

.github/workflows/fmt.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
name: fmt
1+
name: fmt check
22

33
on:
4-
push:
5-
pull_request:
6-
branches: [ main, develop ]
4+
workflow_call:
75

86
env:
97
CARGO_TERM_COLOR: always
108

119
jobs:
1210
fmt:
13-
11+
name: check the format of the code
1412
runs-on: ubuntu-latest
1513

1614
steps:
@@ -21,8 +19,8 @@ jobs:
2119
uses: actions-rs/toolchain@v1
2220
with:
2321
toolchain: nightly
24-
components: rustfmt
22+
components: rustfmt, cargo
2523
default: true
2624

27-
- name: fmt
28-
run: cargo +nightly fmt --all -- --check
25+
- name: rustfmt check
26+
run: cargo +nightly fmt --all --check

.github/workflows/rust.yml

Lines changed: 68 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,93 @@
1-
name: Rust
1+
name: Rust checks
22

33
on:
44
push:
5-
pull_request:
6-
branches: [ main, develop ]
5+
# pull_request:
6+
# branches: [ main, develop ]
77

88
env:
99
CARGO_TERM_COLOR: always
1010

1111
jobs:
12-
build:
13-
14-
runs-on: ${{ matrix.os }}
12+
format:
13+
name: check the format of the code
14+
uses: ./.github/workflows/fmt.yml
15+
16+
rustdoc-check:
17+
name: rustdoc check
18+
uses: ./.github/workflows/rust_doc_check.yml
19+
with:
20+
toolchain: stable
21+
22+
rust_test:
23+
name: rust test
24+
needs: [format]
1525
strategy:
1626
matrix:
1727
os: [ubuntu-latest, windows-latest]
1828
profile: [test, release]
1929
exclude:
2030
- os: windows-latest
2131
profile: release
22-
steps:
23-
- name: Checkout repository
24-
uses: actions/checkout@v4
32+
33+
uses: ./.github/workflows/rust_test.yml
34+
with:
35+
features_flag_1: --features="serde-serialize"
36+
features_flag_2: --no-default-features --features="overflow-test"
37+
toolchain: stable
38+
os: ${{ matrix.os }}
39+
profile: ${{ matrix.profile }}
40+
# steps:
41+
# - name: Checkout repository
42+
# uses: actions/checkout@v4
2543

26-
- name: Install Rust stable toolchain
27-
uses: actions-rs/toolchain@v1
28-
with:
29-
toolchain: stable
30-
default: true
44+
# - name: Install Rust stable toolchain
45+
# uses: actions-rs/toolchain@v1
46+
# with:
47+
# toolchain: stable
48+
# default: true
3149

32-
- name: Run tests with serd
33-
run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --features="serde-serialize"
50+
# - name: Run tests with serd
51+
# run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --features="serde-serialize"
3452

35-
- name: Run examples tests with serd
36-
run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --features="serde-serialize" --examples
53+
# - name: Run examples tests with serd
54+
# run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --features="serde-serialize" --examples
3755

3856
# it is faster to keep the going and reuse previous compilation artefact than using
3957
# a matrix strategy and starting all over again
40-
- name: Run tests no features
41-
run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --no-default-features --features="overflow-test"
58+
# - name: Run tests no features
59+
# run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --no-default-features --features="overflow-test"
4260

43-
- name: Run examples tests no features
44-
run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --no-default-features --features="overflow-test" --examples
61+
# - name: Run examples tests no features
62+
# run: cargo +stable test --profile ${{ matrix.profile }} --all --verbose --no-fail-fast --no-default-features --features="overflow-test" --examples
4563

4664
linter:
4765
name: lint code on nightly release
48-
runs-on: ubuntu-latest
49-
50-
steps:
51-
- name: Checkout repository
52-
uses: actions/checkout@v4
53-
54-
- name: Install Rust nightly toolchain
55-
uses: actions-rs/toolchain@v1
56-
with:
57-
toolchain: nightly
58-
components: clippy
59-
default: true
60-
61-
- name: Linter
62-
run: cargo +nightly clippy --all --verbose --tests --all-features -- --no-deps --deny warnings
63-
64-
- name: Linter release
65-
run: cargo +nightly clippy --all --verbose --tests --release --all-features -- --no-deps --deny warnings
66+
needs: [format, rustdoc-check]
67+
uses: ./.github/workflows/clippy.yml
68+
with:
69+
features_flag: --all-features
70+
toolchain: nightly
71+
72+
coverage:
73+
name: coverage
74+
uses: ./.github/workflows/coverage.yml
75+
with:
76+
profile_file_name_prefix: lattice-qcd-rs
77+
features_flag: --no-default-features --features="serde-serialize"
78+
79+
benches:
80+
name: benches
81+
needs: [format, coverage, rust_test]
82+
if: ${{ github.ref_name == 'main' || github.ref_name == 'develop' }}
83+
uses: ./.github/workflows/benches.yml
84+
with:
85+
toolchain: stable
86+
87+
doc_publish:
88+
name: publish rust doc
89+
needs: [format, coverage, rust_test, rustdoc-check, linter]
90+
if: ${{ github.ref_name == 'main' }}
91+
uses: ./.github/workflows/rust_doc_publish.yml
92+
with:
93+
toolchain: stable

.github/workflows/rust_beta.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1-
name: Rust Doc check
1+
name: Rust doc check
22

33
on:
4-
push:
5-
pull_request:
6-
branches: [ main, develop ]
7-
4+
workflow_call:
5+
inputs:
6+
toolchain:
7+
description: 'rust toolchain'
8+
required: false
9+
type: string
10+
# options:
11+
# - stable
12+
# - nightly
13+
# - beta
14+
check_private_items:
15+
description: 'wether to check documentation for private item'
16+
required: false
17+
default: true
18+
type: boolean
19+
820
env:
921
CARGO_TERM_COLOR: always
1022

1123
jobs:
1224
rustdoc-check:
13-
25+
name: Rust Doc check
1426
runs-on: ubuntu-latest
1527

1628
steps:
@@ -20,8 +32,14 @@ jobs:
2032
- name: Install Rust stable toolchain
2133
uses: actions-rs/toolchain@v1
2234
with:
23-
toolchain: stable
35+
toolchain: ${{ inputs.toolchain }}
36+
components: rust-docs, cargo
2437
default: true
2538

26-
- name: Doc
27-
run: cargo +stable doc --all --no-deps --document-private-items --all-features
39+
- name: Doc check
40+
if: ${{ inputs.check_private_items }}
41+
run: cargo doc --verbose --all --no-deps --document-private-items --all-features
42+
43+
- name: Doc check
44+
if: ${{ !inputs.check_private_items }}
45+
run: cargo doc --verbose --all --no-deps --all-features

0 commit comments

Comments
 (0)