-
-
Notifications
You must be signed in to change notification settings - Fork 1
183 lines (164 loc) · 5.1 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
name: oxlint ecosystem ci
on:
schedule:
- cron: "0 */3 * * *" # Every 3 hours.
pull_request:
types: [opened, synchronize]
paths-ignore:
- '**/*.md'
push:
branches:
- main
paths-ignore:
- '**/*.md'
workflow_dispatch:
inputs: # for create comment action https://github.com/peter-evans/create-or-update-comment?tab=readme-ov-file#action-inputs
issue-number:
required: false
type: string
comment-id:
required: false
type: string
ref:
required: false
type: string
default: 'main'
jobs:
reply:
name: Reply
if: ${{ inputs.issue-number && inputs.comment-id }}
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.OXC_BOT_PAT }}
repository: oxc-project/oxc
issue-number: ${{ inputs.issue-number }}
comment-id: ${{ inputs.comment-id }}
reactions: eyes
build:
name: Build
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: oxc-project/oxc
ref: ${{ inputs.ref }}
- uses: Boshen/setup-rust@main
with:
save-cache: ${{ github.ref_name == 'main' }}
- run: cargo oxlint
env:
RUSTFLAGS: "-C debug-assertions=true"
- uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: oxlint
path: ./target/release/oxlint
checkout:
name: Read matrix.json
needs: build
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setmatrix.outputs.content }}
steps:
- uses: taiki-e/checkout-action@v1
- id: setmatrix
uses: jaywcjlove/github-action-read-file@main
with:
localfile: ./matrix.json
test:
needs: checkout
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.checkout.outputs.matrix) }}
name: Test ${{ matrix.repository }}
steps:
- name: Clone ${{ matrix.repository }}
uses: actions/checkout@v4
with:
repository: ${{ matrix.repository }}
ref: ${{ matrix.ref }}
path: ${{ matrix.path }}
- uses: actions/download-artifact@v4
with:
name: oxlint
path: ${{ matrix.path }}
- run: chmod +x ./oxlint
working-directory: ${{ matrix.path }}
- name: Run
working-directory: ${{ matrix.path }}
run: ${{ matrix.command }}
- name: Check Panic
working-directory: ${{ matrix.path }}
run: |
set +e # disable exit on run
./oxlint --fix --jest-plugin --jsdoc-plugin --jsx-a11y-plugin --nextjs-plugin --react-perf-plugin -D all --silent
EXIT_CODE=$?
# Panic returns exit code > 1, e.g. 101 when a Rust program panics
if [ $EXIT_CODE -gt 1 ]; then
echo "exitcode=$EXIT_CODE" >> $GITHUB_OUTPUT
exit $EXIT_CODE
fi
echo "exitcode=0" >> $GITHUB_OUTPUT
exit 0
comment:
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
name: Reply Comment
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/github-script@v7
id: script
if: ${{ inputs.issue-number }}
with:
github-token: ${{ secrets.OXC_BOT_PAT }}
result-encoding: string
script: |
const {
data: { jobs },
} = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
per_page: 100,
});
let result = jobs
.filter((job) => job.name.startsWith("Test "))
.map((job) => {
const suite = job.name.slice(5);
return { suite, conclusion: job.conclusion, link: job.html_url };
});
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const urlLink = `[Open](${url})`;
const conclusionEmoji = {
success: ":white_check_mark:",
failure: ":x:",
cancelled: ":stop_button:",
};
const body = `
## [Oxlint Ecosystem CI](${urlLink})
| suite | result |
|-------|--------|
${result.map((r) => `| [${r.suite}](${r.link}) | ${conclusionEmoji[r.conclusion]} |`).join("\n")}
`;
return body;
- uses: peter-evans/create-or-update-comment@v4
if: ${{ inputs.issue-number && inputs.comment-id }}
with:
token: ${{ secrets.OXC_BOT_PAT }}
repository: oxc-project/oxc
issue-number: ${{ inputs.issue-number }}
comment-id: ${{ inputs.comment-id }}
body: ${{ steps.script.outputs.result }}
edit-mode: replace