diff --git a/.github/workflows/build-node-python.yml b/.github/workflows/build-node-python.yml index 0136d13a..20d2d2fb 100644 --- a/.github/workflows/build-node-python.yml +++ b/.github/workflows/build-node-python.yml @@ -409,3 +409,123 @@ jobs: exitZeroOnChanges: true exitOnceUploaded: true projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + + build-node-python-playwright-redis: + name: Node, Python, Playwright, Redis + if: ${{ inputs.playwright_enable && (inputs.playwright_run_because_flag || inputs.playwright_run_because_branch == 'true') }} + concurrency: + group: "node-python-playwright-${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.branch }}" + cancel-in-progress: true + permissions: + id-token: write + contents: write + runs-on: ${{ inputs.playwright_runs_on || inputs.runs_on || 'ubuntu-22.04-large' }} + + services: + postgres: + image: postgres:14 + env: + POSTGRES_USER: admin + POSTGRES_PASSWORD: admin + POSTGRES_DB: db + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + --name postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }} + ports: + # will assign a random free host port + - 5432/tcp + + redis: + image: redis:6 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + --name redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }} + ports: + - 6379/tcp + + steps: + - name: Set system env variable to github env + run: echo "GH_ACTIONS_SELF_HOSTED_NETWORK_NAME=${GH_ACTIONS_SELF_HOSTED_NETWORK_NAME}" >> "$GITHUB_ENV" + - name: Set github token, hostname, port and docker network for self-hosted runner + if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME != '' + run: | + { + echo "POSTGRES_HOSTNAME=postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}" + echo "POSTGRES_PORT=5432" + echo "REDIS_HOSTNAME=redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}" + echo "REDIS_PORT=6379" + } >> "$GITHUB_ENV" + docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.POSTGRES_HOSTNAME }} + docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.REDIS_HOSTNAME }} + + - name: Set service connection details to hosted runner + if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME == '' + run: | + echo "POSTGRES_HOSTNAME=localhost" >> "$GITHUB_ENV" + echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}" >> "$GITHUB_ENV" + echo "REDIS_HOSTNAME=localhost" >> "$GITHUB_ENV" + echo "REDIS_PORT=${{ job.services.redis.ports['6379'] }}" >> "$GITHUB_ENV" + - name: Checkout source repository + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }} + fetch-depth: ${{ inputs.chromatic_enable && '0' || '1' }} + - name: Checkout github-workflows + uses: actions/checkout@v4 + with: + repository: datavisyn/github-workflows + ref: ${{ env.WORKFLOW_BRANCH }} + path: ./tmp/github-workflows + - name: Build node and python + uses: ./tmp/github-workflows/.github/actions/build-node-python + with: + run_parallel: ${{ inputs.run_parallel }} + node_version: ${{ secrets.NODE_VERSION || env.NODE_VERSION }} + npm_registry: ${{ env.NPM_REGISTRY }} + python_version: ${{ secrets.PYTHON_VERSION || env.PYTHON_VERSION }} + github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }} + 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 + run_playwright_browser_install: true + enable_node_cache: ${{ inputs.playwright_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }} + enable_python_cache: ${{ inputs.playwright_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }} + chromatic_enable: false # Set to false as we run chromatic below w/ playwright integration + chromatic_project_token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + - name: Decrypt .env.enc and /.env.enc + run: | + yarn run env:decrypt -pass env:ENV_PASSWORD || true + make env_decrypt || true + env: + ENV_PASSWORD: ${{ secrets.ENV_PASSWORD }} + - name: Bundle build + run: yarn run bundle:prod || yarn run webpack:dev + shell: bash + - name: Run playwright e2e tests + run: yarn run pw:run ${{ inputs.playwright_spec_param }} + shell: bash + - name: Upload bundle + uses: actions/upload-artifact@v4 + if: always() + with: + name: "bundles-${{ inputs.branch }}" + path: bundles/ + - name: Upload playwright report + uses: actions/upload-artifact@v4 + if: always() + with: + name: "playwright-report-${{ inputs.branch }}" + path: playwright-report/ + - name: Run Chromatic Playwright + if: ${{ inputs.chromatic_enable }} + uses: chromaui/action@v11.12.1 + with: + playwright: true + exitZeroOnChanges: true + exitOnceUploaded: true + projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}