-
Notifications
You must be signed in to change notification settings - Fork 4
129 lines (108 loc) · 3.56 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: CI
on:
push:
branches: [ main ]
pull_request:
jobs:
commits-lint:
name: Conventional commits
runs-on: ubuntu-latest
env:
COMMITLINT_CONFIG: commitlint.config.js
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Only the latest commit only by default
- name: Get commit range
run: |
echo "COMMIT_RANGE_FROM=${{ github.sha }}^" >> $GITHUB_ENV
echo "COMMIT_RANGE_TO=${{ github.sha }}" >> $GITHUB_ENV
- name: Update commit range
if: github.event_name == 'pull_request'
run: |
echo "COMMIT_RANGE_FROM=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
echo "COMMIT_RANGE_TO=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- name: Update commit range
if: github.event_name == 'push' && !github.event.forced
run: |
echo "COMMIT_RANGE_FROM=${{ github.event.before }}" >> $GITHUB_ENV
- name: Lint conventional commits
run: |
npm install -g @commitlint/cli @commitlint/config-conventional
echo "Linting range ${{ env.COMMIT_RANGE_FROM }}..${{ env.COMMIT_RANGE_TO }}"
commitlint --config ${{ env.COMMITLINT_CONFIG }} --from ${{ env.COMMIT_RANGE_FROM }} --to ${{ env.COMMIT_RANGE_TO }}
rust-format:
name: Rust format
runs-on: ubuntu-latest
container: rust:latest
steps:
- uses: actions/checkout@v3
- name: Check Rust code formatting
run: |
rustup component add rustfmt
cargo fmt --all -- --check
rust-lint:
name: Rust lint
runs-on: ubuntu-latest
container: rust:latest
steps:
- uses: actions/checkout@v3
- name: Install GSL
run: apt-get update && apt-get install -y clang libgsl-dev
- name: Lint Rust code
run: |
rustup component add clippy
cargo clippy -- -D warnings
cargo clippy --tests -- -D warnings
rust-test:
name: Rust test
runs-on: ubuntu-latest
container: ${{ matrix.container }}
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
needs: [rust-format, rust-lint]
strategy:
matrix:
rust-toolchain:
- stable
- nightly
profile:
- dev
- release
include:
- rust-toolchain: stable
container: rust:latest
- rust-toolchain: nightly
container: rustlang/rust:nightly
steps:
- uses: actions/checkout@v3
- name: Install GSL
run: apt-get update && apt-get install -y clang libgsl-dev
- name: Log environment details
run: |
rustc --version
cargo --version
- name: Compile
run: cargo build --profile ${{ matrix.profile }} --verbose
- name: Run tests
run: cargo test --profile ${{ matrix.profile }}
- name: Compile (gsl-wrapper)
working-directory: gsl-wrapper
run: cargo build --profile ${{ matrix.profile }} --verbose
- name: Run tests (gsl-wrapper)
working-directory: gsl-wrapper
run: cargo test --profile ${{ matrix.profile }}
- name: Run checks (benches)
working-directory: gomez-bench
run: cargo check --profile ${{ matrix.profile }}
rust-check-docs:
name: Rust docs check
runs-on: ubuntu-latest
container: rust:latest
needs: [rust-format, rust-lint]
env:
RUSTDOCFLAGS: -D warnings
steps:
- uses: actions/checkout@v3
- name: Check Rust docs
run: cargo doc --no-deps --document-private-items --workspace