-
Notifications
You must be signed in to change notification settings - Fork 12
129 lines (120 loc) · 3.53 KB
/
ci-rust.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:
pull_request:
types:
- opened
- synchronize
- reopened
push:
branches:
- main
tags:
- "[0-9]+.[0-9]+.[0-9]+"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run the unit/doc tests
run: cargo test
- name: Test examples
run: |
EXAMPLES="simple
with-report
with-style
with-resume
"
for example in $EXAMPLES; do
echo "==== Testing $example ======================================="
cargo run -q --example "$example"
echo "============================================================="
done
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check
- run: cargo check
- run: cargo clippy -- -D warnings
- name: Lint markdown
run: just lint-md
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo build
# Disabling this for now since it does not really add a lot of value but does
# add a lot of CI time.
# attest:
# needs:
# - build
# - lint
# - test
# runs-on: ubuntu-latest
# if: startsWith(github.ref, 'refs/tags/')
# steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain
# with:
# profile: minimal
# toolchain: stable
# override: true
# - uses: Swatinem/rust-cache@v2
# # Generate attestation.
# - uses: actions-rs/cargo@v1
# with:
# command: package
# - run: |
# mkdir -p dist
# cp target/package/*.crate dist/
# - name: Generate provenance
# uses: slsa-framework/github-actions-demo@v0.1
# with:
# artifact_path: dist/
# output_path: trauma.${{ github.sha }}.att
# # Sign the attestation.
# - uses: sigstore/cosign-installer@main
# - run: |
# export COSIGN_PASSWORD="${{ secrets.COSIGN_PASSWORD }}"
# echo -n "${{ secrets.COSIGN_KEY }}" > /tmp/cosign.key
# cosign sign-blob --key /tmp/cosign.key trauma.${{ github.sha }}.att > trauma.${{ github.sha }}.sig
# # Upload attestation files.
# - name: Upload provenance
# uses: actions/upload-artifact@v3
# with:
# path: |
# trauma.${{ github.sha }}.att
# trauma.${{ github.sha }}.sig
release:
needs:
- build
- lint
- test
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/download-artifact@v4
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
- name: Publish the release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ steps.changelog_reader.outputs.changes }}
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}