-
-
Notifications
You must be signed in to change notification settings - Fork 22
245 lines (210 loc) · 6.96 KB
/
test.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
name: build
on:
pull_request_review:
branches:
- main
pull_request:
branches:
- main
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
outputs:
files_changed: ${{ steps.changed_files.outputs.files_changed }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
persist-credentials: false
fetch-depth: 0
- name: Use Node.js 20.x
uses: actions/[email protected]
with:
cache: 'yarn'
node-version: '20.x'
- name: Create coverage directory and clover.xml
run: |
mkdir -p coverage
touch coverage/clover.xml
- name: Install dependencies
run: |
yarn install
- name: Run ESLint on changed files
uses: tj-actions/eslint-changed-files@v25
with:
token: ${{ secrets.PAT_TOKEN }}
ignore_patterns: |
dist/**
lib/**
node_modules/**
jest.config.js
coverage/**
- name: Run build and test
run: |
yarn all
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v20
id: changed_files
with:
files: |
src
dist
- name: Commit files
if: steps.changed_files.outputs.files_changed == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add src dist
git commit -m "Added missing changes and modified dist assets."
- name: Push changes
if: steps.changed_files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT_TOKEN }}
branch: ${{ github.head_ref }}
- name: Upload build assets
uses: actions/upload-artifact@v4
with:
name: build-assets
path: dist
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
continue-on-error: true
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage/lcov.info
test:
needs: build
if: needs.build.outputs.files_changed != 'true'
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run glob for all files
id: glob-all-files
uses: ./
with:
files: "**"
include-deleted-files: "true"
base-sha: "99561ef"
sha: "2eb2427"
- name: Show output
run: |
echo "${{ steps.glob-all-files.outputs.paths }}"
cat "${{ steps.glob-all-files.outputs.paths-output-file }}"
- name: Run glob for yml files
id: glob-yml-files
uses: ./
with:
files: |
**.yml
!.github/**/rebase.yml
- name: Show output
run: |
echo "${{ steps.glob-yml-files.outputs.paths }}"
cat "${{ steps.glob-yml-files.outputs.paths-output-file }}"
- name: Run glob for all yml files
id: glob-all-yml-files
uses: ./
with:
files: |
**/*.yml
excluded-files: |
.github/workflow/rebase.yml
- name: Show output
run: |
echo "${{ steps.glob-all-yml-files.outputs.paths }}"
cat "${{ steps.glob-all-yml-files.outputs.paths-output-file }}"
- name: Run glob for test.yml and md files
uses: ./
id: glob-test-yml-md
with:
files: |
.github/workflows/test.yml
*.md
- name: Show output
run: |
echo "${{ steps.glob-test-yml-md.outputs.paths }}"
cat "${{ steps.glob-test-yml-md.outputs.paths-output-file }}"
- name: Run glob for source-files.txt escape paths
uses: ./
id: glob-source-files-safe-output
with:
files-from-source-file: |
src/__tests__/source-files.txt
src/__tests__/source-files.txt
safe-output: true
- name: Show output
run: |
echo "${{ steps.glob-source-files-safe-output.outputs.paths }}"
cat "${{ steps.glob-source-files-safe-output.outputs.paths-output-file }}"
- name: Run glob for source-files.txt
uses: ./
id: glob-source-files
with:
files-from-source-file: |
src/__tests__/source-files.txt
src/__tests__/source-files.txt
- name: Show output
run: |
echo "${{ steps.glob-source-files.outputs.paths }}"
cat "${{ steps.glob-source-files.outputs.paths-output-file }}"
- name: Run glob excluding files in source-files.txt
uses: ./
id: glob-excluded-source-files
with:
excluded-files-from-source-file: |
src/__tests__/source-files.txt
src/__tests__/source-files.txt
- name: Show output
run: |
echo "${{ steps.glob-excluded-source-files.outputs.paths }}"
cat "${{ steps.glob-excluded-source-files.outputs.paths-output-file }}"
- name: Run glob for test.yml and md files and custom separator
uses: ./
id: glob-test-yml-md-separator
with:
files: ".github/workflows/test.yml *.md"
files-separator: " "
- name: Show output
run: |
echo "${{ steps.glob-test-yml-md-separator.outputs.paths }}"
cat "${{ steps.glob-test-yml-md-separator.outputs.paths-output-file }}"
- name: Run glob for all .yml files and excluding test.yml and custom separator
uses: ./
id: glob-excluded-test-yml-separator
with:
files: "**.yml **/*.yml"
files-separator: " "
excluded-files: ".github/workflows/test.yml"
- name: Show output
run: |
echo "${{ steps.glob-excluded-test-yml-separator.outputs.paths }}"
cat "${{ steps.glob-excluded-test-yml-separator.outputs.paths-output-file }}"
- name: Run glob with invalid patterns
uses: ./
id: glob-invalid
continue-on-error: true
with:
files: |
- *.md
- name: Show output
run: |
echo "${{ steps.glob-invalid.outputs.paths }}"
echo "${{ steps.glob-invalid.outputs.paths-output-file }}"
- name: Verify that the paths-output-file is created
if: steps.glob-invalid.outputs.paths-output-file == ''
run: |
echo "Expected: paths-output-file to not be empty got ${{ steps.glob-invalid.outputs.paths-output-file }}"
exit 1