Skip to content

Commit 4a5e7dd

Browse files
authored
Merge pull request #29 from datavisyn/new_deployment_playwright
feat: Add playwright option next to cypress option
2 parents 3ec02ba + 1a21515 commit 4a5e7dd

File tree

1 file changed

+95
-2
lines changed

1 file changed

+95
-2
lines changed

.github/workflows/build-node-python.yml

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ on:
2323
type: string
2424
required: false
2525
default: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || !!startsWith(github.ref, 'refs/heads/release-') }}
26+
playwright_enable:
27+
description: "Global enable for playwright"
28+
type: boolean
29+
required: false
30+
default: false
31+
playwright_run_because_flag:
32+
description: "Local flag to run playwright. Will only work if playwright_enable: true."
33+
type: boolean
34+
required: false
35+
default: false
36+
playwright_run_because_branch:
37+
description: "Branch names to run playwright on. Will only work if playwright_enable: true."
38+
# TODO: actionlint is failing as it expects true/false as default value for boolean types
39+
type: string
40+
required: false
41+
default: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || !!startsWith(github.ref, 'refs/heads/release-') }}
2642
node_run_webpack:
2743
description: "Flag to always run the webpack production build."
2844
type: boolean
@@ -36,6 +52,10 @@ on:
3652
type: string
3753
required: false
3854
default: "ubuntu-22.04-large"
55+
playwright_runs_on:
56+
type: string
57+
required: false
58+
default: "ubuntu-22.04-large"
3959
secrets:
4060
DATAVISYN_BOT_REPO_TOKEN:
4161
required: false
@@ -63,7 +83,7 @@ permissions:
6383
jobs:
6484
build-node:
6585
name: Node
66-
if: ${{ !inputs.cypress_enable || (!inputs.cypress_run_because_flag && inputs.cypress_run_because_branch != 'true') }}
86+
if: ${{ (!inputs.cypress_enable || (!inputs.cypress_run_because_flag && inputs.cypress_run_because_branch != 'true')) && (!inputs.playwright_enable || (!inputs.playwright_run_because_flag && inputs.playwright_run_because_branch != 'true')) }}
6787
concurrency:
6888
group: "node-${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.branch }}"
6989
cancel-in-progress: true
@@ -93,7 +113,7 @@ jobs:
93113

94114
build-python:
95115
name: Python
96-
if: ${{ !inputs.cypress_enable || (!inputs.cypress_run_because_flag && inputs.cypress_run_because_branch != 'true') }}
116+
if: ${{ (!inputs.cypress_enable || (!inputs.cypress_run_because_flag && inputs.cypress_run_because_branch != 'true')) && (!inputs.playwright_enable || (!inputs.playwright_run_because_flag && inputs.playwright_run_because_branch != 'true')) }}
97117
concurrency:
98118
group: "python-${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.branch }}"
99119
cancel-in-progress: true
@@ -211,3 +231,76 @@ jobs:
211231
# with:
212232
# name: cypress-videos
213233
# path: cypress/videos
234+
235+
# If playwright is used, build node and python sequentially as it is avoiding the duplicate install overhead
236+
build-node-python-playwright:
237+
name: Node, Python, Playwright
238+
if: ${{ inputs.playwright_enable && (inputs.playwright_run_because_flag || inputs.playwright_run_because_branch == 'true') }}
239+
concurrency:
240+
group: "node-python-playwright-${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.branch }}"
241+
cancel-in-progress: true
242+
permissions:
243+
id-token: write
244+
contents: write
245+
runs-on: ${{ inputs.playwright_runs_on || inputs.runs_on }}
246+
247+
services:
248+
postgres:
249+
image: postgres:14
250+
env:
251+
POSTGRES_USER: admin
252+
POSTGRES_PASSWORD: admin
253+
POSTGRES_DB: db
254+
options: >-
255+
--health-cmd pg_isready
256+
--health-interval 10s
257+
--health-timeout 5s
258+
--health-retries 5
259+
ports:
260+
- 5432:5432
261+
262+
steps:
263+
- name: Checkout source repository
264+
uses: actions/checkout@v3
265+
with:
266+
ref: ${{ inputs.branch }}
267+
token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
268+
- name: Checkout github-workflows
269+
uses: actions/checkout@v3
270+
with:
271+
repository: datavisyn/github-workflows
272+
ref: ${{ env.WORKFLOW_BRANCH }}
273+
path: ./tmp/github-workflows
274+
- name: Build node
275+
uses: ./tmp/github-workflows/.github/actions/build-node
276+
with:
277+
node_version: ${{ secrets.NODE_VERSION || env.NODE_VERSION }}
278+
npm_registry: ${{ env.NPM_REGISTRY }}
279+
github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
280+
run_webpack: false # Disable the build here and call afterwards, as otherwise the yarn run env:decrypt will fail due to a missing yarn install
281+
- name: Build python
282+
uses: ./tmp/github-workflows/.github/actions/build-python
283+
with:
284+
python_version: ${{ secrets.PYTHON_VERSION || env.PYTHON_VERSION }}
285+
github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
286+
- name: Decrypt .env.enc and <app>/.env.enc
287+
run: |
288+
yarn run env:decrypt -pass env:ENV_PASSWORD || true
289+
make env_decrypt || true
290+
env:
291+
ENV_PASSWORD: ${{ secrets.ENV_PASSWORD }}
292+
- name: Webpack build
293+
run: npm run webpack:prod
294+
shell: bash
295+
- name: Install playwright browsers
296+
run: yarn playwright install --with-deps chromium
297+
shell: bash
298+
- name: Run playwright e2e tests
299+
run: yarn run pw:run
300+
shell: bash
301+
- name: Upload playwright report
302+
uses: actions/upload-artifact@v3
303+
if: always()
304+
with:
305+
name: playwright-report
306+
path: playwright-report/

0 commit comments

Comments
 (0)