-
Notifications
You must be signed in to change notification settings - Fork 29
109 lines (94 loc) · 3 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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- '**'
jobs:
cargo:
name: Cargo test, clippy and doc
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: x86_64-pc-windows-gnu
permissions:
contents: write
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy, rustfmt
target: ${{ matrix.target }}
- name: Setup cache
uses: Swatinem/rust-cache@v2
- name: Cargo test
run: cargo test --target ${{ matrix.target }}
- name: Cargo fmt
if: ${{ matrix.os == 'ubuntu-latest' }}
run: cargo fmt -- --check
- name: typos check
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cargo install typos-cli
typos
- name: Cargo clippy
if: ${{ matrix.os == 'ubuntu-latest' }}
run: cargo clippy --all-targets --all-features --message-format=json > clippy_result.json
continue-on-error: true
- name: Install clippy-sarif sarif-fmt (require cargo)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cargo install clippy-sarif sarif-fmt
cat clippy_result.json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
- name: Upload analysis results to GitHub
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: rust-clippy-results.sarif
wait-for-processing: true
- name: Cargo doc
if: ${{ github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest'}}
run: |
cargo doc --no-deps --document-private-items
echo "<meta http-equiv='refresh' content='0; url=freedit'>" > target/doc/index.html
rm target/doc/.lock
- name: Upload artifact
if: ${{ github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest'}}
uses: actions/upload-pages-artifact@v3
with:
path: 'target/doc'
Deploy:
needs: cargo
name: Deploy to GitHub Pages
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: 'github-pages'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4