33 push :
44 branches :
55 - master
6- pull_request :
6+ pull_request_target :
7+ branches :
8+ - master
79env :
8- NODE_VERSION : 16.20.1
10+ NODE_VERSION : 18
11+ YARN_VERSION : 1.22.22
912jobs :
1013 backend-lint :
1114 runs-on : ubuntu-22.04
1215 steps :
13- - uses : actions/checkout@v3
16+ - if : github.event.pull_request.mergeable == 'false'
17+ name : Exit if PR is not mergeable
18+ run : exit 1
19+ - uses : actions/checkout@v4
1420 with :
1521 fetch-depth : 1
16- - uses : actions/setup-python@v4
22+ ref : ${{ github.event.pull_request.head.sha }}
23+ - uses : actions/setup-python@v5
1724 with :
1825 python-version : ' 3.8'
1926 - run : sudo pip install black==23.1.0 ruff==0.0.287
@@ -24,14 +31,18 @@ jobs:
2431 runs-on : ubuntu-22.04
2532 needs : backend-lint
2633 env :
27- COMPOSE_FILE : .ci/docker- compose.ci.yml
34+ COMPOSE_FILE : .ci/compose.ci.yaml
2835 COMPOSE_PROJECT_NAME : redash
2936 COMPOSE_DOCKER_CLI_BUILD : 1
3037 DOCKER_BUILDKIT : 1
3138 steps :
32- - uses : actions/checkout@v3
39+ - if : github.event.pull_request.mergeable == 'false'
40+ name : Exit if PR is not mergeable
41+ run : exit 1
42+ - uses : actions/checkout@v4
3343 with :
3444 fetch-depth : 1
45+ ref : ${{ github.event.pull_request.head.sha }}
3546 - name : Build Docker Images
3647 run : |
3748 set -x
@@ -51,53 +62,63 @@ jobs:
5162 docker cp tests:/app/junit.xml /tmp/test-results/unit-tests/results.xml
5263 - name : Upload coverage reports to Codecov
5364 uses : codecov/codecov-action@v3
65+ with :
66+ token : ${{ secrets.CODECOV_TOKEN }}
5467 - name : Store Test Results
55- uses : actions/upload-artifact@v3
68+ uses : actions/upload-artifact@v4
5669 with :
57- name : test-results
70+ name : backend- test-results
5871 path : /tmp/test-results
5972 - name : Store Coverage Results
60- uses : actions/upload-artifact@v3
73+ uses : actions/upload-artifact@v4
6174 with :
6275 name : coverage
6376 path : coverage.xml
6477
6578 frontend-lint :
6679 runs-on : ubuntu-22.04
6780 steps :
68- - uses : actions/checkout@v3
81+ - if : github.event.pull_request.mergeable == 'false'
82+ name : Exit if PR is not mergeable
83+ run : exit 1
84+ - uses : actions/checkout@v4
6985 with :
7086 fetch-depth : 1
71- - uses : actions/setup-node@v3
87+ ref : ${{ github.event.pull_request.head.sha }}
88+ - uses : actions/setup-node@v4
7289 with :
7390 node-version : ${{ env.NODE_VERSION }}
7491 cache : ' yarn'
7592 - name : Install Dependencies
7693 run : |
77- npm install --global --force yarn@1.22.19
94+ npm install --global --force yarn@$YARN_VERSION
7895 yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
7996 - name : Run Lint
8097 run : yarn lint:ci
8198 - name : Store Test Results
82- uses : actions/upload-artifact@v3
99+ uses : actions/upload-artifact@v4
83100 with :
84- name : test-results
101+ name : frontend- test-results
85102 path : /tmp/test-results
86103
87104 frontend-unit-tests :
88105 runs-on : ubuntu-22.04
89106 needs : frontend-lint
90107 steps :
91- - uses : actions/checkout@v3
108+ - if : github.event.pull_request.mergeable == 'false'
109+ name : Exit if PR is not mergeable
110+ run : exit 1
111+ - uses : actions/checkout@v4
92112 with :
93113 fetch-depth : 1
94- - uses : actions/setup-node@v3
114+ ref : ${{ github.event.pull_request.head.sha }}
115+ - uses : actions/setup-node@v4
95116 with :
96117 node-version : ${{ env.NODE_VERSION }}
97118 cache : ' yarn'
98119 - name : Install Dependencies
99120 run : |
100- npm install --global --force yarn@1.22.19
121+ npm install --global --force yarn@$YARN_VERSION
101122 yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
102123 - name : Run App Tests
103124 run : yarn test
@@ -109,18 +130,22 @@ jobs:
109130 runs-on : ubuntu-22.04
110131 needs : frontend-lint
111132 env :
112- COMPOSE_FILE : .ci/docker- compose.cypress.yml
133+ COMPOSE_FILE : .ci/compose.cypress.yaml
113134 COMPOSE_PROJECT_NAME : cypress
114- PERCY_TOKEN_ENCODED : ZGRiY2ZmZDQ0OTdjMzM5ZWE0ZGQzNTZiOWNkMDRjOTk4Zjg0ZjMxMWRmMDZiM2RjOTYxNDZhOGExMjI4ZDE3MA==
115- CYPRESS_PROJECT_ID_ENCODED : OTI0Y2th
116- CYPRESS_RECORD_KEY_ENCODED : YzA1OTIxMTUtYTA1Yy00NzQ2LWEyMDMtZmZjMDgwZGI2ODgx
117135 CYPRESS_INSTALL_BINARY : 0
118136 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD : 1
137+ PERCY_TOKEN : ${{ secrets.PERCY_TOKEN }}
138+ CYPRESS_PROJECT_ID : ${{ secrets.CYPRESS_PROJECT_ID }}
139+ CYPRESS_RECORD_KEY : ${{ secrets.CYPRESS_RECORD_KEY }}
119140 steps :
120- - uses : actions/checkout@v3
141+ - if : github.event.pull_request.mergeable == 'false'
142+ name : Exit if PR is not mergeable
143+ run : exit 1
144+ - uses : actions/checkout@v4
121145 with :
122146 fetch-depth : 1
123- - uses : actions/setup-node@v3
147+ ref : ${{ github.event.pull_request.head.sha }}
148+ - uses : actions/setup-node@v4
124149 with :
125150 node-version : ${{ env.NODE_VERSION }}
126151 cache : ' yarn'
@@ -130,7 +155,7 @@ jobs:
130155 echo "CODE_COVERAGE=true" >> "$GITHUB_ENV"
131156 - name : Install Dependencies
132157 run : |
133- npm install --global --force yarn@1.22.19
158+ npm install --global --force yarn@$YARN_VERSION
134159 yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
135160 - name : Setup Redash Server
136161 run : |
@@ -146,93 +171,7 @@ jobs:
146171 - name : Copy Code Coverage Results
147172 run : docker cp cypress:/usr/src/app/coverage ./coverage || true
148173 - name : Store Coverage Results
149- uses : actions/upload-artifact@v3
174+ uses : actions/upload-artifact@v4
150175 with :
151176 name : coverage
152177 path : coverage
153-
154- build-skip-check :
155- runs-on : ubuntu-22.04
156- outputs :
157- skip : ${{ steps.skip-check.outputs.skip }}
158- steps :
159- - name : Skip?
160- id : skip-check
161- run : |
162- if [[ "${{ vars.DOCKER_USER }}" == '' ]]; then
163- echo 'Docker user is empty. Skipping build+push'
164- echo skip=true >> "$GITHUB_OUTPUT"
165- elif [[ "${{ secrets.DOCKER_PASS }}" == '' ]]; then
166- echo 'Docker password is empty. Skipping build+push'
167- echo skip=true >> "$GITHUB_OUTPUT"
168- elif [[ "${{ github.ref_name }}" != 'master' ]]; then
169- echo 'Ref name is not `master`. Skipping build+push'
170- echo skip=true >> "$GITHUB_OUTPUT"
171- else
172- echo 'Docker user and password are set and branch is `master`.'
173- echo 'Building + pushing `preview` image.'
174- echo skip=false >> "$GITHUB_OUTPUT"
175- fi
176-
177- build-docker-image :
178- runs-on : ubuntu-22.04
179- needs :
180- - backend-unit-tests
181- - frontend-unit-tests
182- - frontend-e2e-tests
183- - build-skip-check
184- if : needs.build-skip-check.outputs.skip == 'false'
185- steps :
186- - uses : actions/checkout@v3
187- with :
188- fetch-depth : 1
189- - uses : actions/setup-node@v3
190- with :
191- node-version : ${{ env.NODE_VERSION }}
192- cache : ' yarn'
193- - name : Install Dependencies
194- run : |
195- npm install --global --force [email protected] 196- yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
197-
198- - name : Set up QEMU
199- timeout-minutes : 1
200- 201-
202- - name : Set up Docker Buildx
203- uses : docker/setup-buildx-action@v2
204-
205- - name : Login to DockerHub
206- uses : docker/login-action@v2
207- with :
208- username : ${{ vars.DOCKER_USER }}
209- password : ${{ secrets.DOCKER_PASS }}
210-
211- - name : Bump version
212- id : version
213- run : |
214- set -x
215- .ci/update_version
216- VERSION=$(jq -r .version package.json)
217- VERSION_TAG="${VERSION}.b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}"
218- echo "VERSION_TAG=$VERSION_TAG" >> "$GITHUB_OUTPUT"
219-
220- - name : Build and push preview image to Docker Hub
221- uses : docker/build-push-action@v4
222- with :
223- push : true
224- tags : |
225- redash/redash:preview
226- redash/preview:${{ steps.version.outputs.VERSION_TAG }}
227- context : .
228- build-args : |
229- test_all_deps=true
230- cache-from : type=ghq
231- cache-to : type=gha,mode=max
232- platforms : linux/amd64,linux/arm64
233- env :
234- DOCKER_CONTENT_TRUST : true
235-
236- - name : " Failure: output container logs to console"
237- if : failure()
238- run : docker compose logs
0 commit comments