@@ -17,13 +17,32 @@ jobs:
1717 name : ESLint
1818 runs-on : ubuntu-latest
1919 steps :
20- - uses : actions/checkout@v1
20+ - uses : actions/checkout@v2
2121 with :
2222 fetch-depth : 3
23+ - uses : technote-space/get-diff-action@v1
24+ with :
25+ PREFIX_FILTER : assets/js/
26+ SUFFIX_FILTER : .js
27+ FILES : .eslintrc
28+ - name : Get Yarn Cache Directory
29+ id : yarn-cache
30+ run : echo "::set-output name=dir::$(yarn cache dir)"
31+ if : env.GIT_DIFF
32+ - name : Cache node dependencies
33+ uses : actions/cache@v1
34+ with :
35+ path : ${{ steps.yarn-cache.outputs.dir }}
36+ key : ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
37+ restore-keys : |
38+ ${{ runner.os }}-yarn-
39+ if : env.GIT_DIFF
2340 - name : Prepare setting
2441 run : git clone --depth=1 https://github.com/wp-content-framework/travis-ci.git travis-ci && bash travis-ci/bin/prepare.sh
42+ if : env.GIT_DIFF
2543 - name : Check code style
2644 run : bash travis-ci/bin/js/js-lint.sh
45+ if : env.GIT_DIFF
2746 - uses : 8398a7/action-slack@v1
2847 with :
2948 type : failure
@@ -35,13 +54,34 @@ jobs:
3554 name : PHP Code Sniffer
3655 runs-on : ubuntu-latest
3756 steps :
38- - uses : actions/checkout@v1
57+ - uses : actions/checkout@v2
3958 with :
4059 fetch-depth : 3
60+ - uses : technote-space/get-diff-action@v1
61+ with :
62+ PREFIX_FILTER : |
63+ configs/
64+ src/
65+ tests/
66+ SUFFIX_FILTER : .php
67+ - name : Get Composer Cache Directory
68+ id : composer-cache
69+ run : |
70+ echo "::set-output name=dir::$(composer config cache-files-dir)"
71+ if : env.GIT_DIFF
72+ - uses : actions/cache@v1
73+ with :
74+ path : ${{ steps.composer-cache.outputs.dir }}
75+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
76+ restore-keys : |
77+ ${{ runner.os }}-composer-
78+ if : env.GIT_DIFF
4179 - name : Prepare setting
4280 run : git clone --depth=1 https://github.com/wp-content-framework/travis-ci.git travis-ci && bash travis-ci/bin/prepare.sh
81+ if : env.GIT_DIFF
4382 - name : Check code style
4483 run : bash travis-ci/bin/php/phpcs.sh
84+ if : env.GIT_DIFF
4585 - uses : 8398a7/action-slack@v1
4686 with :
4787 type : failure
@@ -53,13 +93,34 @@ jobs:
5393 name : PHPMD
5494 runs-on : ubuntu-latest
5595 steps :
56- - uses : actions/checkout@v1
96+ - uses : actions/checkout@v2
5797 with :
5898 fetch-depth : 3
99+ - uses : technote-space/get-diff-action@v1
100+ with :
101+ PREFIX_FILTER : |
102+ configs/
103+ src/
104+ tests/
105+ SUFFIX_FILTER : .php
106+ - name : Get Composer Cache Directory
107+ id : composer-cache
108+ run : |
109+ echo "::set-output name=dir::$(composer config cache-files-dir)"
110+ if : env.GIT_DIFF
111+ - uses : actions/cache@v1
112+ with :
113+ path : ${{ steps.composer-cache.outputs.dir }}
114+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
115+ restore-keys : |
116+ ${{ runner.os }}-composer-
117+ if : env.GIT_DIFF
59118 - name : Prepare setting
60119 run : git clone --depth=1 https://github.com/wp-content-framework/travis-ci.git travis-ci && bash travis-ci/bin/prepare.sh
120+ if : env.GIT_DIFF
61121 - name : Check code style
62122 run : bash travis-ci/bin/php/phpmd.sh
123+ if : env.GIT_DIFF
63124 - uses : 8398a7/action-slack@v1
64125 with :
65126 type : failure
@@ -76,23 +137,50 @@ jobs:
76137 matrix :
77138 node : ['10', '11', '12']
78139 steps :
79- - uses : actions/checkout@v1
140+ - uses : actions/checkout@v2
80141 with :
81142 fetch-depth : 3
143+ - uses : technote-space/get-diff-action@v1
144+ with :
145+ PREFIX_FILTER : assets/js/
146+ SUFFIX_FILTER : |
147+ .js
148+ .snap
149+ FILES : |
150+ yarn.lock
151+ jest.config.js
82152 - name : Setup node
83153 uses : actions/setup-node@v1
84154 with :
85155 node-version : ${{ matrix.node }}
156+ if : env.GIT_DIFF || github.event_name == 'push'
157+ - name : Get Yarn Cache Directory
158+ id : yarn-cache
159+ run : echo "::set-output name=dir::$(yarn cache dir)"
160+ if : env.GIT_DIFF || github.event_name == 'push'
161+ - name : Cache node dependencies
162+ uses : actions/cache@v1
163+ with :
164+ path : ${{ steps.yarn-cache.outputs.dir }}
165+ key : ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
166+ restore-keys : |
167+ ${{ runner.os }}-yarn-
168+ if : env.GIT_DIFF || github.event_name == 'push'
86169 - name : Prepare setting
87170 run : git clone --depth=1 https://github.com/wp-content-framework/travis-ci.git travis-ci && bash travis-ci/bin/prepare.sh
171+ if : env.GIT_DIFF || github.event_name == 'push'
88172 - name : Run tests
89173 run : bash travis-ci/bin/js/js-test.sh
174+ if : env.GIT_DIFF || github.event_name == 'push'
90175 - name : Codecov
91- run : curl -s https://codecov.io/bash | bash -s -- -t $CODECOV_TOKEN -f $COVERAGE_FILE
176+ run : |
177+ if [ -n "$CODECOV_TOKEN" ]; then
178+ curl -s https://codecov.io/bash | bash -s -- -t $CODECOV_TOKEN -f $COVERAGE_FILE
179+ fi
92180 env :
93181 CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
94182 COVERAGE_FILE : ./assets/js/coverage/lcov.info
95- if : matrix.node == '12'
183+ if : matrix.node == '12' && (env.GIT_DIFF || github.event_name == 'push')
96184 - uses : 8398a7/action-slack@v1
97185 with :
98186 type : failure
@@ -112,7 +200,7 @@ jobs:
112200 strategy :
113201 matrix :
114202 php : ['7.0', '7.3', '5.6']
115- WP_VERSION : ['latest', '5.2', ' 4.6']
203+ WP_VERSION : ['latest', '4.6']
116204 WP_MULTISITE : ['0', '1']
117205 include :
118206 - php : ' 7.3'
@@ -123,32 +211,58 @@ jobs:
123211 - php : ' 7.3'
124212 WP_VERSION : ' 4.6'
125213 steps :
126- - uses : actions/checkout@v1
214+ - uses : actions/checkout@v2
127215 with :
128216 fetch-depth : 3
217+ - uses : technote-space/get-diff-action@v1
218+ with :
219+ PREFIX_FILTER : |
220+ configs/
221+ src/
222+ tests/
223+ SUFFIX_FILTER : .php
224+ FILES : composer.lock
129225 - name : Switch PHP version
130226 env :
131227 PHP_VERSION : ${{ matrix.php }}
132228 run : sudo ln -sf "/usr/bin/php$PHP_VERSION" /etc/alternatives/php
229+ if : env.GIT_DIFF || github.event_name == 'push'
230+ - name : Get Composer Cache Directory
231+ id : composer-cache
232+ run : |
233+ echo "::set-output name=dir::$(composer config cache-files-dir)"
234+ if : env.GIT_DIFF || github.event_name == 'push'
235+ - uses : actions/cache@v1
236+ with :
237+ path : ${{ steps.composer-cache.outputs.dir }}
238+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
239+ restore-keys : |
240+ ${{ runner.os }}-composer-
241+ if : env.GIT_DIFF || github.event_name == 'push'
133242 - name : Prepare setting
134243 run : git clone --depth=1 https://github.com/wp-content-framework/travis-ci.git travis-ci && bash travis-ci/bin/prepare.sh
135244 env :
136245 WP_VERSION : ${{ matrix.WP_VERSION }}
137246 WP_MULTISITE : ${{ matrix.WP_MULTISITE }}
138247 ACTIVATE_POPULAR_PLUGINS : ${{ matrix.ACTIVATE_POPULAR_PLUGINS }}
248+ if : env.GIT_DIFF || github.event_name == 'push'
139249 - name : Run tests
140250 run : bash travis-ci/bin/php/wp-test.sh
141251 env :
142252 DB_PASS : root
143253 WP_VERSION : ${{ matrix.WP_VERSION }}
144254 WP_MULTISITE : ${{ matrix.WP_MULTISITE }}
145255 ACTIVATE_POPULAR_PLUGINS : ${{ matrix.ACTIVATE_POPULAR_PLUGINS }}
256+ if : env.GIT_DIFF || github.event_name == 'push'
146257 - name : Codecov
147- run : curl -s https://codecov.io/bash | bash -s -- -t $CODECOV_TOKEN -f $COVERAGE_FILE
258+ run : |
259+ if [ -n "$CODECOV_TOKEN" ]; then
260+ curl -s https://codecov.io/bash | bash -s -- -t $CODECOV_TOKEN -f $COVERAGE_FILE
261+ fi
148262 env :
149263 CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
150264 COVERAGE_FILE : ./coverage/clover.xml
151- if : matrix.ACTIVATE_POPULAR_PLUGINS == 1
265+ if : matrix.ACTIVATE_POPULAR_PLUGINS == 1 && (env.GIT_DIFF || github.event_name == 'push')
152266 - uses : 8398a7/action-slack@v1
153267 with :
154268 type : failure
0 commit comments