-
-
Notifications
You must be signed in to change notification settings - Fork 2
248 lines (224 loc) · 8.35 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
name: CI
on:
push:
branches-ignore:
- main
tags-ignore:
- '**'
paths:
- '.github/workflows/ci.yml'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/*.rs'
- '**/*.sh'
- '**/*.exp'
pull_request:
paths:
- '.github/workflows/ci.yml'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/*.rs'
- '**/*.sh'
- '**/*.exp'
workflow_dispatch:
concurrency:
group: ${{ github.head_ref || github.ref_name }}
defaults:
run:
shell: bash
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
shared-key: jira_cli-check
cache-on-failure: true
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
components: rustfmt
- name: Update Rustup (temporary workaround)
run: |
rustup self update
rustup update --no-self-update
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall -y --force cargo-quickinstall
- name: Deny check
run: |
cargo binstall -y --force cargo-deny
cargo deny --format json check bans licenses sources advisories > $HOME/deny.json || exit 0
- name: Audit check
run: |
cargo binstall -y --force cargo-audit
cargo audit --json > $HOME/audit.json || exit 0
- name: Check a local package and all of its dependencies for errors
uses: clechasseur/rs-cargo@v2
with:
command: check
args: --all
- name: Lint check
uses: clechasseur/rs-cargo@v2
with:
command: fmt
args: --all --check
- name: Outdated check
run: |
cargo binstall -y --force cargo-outdated
cargo outdated --depth 1 --format json > $HOME/outdated.json
- name: Udeps check
run: |
cargo binstall -y --force cargo-udeps
cargo +nightly udeps --quiet --workspace --all-features --all-targets --output json > $HOME/udeps.json || exit 0
- name: Clippy check
run: |
rustup component add clippy
cargo clippy --all-features --all-targets --message-format=json -- -Dclippy::all -Dclippy::nursery -Dclippy::pedantic > $HOME/clippy.json || exit 0
- name: Sonar converter
run: |
cargo binstall -y --force cargo-sonar
cargo sonar --audit --audit-path $HOME/audit.json --clippy --clippy-path $HOME/clippy.json --deny --deny-path $HOME/deny.json --outdated --outdated-path $HOME/outdated.json --udeps --udeps-path $HOME/udeps.json --sonar-path $HOME/sonar.json
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup sonarqube
uses: warchant/setup-sonar-scanner@v7
- name: Run sonarqube
run: sonar-scanner -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} -Dsonar.sources=$GITHUB_WORKSPACE -Dsonar.host.url=${{ secrets.SONAR_URL }} -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dsonar.externalIssuesReportPaths=$HOME/sonar.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ubuntu-latest
needs:
- check
steps:
- uses: Swatinem/rust-cache@v2
with:
shared-key: jira_cli-x86_64-unknown-linux-gnu
cache-on-failure: true
- uses: actions/checkout@v4
- name: Update Rustup and define default toolchain
run: rustup update --no-self-update stable && rustup default stable
- name: Add target
run: rustup target add x86_64-unknown-linux-gnu
- name: Install dependencies for Linux
run: sudo apt update -y && sudo apt install --no-install-recommends expect gcc-multilib libjemalloc-dev libsecret-1-0 libsecret-1-dev mold -y
- name: Setup mold linker
run: echo -e '[target.x86_64-unknown-linux-gnu]\nlinker = "/usr/bin/clang"\nrustflags = ["-C", "link-arg=--ld-path=/usr/bin/mold"]' > ~/.cargo/config.toml
- name: Install rustfmt
run: rustup component add rustfmt || echo "rustfmt not available"
- name: Build
run: cargo build
- name: Run tests.sh
run: ./tests.sh
env:
GIT_ACTION_RUN_NUMBER: ${{ github.run_number }}
JIRA_DOMAIN: ${{ secrets.JIRA_DOMAIN }}
JIRA_USER: ${{ secrets.JIRA_USER }}
JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }}
JIRA_USER_ACCOUNT_ID: ${{ secrets.JIRA_USER_ACCOUNT_ID }}
native:
runs-on: ${{ matrix.os }}
needs:
- check
- test
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
- os: macos-latest
rust: stable
target: x86_64-apple-darwin
steps:
- uses: Swatinem/rust-cache@v2
with:
shared-key: jira_cli-${{ matrix.target }}
cache-on-failure: true
- uses: actions/checkout@v4
- name: Update Rustup and define default toolchain
run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Install dependencies for Linux
run: sudo apt update -y && sudo apt install --no-install-recommends expect gcc-multilib libjemalloc-dev libsecret-1-0 libsecret-1-dev mold -y
if: matrix.os == 'ubuntu-latest'
- name: Setup mold linker
run: echo -e '[target.x86_64-unknown-linux-gnu]\nlinker = "/usr/bin/clang"\nrustflags = ["-C", "link-arg=--ld-path=/usr/bin/mold"]' > ~/.cargo/config.toml
- name: Install rustfmt
run: rustup component add rustfmt || echo "rustfmt not available"
- name: Build
run: cargo build
env:
GIT_ACTION_RUN_NUMBER: ${{ github.run_number }}
JIRA_DOMAIN: ${{ secrets.JIRA_DOMAIN }}
JIRA_USER: ${{ secrets.JIRA_USER }}
JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }}
JIRA_USER_ACCOUNT_ID: ${{ secrets.JIRA_USER_ACCOUNT_ID }}
if: matrix.os == 'ubuntu-latest'
cross:
runs-on: ${{ matrix.os }}
needs:
- check
- test
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-gnu
- os: macos-latest
rust: stable
target: aarch64-apple-darwin
steps:
- uses: Swatinem/rust-cache@v2
with:
shared-key: jira_cli-${{ matrix.target }}
cache-on-failure: true
- uses: actions/checkout@v4
- name: Update Rustup and define default toolchain
run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Install dependencies for Linux
run: sudo apt update -y && sudo apt install --no-install-recommends expect g++-aarch64-linux-gnu gcc-aarch64-linux-gnu libjemalloc-dev libsecret-1-0 libsecret-1-dev -y
if: matrix.os == 'ubuntu-latest'
- name: Install rustfmt
run: rustup component add rustfmt || echo "rustfmt not available"
- name: Build for all architecture except Mac ARM
run: cargo build --target ${{ matrix.target }}
if: matrix.target != 'aarch64-apple-darwin'
- name: Build for Mac ARM
run: |
SDKROOT=$(xcrun -sdk macosx --show-sdk-path)
MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)
cargo build --target=aarch64-apple-darwin
if: matrix.target == 'aarch64-apple-darwin'
approve-pr:
name: Approve PR
if: ${{ github.event_name == 'pull_request' }}
needs:
- check
- test
- native
- cross
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action@v2
with:
github-token: ${{ secrets.PAT }}