-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (135 loc) · 3.8 KB
/
workflow.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# NOTE: Built by following starship/starship as template - Thank you!
name: Main Workflow
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
jobs:
# Run the `rustfmt` code formatter
rustfmt:
name: Rustfmt [Formatter]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
# Run the `clippy` linting tool
clippy:
name: Clippy [Linter]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
override: true
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -D clippy::all
# Run a security audit on dependencies
cargo_audit:
name: Cargo Audit [Security]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- run: cargo install --force cargo-audit
- run: cargo generate-lockfile
- uses: actions-rs/cargo@v1
with:
command: audit
# Ensure that the project could be successfully compiled
cargo_check:
name: Compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check
args: --all
# Run tests on Linux and macOS
# NOTE: not supporting Windows as of of yet
# On both Rust stable and Rust nightly
test:
name: Test Suite
needs: [cargo_check]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
rust: [nightly]
steps:
# Checkout the branch being tested
- uses: actions/checkout@v1
# Install all the required dependencies for testing
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: Run all tests
env:
RUST_BACKTRACE: "full"
uses: actions-rs/cargo@v1
with:
command: test
args: -- -Z unstable-options --include-ignored --test-threads=1
# Run the tests in the Docker image
docker_test:
name: Test in Docker
needs: [cargo_check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Pull the pre-built Docker image
run: docker pull jakeschurch/badm-test
- name: Fix file permissions
run: chmod -R a+w .
- name: Build the Docker image
run:
docker build -f tests/Dockerfile --tag jakeschurch/badm-test --cache-from
jakeschurch/badm-test .
- name: Run tests in Docker
run: docker run --rm -v $(pwd):/src/badm jakeschurch/badm-test
# Publish crate to Crates.io
cargo_publish:
if: startsWith(github.ref, 'refs/tags/v')
name: Publish Cargo Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- run: cargo doc --all --document-private-items --workspace
- run: cargo login $CRATES_IO_TOKEN
- run: cargo publish
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}