Skip to content

Commit 730e048

Browse files
committed
remove separate redis job, enable by default
1 parent 8e63818 commit 730e048

File tree

1 file changed

+28
-116
lines changed

1 file changed

+28
-116
lines changed

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

Lines changed: 28 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ on:
8181
required: false
8282
type: boolean
8383
default: false
84-
redis_enable:
85-
description: 'Enable Redis service'
86-
required: false
87-
type: boolean
88-
default: false
8984

9085
secrets:
9186
DATAVISYN_BOT_REPO_TOKEN:
@@ -220,23 +215,43 @@ jobs:
220215
ports:
221216
# will assign a random free host port
222217
- 5432/tcp
223-
218+
redis:
219+
image: redis:6
220+
options: >-
221+
--health-cmd "redis-cli ping"
222+
--health-interval 10s
223+
--health-timeout 5s
224+
--health-retries 5
225+
--name redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
226+
ports:
227+
- 6379/tcp
228+
224229
steps:
225230
- name: Set self-hosted env variable to github env
226231
run: echo "GH_ACTIONS_SELF_HOSTED_NETWORK_NAME=${GH_ACTIONS_SELF_HOSTED_NETWORK_NAME}" >> "$GITHUB_ENV"
227-
- name: Set github token, hostname, port and docker network for self-hosted runner
232+
- name: Set up custom postgres and redis hostname, port and docker network for self-hosted runner
228233
if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME != ''
229-
run: |
234+
env:
235+
REDIS_HOSTNAME: redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
236+
REDIS_PORT: 6379
237+
run: |
230238
{
231239
echo "POSTGRES_HOSTNAME=postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
232240
echo "POSTGRES_PORT=5432"
241+
echo "REDIS_HOSTNAME=redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
242+
echo "REDIS_PORT=6379"
233243
} >> "$GITHUB_ENV"
234-
docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} "postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
235-
- name: Set postgres connection details to hosted runner
244+
docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.POSTGRES_HOSTNAME }}
245+
docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.REDIS_HOSTNAME }}
246+
- name: Set service connection details to hosted runner
236247
if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME == ''
237248
run: |
238-
echo "POSTGRES_HOSTNAME=localhost" >> "$GITHUB_ENV"
239-
echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}" >> "$GITHUB_ENV"
249+
{
250+
echo "POSTGRES_HOSTNAME=localhost"
251+
echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}"
252+
echo "REDIS_HOSTNAME=localhost"
253+
echo "REDIS_PORT=${{ job.services.redis.ports['6379'] }}"
254+
} >> "$GITHUB_ENV"
240255
- name: Checkout source repository
241256
uses: actions/checkout@v4
242257
with:
@@ -314,110 +329,7 @@ jobs:
314329
# If playwright is used, build node and python sequentially as it is avoiding the duplicate install overhead
315330
build-node-python-playwright:
316331
name: Node, Python, Playwright
317-
if: ${{ !inputs.redis_enable && inputs.playwright_enable && (inputs.playwright_run_because_flag || inputs.playwright_run_because_branch == 'true') }}
318-
concurrency:
319-
group: "node-python-playwright-${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.branch }}"
320-
cancel-in-progress: true
321-
permissions:
322-
id-token: write
323-
contents: write
324-
runs-on: ${{ inputs.playwright_runs_on || inputs.runs_on || 'ubuntu-22.04-large' }}
325-
326-
services:
327-
postgres:
328-
image: postgres:14
329-
env:
330-
POSTGRES_USER: admin
331-
POSTGRES_PASSWORD: admin
332-
POSTGRES_DB: db
333-
options: >-
334-
--health-cmd pg_isready
335-
--health-interval 10s
336-
--health-timeout 5s
337-
--health-retries 5
338-
--name postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
339-
ports:
340-
# will assign a random free host port
341-
- 5432/tcp
342-
343-
steps:
344-
- name: Set system env variable to github env
345-
run: echo "GH_ACTIONS_SELF_HOSTED_NETWORK_NAME=${GH_ACTIONS_SELF_HOSTED_NETWORK_NAME}" >> "$GITHUB_ENV"
346-
- name: Set github token, hostname, port and docker network for self-hosted runner
347-
if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME != ''
348-
run: |
349-
{
350-
echo "POSTGRES_HOSTNAME=postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
351-
echo "POSTGRES_PORT=5432"
352-
} >> "$GITHUB_ENV"
353-
docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.POSTGRES_HOSTNAME }}
354-
- name: Set postgres connection details to hosted runner
355-
if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME == ''
356-
run: |
357-
echo "POSTGRES_HOSTNAME=localhost" >> "$GITHUB_ENV"
358-
echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}" >> "$GITHUB_ENV"
359-
- name: Checkout source repository
360-
uses: actions/checkout@v4
361-
with:
362-
ref: ${{ inputs.branch }}
363-
token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
364-
fetch-depth: ${{ inputs.chromatic_enable && '0' || '1' }}
365-
- name: Checkout github-workflows
366-
uses: actions/checkout@v4
367-
with:
368-
repository: datavisyn/github-workflows
369-
ref: ${{ env.WORKFLOW_BRANCH }}
370-
path: ./tmp/github-workflows
371-
- name: Build node and python
372-
uses: ./tmp/github-workflows/.github/actions/build-node-python
373-
with:
374-
run_parallel: ${{ inputs.run_parallel }}
375-
node_version: ${{ secrets.NODE_VERSION || env.NODE_VERSION }}
376-
npm_registry: ${{ env.NPM_REGISTRY }}
377-
python_version: ${{ secrets.PYTHON_VERSION || env.PYTHON_VERSION }}
378-
github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
379-
run_node_bundle: false # Disable the build here and call afterwards, as otherwise the yarn run env:decrypt will fail due to a missing yarn install
380-
run_playwright_browser_install: true
381-
enable_node_cache: ${{ inputs.playwright_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }}
382-
enable_python_cache: ${{ inputs.playwright_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }}
383-
chromatic_enable: false # Set to false as we run chromatic below w/ playwright integration
384-
chromatic_project_token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
385-
- name: Decrypt .env.enc and <app>/.env.enc
386-
run: |
387-
yarn run env:decrypt -pass env:ENV_PASSWORD || true
388-
make env_decrypt || true
389-
env:
390-
ENV_PASSWORD: ${{ secrets.ENV_PASSWORD }}
391-
- name: Bundle build
392-
run: yarn run bundle:prod || yarn run webpack:dev
393-
shell: bash
394-
- name: Run playwright e2e tests
395-
run: yarn run pw:run ${{ inputs.playwright_spec_param }}
396-
shell: bash
397-
- name: Upload bundle
398-
uses: actions/upload-artifact@v4
399-
if: always()
400-
with:
401-
name: "bundles-${{ inputs.branch }}"
402-
path: bundles/
403-
- name: Upload playwright report
404-
uses: actions/upload-artifact@v4
405-
if: always()
406-
with:
407-
name: "playwright-report-${{ inputs.branch }}"
408-
path: playwright-report/
409-
- name: Run Chromatic Playwright
410-
if: ${{ inputs.chromatic_enable }}
411-
uses: chromaui/[email protected]
412-
with:
413-
playwright: true
414-
exitZeroOnChanges: true
415-
exitOnceUploaded: true
416-
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
417-
418-
build-node-python-playwright-redis:
419-
name: Node, Python, Playwright, Redis
420-
if: ${{ inputs.redis_enable && inputs.playwright_enable && (inputs.playwright_run_because_flag || inputs.playwright_run_because_branch == 'true') }}
332+
if: ${{ inputs.playwright_enable && (inputs.playwright_run_because_flag || inputs.playwright_run_because_branch == 'true') }}
421333
concurrency:
422334
group: "node-python-playwright-${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.branch }}"
423335
cancel-in-progress: true

0 commit comments

Comments
 (0)