|
81 | 81 | required: false |
82 | 82 | type: boolean |
83 | 83 | default: false |
84 | | - redis_enable: |
85 | | - description: 'Enable Redis service' |
86 | | - required: false |
87 | | - type: boolean |
88 | | - default: false |
89 | 84 |
|
90 | 85 | secrets: |
91 | 86 | DATAVISYN_BOT_REPO_TOKEN: |
@@ -220,23 +215,43 @@ jobs: |
220 | 215 | ports: |
221 | 216 | # will assign a random free host port |
222 | 217 | - 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 | + |
224 | 229 | steps: |
225 | 230 | - name: Set self-hosted env variable to github env |
226 | 231 | 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 |
228 | 233 | 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: | |
230 | 238 | { |
231 | 239 | echo "POSTGRES_HOSTNAME=postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}" |
232 | 240 | 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" |
233 | 243 | } >> "$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 |
236 | 247 | if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME == '' |
237 | 248 | 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" |
240 | 255 | - name: Checkout source repository |
241 | 256 | uses: actions/checkout@v4 |
242 | 257 | with: |
@@ -314,110 +329,7 @@ jobs: |
314 | 329 | # If playwright is used, build node and python sequentially as it is avoiding the duplicate install overhead |
315 | 330 | build-node-python-playwright: |
316 | 331 | 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 | | - |
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') }} |
421 | 333 | concurrency: |
422 | 334 | group: "node-python-playwright-${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.branch }}" |
423 | 335 | cancel-in-progress: true |
|
0 commit comments