-
-
Notifications
You must be signed in to change notification settings - Fork 192
2219 lines (2079 loc) · 89.6 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: CI
permissions:
contents: read
on:
push:
branches:
- "**"
pull_request:
types:
- assigned
- unassigned
- labeled
- unlabeled
- opened
- edited
- closed
- reopened
- synchronize
- converted_to_draft
- ready_for_review
- locked
- unlocked
- review_requested
- review_request_removed
- auto_merge_enabled
- auto_merge_disabled
branches:
- "**"
jobs:
build:
runs-on: ubuntu-latest
outputs:
files_changed: ${{ steps.changed_files.outputs.files_changed }}
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
- 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
if: github.event_name == 'pull_request'
with:
token: ${{ secrets.PAT_TOKEN }}
config_path: ".eslintrc.json"
- name: Run build and test
run: |
yarn all
env:
GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FORK: ${{ github.event.pull_request.head.repo.fork }}
- 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' && github.event_name == 'pull_request'
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' && github.event_name == 'pull_request'
continue-on-error: 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-multiple-repositories:
name: Test with multiple repositories
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.files_changed != 'true'
permissions:
contents: read
steps:
- name: Checkout into dir1
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: true
fetch-depth: 0
path: dir1
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
path: dir1/dist
- name: Run changed-files with defaults on the dir1
id: changed-files-dir1
uses: ./dir1
with:
path: dir1
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-dir1.outputs) }}'
shell:
bash
- name: List all modified files
run: |
for file in ${{ steps.changed-files-dir1.outputs.modified_files }}; do
echo "$file"
done
shell:
bash
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
path: dir2/dist
- name: Checkout into dir2
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: true
fetch-depth: 0
path: dir2
- name: Run changed-files with defaults on the dir2
id: changed-files-dir2
uses: ./dir2
with:
path: dir2
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-dir2.outputs) }}'
shell:
bash
- name: List all modified files
run: |
for file in ${{ steps.changed-files-dir2.outputs.modified_files }}; do
echo "$file"
done
shell:
bash
test-using-since-and-until:
name: Test changed-files using since and until
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && needs.build.outputs.files_changed != 'true'
permissions:
contents: read
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files since 2022-08-19
id: changed-files-since
uses: ./
with:
since: "2022-08-19"
- name: Check output
if: "!contains(steps.changed-files-since.outputs.all_changed_files, '.github/workflows/sync-release-version.yml')"
run: |
echo "Invalid output: Expected to include (.github/workflows/sync-release-version.yml) got (${{ steps.changed-files-since.outputs.all_changed_files }})"
exit 1
shell:
bash
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-since.outputs) }}'
shell:
bash
- name: Run changed-files until 2022-08-20
id: changed-files-until
uses: ./
with:
until: "2022-08-20"
- name: Check output
if: "!contains(steps.changed-files-until.outputs.all_changed_files, 'README.md')"
run: |
echo "Invalid output: Expected to include (README.md) got (${{ steps.changed-files-until.outputs.all_changed_files }})"
exit 1
shell:
bash
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-until.outputs) }}'
shell:
bash
test-similar-base-and-commit-sha:
name: Test changed-files similar base and commit sha
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.files_changed != 'true'
permissions:
contents: read
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files with similar base and commit sha
id: changed-files
continue-on-error: true
uses: ./
with:
base_sha: d1c0ee4
sha: d1c0ee4
- name: Exit with 1 if no error is raised
if: steps.changed-files.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
exit 1
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files.outputs) }}'
shell:
bash
test-using-branch-names-for-base-sha-and-sha-inputs:
name: Test using branch names for base_sha and sha inputs
runs-on: ubuntu-latest
needs: build
if: |
(
github.event_name == 'push' ||
github.event_name == 'pull_request'
) && needs.build.outputs.files_changed != 'true'
permissions:
contents: read
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files with main as the base_sha
id: changed-files
uses: ./
with:
base_sha: main
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files.outputs) }}'
shell:
bash
test-limited-commit-history:
name: Test changed-files with limited commit history
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.files_changed != 'true'
permissions:
contents: read
strategy:
fail-fast: false
max-parallel: 4
matrix:
fetch-depth: [1, 2, 50]
input-fetch_depth: [1, 2, 50]
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: ${{ matrix.fetch-depth }}
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files
id: changed-files
uses: ./
continue-on-error: ${{ matrix.input-skip_initial_fetch == true && matrix.fetch-depth < 10 }}
with:
fetch_depth: ${{ matrix.input-fetch_depth }}
skip_initial_fetch: ${{ github.event_name == 'push' }}
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files.outputs) }}'
shell:
bash
test-pull-request-head-ref:
name: Test changed-files with pull request head ref
runs-on: ubuntu-latest
needs: build
if: github.event_name != 'push' && needs.build.outputs.files_changed != 'true'
permissions:
contents: read
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files
id: changed-files
uses: ./
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files.outputs) }}'
shell:
bash
test-pull-request-without-persist-credentials:
name: Test changed-files with pull request without persist credentials
runs-on: ubuntu-latest
needs: build
if: github.event_name != 'push' && needs.build.outputs.files_changed != 'true'
permissions:
contents: read
strategy:
fail-fast: false
max-parallel: 4
matrix:
fetch-depth: [1, 2, 0]
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: ${{ matrix.fetch-depth }}
persist-credentials: false
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files
id: changed-files
uses: ./
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files.outputs) }}'
shell:
bash
test-non-existent-base-sha:
name: Test changed-files non existent base sha
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.files_changed != 'true'
permissions:
contents: read
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files with non existent base sha
id: changed-files
uses: ./
continue-on-error: true
with:
base_sha: "4554456"
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash
- name: Exit with 1 if no error is raised
if: steps.changed-files.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
exit 1
- name: Run changed-files-specific with non existent base sha
id: changed-files-specific
uses: ./
continue-on-error: true
with:
files: action.yml
base_sha: "4554456"
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
shell:
bash
- name: Exit with 1 if no error is raised
if: steps.changed-files-specific.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files-specific.outcome }}"
exit 1
test-non-existent-sha:
name: Test changed-files non existent sha
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.files_changed != 'true'
permissions:
contents: read
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files with non existent sha
id: changed-files
uses: ./
continue-on-error: true
with:
sha: "4774456"
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash
- name: Exit with 1 if no error is raised
if: steps.changed-files.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
exit 1
- name: Run changed-files-specific with non existent sha
id: changed-files-specific
uses: ./
continue-on-error: true
with:
files: action.yml
sha: "4774456"
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
shell:
bash
- name: Exit with 1 if no error is raised
if: steps.changed-files-specific.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files-specific.outcome }}"
exit 1
test-rest-api:
name: Test changed-files with REST API
runs-on: ubuntu-latest
needs: build
if: github.event_name != 'push' && needs.build.outputs.files_changed != 'true'
permissions:
pull-requests: read
steps:
- name: Checkout into dir1
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: true
fetch-depth: 0
path: dir1
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
path: dir1/dist
- name: Run changed-files with REST API
id: changed-files
uses: ./dir1
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files.outputs) }}'
shell:
bash
test-dir-names-nested-folder:
name: Test changed-files with dir-names in a nested folder
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.files_changed != 'true'
permissions:
contents: read
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: true
fetch-depth: 0
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
path: dist
- name: Get changed files in the .github folder
id: changed-files
uses: ./
with:
path: .github
json: true
escape_json: false
dir_names: true
dir_names_exclude_current_dir: true
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash
test-non-existing-repository:
name: Test changed-files with non existing repository
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && needs.build.outputs.files_changed != 'true'
permissions:
contents: read
steps:
- name: Checkout into dir1
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: true
fetch-depth: 0
path: dir1
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
path: dir1/dist
- name: Run changed-files with non existing repository
id: changed-files
continue-on-error: true
uses: ./dir1
- name: Verify failed
if: steps.changed-files.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
exit 1
test-submodules:
name: Test changed-files with submodule
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.files_changed != 'true'
permissions:
contents: read
strategy:
fail-fast: false
max-parallel: 4
matrix:
fetch-depth: [0, 1, 2]
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
submodules: recursive
fetch-depth: ${{ matrix.fetch-depth }}
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files with submodule
id: changed-files
uses: ./
with:
base_sha: "85bd869"
sha: "adde7bb"
fetch_depth: 60000
- name: Verify added files
if: steps.changed-files.outputs.added_files != 'test/demo/test/test.txt'
run: |
echo "Expected: (test/demo/test/test.txt) got ${{ steps.changed-files.outputs.added_files }}"
exit 1
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash
- name: Run changed-files excluding submodule
id: changed-files-exclude-submodule
uses: ./
with:
base_sha: "85bd869"
sha: "adde7bb"
fetch_depth: 60000
exclude_submodules: true
- name: Verify no added files
if: steps.changed-files-exclude-submodule.outputs.added_files != ''
run: |
echo "Expected: ('') got ${{ steps.changed-files-exclude-submodule.outputs.added_files }}"
exit 1
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-exclude-submodule.outputs) }}"
shell:
bash
test-yaml:
name: Test changed-files with yaml
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.files_changed != 'true'
permissions:
contents: read
strategy:
fail-fast: false
max-parallel: 4
matrix:
fetch-depth: [0, 1, 2]
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
submodules: recursive
fetch-depth: ${{ matrix.fetch-depth }}
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files with files_yaml
id: changed-files
uses: ./
with:
files_yaml: |
test:
- test/**.txt
- test/**.md
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash
- name: Run changed-files with files_yaml_from_source_file
id: changed-files-from-source-file
uses: ./
with:
files_yaml_from_source_file: |
test/changed-files.yml
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-from-source-file.outputs) }}"
shell:
bash
- name: Run changed-files with files_yaml, json and write_output_files
id: changed-files-json-write-output-files
uses: ./
with:
files_yaml: |
test:
- .github/workflows/test.yml
json: true
write_output_files: true
- name: Show all outputs
run: |
echo "${{ toJSON(steps.changed-files-json-write-output-files.outputs) }}"
shell:
bash
- name: Show all_changed_files output and list .github/outputs
run: |
echo '${{ toJSON(steps.changed-files-json-write-output-files.outputs.test_all_changed_files) }}'
cat .github/outputs/test_all_changed_files.json
shell:
bash
test-recover-deleted-file:
name: Test changed-files recover deleted file
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.files_changed != 'true'
permissions:
contents: read
strategy:
fail-fast: false
max-parallel: 4
matrix:
fetch-depth: [0, 1, 2]
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
submodules: recursive
fetch-depth: ${{ matrix.fetch-depth }}
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: build-assets
- name: Run changed-files with recover_deleted_files
id: changed-files-recover-deleted-files
uses: ./
with:
base_sha: "fcdeb5b3d797752d95f6dbe98552a95c29dad338"
sha: "432e0c810c60ef1332850a971c5ec39022034b4c"
recover_deleted_files: true
fetch_depth: 60000
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-recover-deleted-files.outputs) }}"
shell:
bash
- name: Verify deleted files
if: steps.changed-files-recover-deleted-files.outputs.deleted_files != 'test/test deleted.txt'
run: |
echo "Expected: (test/test deleted.txt) got ${{ steps.changed-files-recover-deleted-files.outputs.deleted_files }}"
exit 1
- name: Verify that test/test deleted.txt is restored
run: |
if [ ! -f "test/test deleted.txt" ]; then
echo "Expected: (test/test deleted.txt) to exist"
exit 1
else
cat "test/test deleted.txt"
rm "test/test deleted.txt"
fi
- name: Run changed-files with recover_deleted_files and files input
id: changed-files-recover-deleted-files-with-files
uses: ./
with:
base_sha: "fcdeb5b3d797752d95f6dbe98552a95c29dad338"
sha: "432e0c810c60ef1332850a971c5ec39022034b4c"
files: |
test/**
recover_deleted_files: true
fetch_depth: 60000
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-recover-deleted-files-with-files.outputs) }}"
shell:
bash
- name: Verify deleted files
if: steps.changed-files-recover-deleted-files-with-files.outputs.deleted_files != 'test/test deleted.txt'
run: |
echo "Expected: (test/test deleted.txt) got ${{ steps.changed-files-recover-deleted-files-with-files.outputs.deleted_files }}"
exit 1
- name: Verify that test/test deleted.txt is restored
run: |
if [ ! -f "test/test deleted.txt" ]; then
echo "Expected: (test/test deleted.txt) to exist"
exit 1
else
cat "test/test deleted.txt"
rm "test/test deleted.txt"
fi
- name: Run changed-files with recover_deleted_files and files_yaml input
id: changed-files-recover-deleted-files-with-files-yaml
uses: ./
with:
base_sha: "fcdeb5b3d797752d95f6dbe98552a95c29dad338"
sha: "432e0c810c60ef1332850a971c5ec39022034b4c"
files_yaml: |
test:
- test/**.txt
- test/**.md
recover_deleted_files: true
fetch_depth: 60000
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-recover-deleted-files-with-files-yaml.outputs) }}"
shell:
bash
- name: Verify deleted files
if: steps.changed-files-recover-deleted-files-with-files-yaml.outputs.test_deleted_files != 'test/test deleted.txt'
run: |
echo "Expected: (test/test deleted.txt) got ${{ steps.changed-files-recover-deleted-files-with-files-yaml.outputs.test_deleted_files }}"
exit 1
- name: Verify that the modified_keys is correct
if: "!contains(steps.changed-files-recover-deleted-files-with-files-yaml.outputs.modified_keys, 'test')"
run: |
echo "Expected: (test) got ${{ steps.changed-files-recover-deleted-files-with-files-yaml.outputs.modified_keys }}"
exit 1
- name: Verify that test/test deleted.txt is restored
run: |
if [ ! -f "test/test deleted.txt" ]; then
echo "Expected: (test/test deleted.txt) to exist"
exit 1
else
cat "test/test deleted.txt"
rm "test/test deleted.txt"
fi
- name: Run changed-files with recover_deleted_files and recover_deleted_files_to_destination
id: changed-files-recover-deleted-files-to-destination
uses: ./
with:
base_sha: "fcdeb5b3d797752d95f6dbe98552a95c29dad338"
sha: "432e0c810c60ef1332850a971c5ec39022034b4c"
recover_deleted_files: true
recover_deleted_files_to_destination: "deleted_files"
fetch_depth: 60000
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-recover-deleted-files-to-destination.outputs) }}"
shell:
bash
- name: Verify deleted files
if: steps.changed-files-recover-deleted-files-to-destination.outputs.deleted_files != 'test/test deleted.txt'
run: |
echo "Expected: (test/test deleted.txt) got ${{ steps.changed-files-recover-deleted-files-to-destination.outputs.deleted_files }}"
exit 1
- name: Verify that test/test deleted.txt is restored
run: |
if [ ! -f "deleted_files/test/test deleted.txt" ]; then
echo "Expected: (deleted_files/test/test deleted.txt) to exist"
exit 1
else
cat "deleted_files/test/test deleted.txt"
fi
- name: Run changed-files with recover_deleted_files for an expected git submodule file
id: changed-files-recover-deleted-files-within-submodule
uses: ./
with:
base_sha: "3be651e99d3d4eae395694f6c6f3b9d18457f6c8"
sha: "d90c240f2ad4ec04d8f0f48e5ac290ad96ebe850"
recover_deleted_files: true
fetch_depth: 60000
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-recover-deleted-files-within-submodule.outputs) }}"
shell:
bash
- name: Verify deleted files
if: steps.changed-files-recover-deleted-files-within-submodule.outputs.deleted_files != 'test/demo/.github/FUNDING.yml'
run: |
echo "Expected: (test/demo/.github/FUNDING.yml) got ${{ steps.changed-files-recover-deleted-files-within-submodule.outputs.deleted_files }}"
exit 1
- name: Verify that test/demo/.github/FUNDING.yml is restored
run: |
if [ ! -f "test/demo/.github/FUNDING.yml" ]; then
echo "Expected: (test/demo/.github/FUNDING.yml) to exist"
exit 1
else
cat "test/demo/.github/FUNDING.yml"
rm "test/demo/.github/FUNDING.yml"
fi
test-dir-names-deleted-files-include-only-deleted-dirs-single-file:
name: Test dir names deleted files include only deleted dirs single file
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.files_changed != 'true'
permissions:
contents: read
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: a52f8621d26d5d9f54b80f74bda2d9eedff94693
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: true
fetch-depth: 2
- name: Run changed-files with dir_names and dir_names_deleted_files_include_only_deleted_dirs with a single file deleted withing the test directory
id: changed-files-dir-names-deleted-files-include-only-deleted-dirs-single-file
uses: ./
with:
base_sha: 920856cfdd4b4be17810e34b197596397473adf6
sha: a52f8621d26d5d9f54b80f74bda2d9eedff94693
dir_names: true
dir_names_deleted_files_include_only_deleted_dirs: true
- name: Show output
run: |