diff --git a/.github/workflows/build-node-python.yml b/.github/workflows/build-node-python.yml index 95f360bf..6afda2d7 100644 --- a/.github/workflows/build-node-python.yml +++ b/.github/workflows/build-node-python.yml @@ -23,6 +23,22 @@ on: type: string required: false default: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || !!startsWith(github.ref, 'refs/heads/release-') }} + playwright_enable: + description: "Global enable for playwright" + type: boolean + required: false + default: false + playwright_run_because_flag: + description: "Local flag to run playwright. Will only work if playwright_enable: true." + type: boolean + required: false + default: false + playwright_run_because_branch: + description: "Branch names to run playwright on. Will only work if playwright_enable: true." + # TODO: actionlint is failing as it expects true/false as default value for boolean types + type: string + required: false + default: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || !!startsWith(github.ref, 'refs/heads/release-') }} node_run_webpack: description: "Flag to always run the webpack production build." type: boolean @@ -36,6 +52,10 @@ on: type: string required: false default: "ubuntu-22.04-large" + playwright_runs_on: + type: string + required: false + default: "ubuntu-22.04-large" secrets: DATAVISYN_BOT_REPO_TOKEN: required: false @@ -63,7 +83,7 @@ permissions: jobs: build-node: name: Node - if: ${{ !inputs.cypress_enable || (!inputs.cypress_run_because_flag && inputs.cypress_run_because_branch != 'true') }} + 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')) }} concurrency: group: "node-${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.branch }}" cancel-in-progress: true @@ -93,7 +113,7 @@ jobs: build-python: name: Python - if: ${{ !inputs.cypress_enable || (!inputs.cypress_run_because_flag && inputs.cypress_run_because_branch != 'true') }} + 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')) }} concurrency: group: "python-${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.branch }}" cancel-in-progress: true @@ -211,3 +231,76 @@ jobs: # with: # name: cypress-videos # path: cypress/videos + + # If playwright is used, build node and python sequentially as it is avoiding the duplicate install overhead + build-node-python-playwright: + name: Node, Python, Playwright + 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 }} + + 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 + ports: + - 5432:5432 + + steps: + - name: Checkout source repository + uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch }} + token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }} + - name: Checkout github-workflows + uses: actions/checkout@v3 + with: + repository: datavisyn/github-workflows + ref: ${{ env.WORKFLOW_BRANCH }} + path: ./tmp/github-workflows + - name: Build node + uses: ./tmp/github-workflows/.github/actions/build-node + with: + node_version: ${{ secrets.NODE_VERSION || env.NODE_VERSION }} + npm_registry: ${{ env.NPM_REGISTRY }} + github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }} + 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 + - name: Build python + uses: ./tmp/github-workflows/.github/actions/build-python + with: + python_version: ${{ secrets.PYTHON_VERSION || env.PYTHON_VERSION }} + github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.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: Webpack build + run: npm run webpack:prod + shell: bash + - name: Install playwright browsers + run: yarn playwright install --with-deps chromium + shell: bash + - name: Run playwright e2e tests + run: yarn run pw:run + shell: bash + - name: Upload playwright report + uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/