generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 4
132 lines (131 loc) · 4.29 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
name: "build-test"
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- master
- 'releases/*'
jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
npm install
npm run all
test-1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./
id: filter
with:
filters: |
test:
- testzone/*.txt
- name: Check Output
run: '[[ "${{ steps.filter.outputs.test }}" = "false" ]]'
test-2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Committer Info
run: |
git config user.name 'Github Action' && \
git config user.email '[email protected]'
# add a fake commit
- name: Add Commit
run: |
mkdir testzone && \
touch testzone/touched.txt && \
git add testzone/touched.txt && \
git commit -m "add testzone/touched.txt"
- uses: ./
id: filter
with:
filters: |
test:
- testzone/*.txt
# Override ${{ github.event.pull_request.head.sha }} to HEAD for testing
head: 'HEAD'
- name: Check Output
run: |
[[ "${{ steps.filter.outputs.test }}" = "true" ]] &&
[[ "${{ steps.filter.outputs.test_files }}" = "testzone/touched.txt" ]]
# test case of issue #7
test-3:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Committer Info
run: |
git config user.name 'Github Action' && \
git config user.email '[email protected]'
- name: Add Commit
id: add_commit
run: |
git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} && \
git checkout -b this_pr && \
mkdir testzone && \
touch testzone/added_by_this_pr.txt && \
git add testzone/added_by_this_pr.txt && \
git commit -m "add by this PR" && \
echo "::set-output name=head::$(git rev-parse HEAD)"
- name: Move Base
id: move_base
run: |
git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} && \
git checkout -b base ${{ github.event.pull_request.base.sha }} && \
mkdir testzone_1 && \
touch testzone_1/added_by_other_pr.txt && \
git add testzone_1/added_by_other_pr.txt && \
git commit -m "another merged PR" && \
echo "::set-output name=base::$(git rev-parse HEAD)" && \
git checkout this_pr
- uses: ./
id: filter
with:
# for testing, set the base to moved base, simulating the situation that the base changed (probably another PR
# got merged into the master)
base: ${{ steps.move_base.outputs.base }}
head: ${{ steps.add_commit.outputs.head }}
filters: |
this_pr:
- testzone/*.txt
test:
- testzone_1/*.txt
- name: Check Output
# Although "base" has a additional commit modifying the file matching "testzone_1/*.txt" (testzone_1/added_by_other_pr.txt),
# the file is already merged in the "base"
run: '[[ "${{ steps.filter.outputs.test }}" = "false" && "${{ steps.filter.outputs.this_pr }}" = "true" ]]'
test-4:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Committer Info
run: |
git config user.name 'Github Action' && \
git config user.email '[email protected]'
# add a fake commit
- name: Add Commit
run: |
touch a.txt && \
touch b.txt && \
git add a.txt b.txt && \
git commit -m "add txt files"
- uses: ./
id: filter
with:
filters: |
test:
- '*.txt'
a:
- a.txt
# Override ${{ github.event.pull_request.head.sha }} to HEAD for testing
head: 'HEAD'
- name: Check Output
run: |
[[ "${{ steps.filter.outputs.test }}" = "true" ]] &&
[[ "${{ steps.filter.outputs.test_files }}" = "a.txt b.txt" ]] &&
[[ "${{ steps.filter.outputs.a }}" = "true" ]] &&
[[ "${{ steps.filter.outputs.a_files }}" = "a.txt" ]]