-
-
Notifications
You must be signed in to change notification settings - Fork 22
195 lines (187 loc) · 6.26 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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
- '**'
jobs:
shellcheck:
name: Run shellcheck
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: shellcheck
uses: reviewdog/action-shellcheck@v1.21
test:
name: Test verify-changed-files
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest, macos-11, windows-2022]
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Test files has no changes
uses: ./
id: changed_files_not_expected
with:
files: |
test/*.txt
test/*.sql
test/**/*.txt
test/**/*.sql
- name: Display changed files
if: steps.changed_files_not_expected.outputs.files_changed == 'true'
run: |
echo "Changed files (Not expected): ${{ steps.changed_files_not_expected.outputs.changed_files }}"
exit 1
- name: Test dont fail if not changed
uses: ./
id: changed_files_not_expected_fail
with:
fail-if-changed: true
files: |
test/*.txt
test/*.sql
test/**/*.txt
test/**/*.sql
- name: Test fail if changed
uses: ./
id: unchanged_files_expected_fail
continue-on-error: true
with:
fail-if-unchanged: true
files: |
test/*.txt
test/*.sql
test/**/*.txt
test/**/*.sql
- name: Make changes
run: |
printf '%s\n' "323442" "424" >> test/new.txt
printf '%s\n' "323442" "424" >> test/new1.txt
printf '%s\n' "323442" "424" >> test/new2.txt
printf '%s\n' "323442" "424" >> "test/\$(whoami).txt"
printf '%s\n' "323442" "424" >> test/啊啊啊.txt
shell: bash
- name: Test test/new*.txt file has changes
uses: ./
id: changed_files_expected
with:
separator: '\n'
path: test
quotepath: false
files: |
*.{txt,sql}
**/*.{txt,sql}
- name: Display changed files
if: steps.changed_files_expected.outputs.files_changed == 'true'
run: |
echo "Changed files: ${{ steps.changed_files_expected.outputs.changed_files }}"
- name: Verify Changes to test/**.txt
if: |
(
steps.changed_files_expected.outputs.files_changed != 'true' ||
!contains(steps.changed_files_expected.outputs.changed_files, 'test/new.txt') ||
!contains(steps.changed_files_expected.outputs.changed_files, 'test/new1.txt') ||
!contains(steps.changed_files_expected.outputs.changed_files, 'test/new2.txt') ||
!contains(steps.changed_files_expected.outputs.changed_files, 'test/$\(whoami\).txt') ||
!contains(steps.changed_files_expected.outputs.changed_files, 'test/啊啊啊.txt')
)
run: |
echo "No Changes found or missing changed files: (Not expected)"
exit 1
- name: Test fail if changed
uses: ./
id: changed_files_expected_fail
continue-on-error: true
with:
fail-if-changed: true
files: |
test/*.txt
test/*.sql
test/**/*.txt
test/**/*.sql
- name: Test dont fail if changed and fail-if-unchanged is true
uses: ./
id: unchanged_files_not_expected_fail
with:
fail-if-unchanged: true
files: |
test/*.txt
test/*.sql
test/**/*.txt
test/**/*.sql
- name: Generate an unstaged file
run: |
echo "New changes" > unstaged.txt
- name: Test unstaged file has changes
uses: ./
id: changed_unstaged_files_expected
with:
files: |
unstaged.txt
- name: Display unstaged changed files
if: steps.changed_unstaged_files_expected.outputs.files_changed == 'true'
run: |
echo "Changed files: ${{ steps.changed_unstaged_files_expected.outputs.changed_files }}"
- name: Verify Changes to unstaged.txt
if: steps.changed_unstaged_files_expected.outputs.files_changed != 'true'
run: |
echo "No Changes found: (Not expected)"
exit 1
- name: Test unstaged file changes are ignored
uses: ./
id: changed_unstaged_files_not_expected
with:
files: |
!test/new.txt
!test/new1.txt
!test/new2.txt
!test/$(whoami).txt
!unstaged.txt
- name: Verify Changes to unstaged.txt are ignored
if: steps.changed_unstaged_files_not_expected.outputs.files_changed != 'false'
run: |
echo "Changes found: (Not expected)"
exit 1
- name: Test unstaged file has changes
uses: ./
id: changed_unstaged2_files_expected
with:
files: |
!test/new.txt
!test/new1.txt
!test/new2.txt
!test/$(whoami).txt
unstaged.txt
- name: Verify Changes to unstaged.txt are ignored
if: steps.changed_unstaged2_files_expected.outputs.files_changed != 'true'
run: |
echo "No Changes found: (Not expected)"
exit 1
- name: Delete test/new.txt without staging
run: |
rm test/new.txt
- name: Test deletion of test/new.txt
uses: ./
with:
path: test
id: deleted_file_test
- name: Show output
run: |
echo "Changed files: ${{ steps.deleted_file_test.outputs.changed_files }}"
- name: Display deleted file test result
if: "contains(steps.deleted_file_test.outputs.changed_files, 'new.txt')"
run: |
echo "Deletion detected: ${{ steps.deleted_file_test.outputs.changed_files }}"
- name: Verify Deletion of test/new.txt
if: "!contains(steps.deleted_file_test.outputs.changed_files, 'new.txt')"
run: |
echo "No Deletion detected: (Not expected)"
exit 1