ci: Update TypeScript test workflow for improved Playwright integration (#4781)

* Update TypeScript test workflow to improve Playwright caching and containerization

- Add container image for Playwright to ensure consistent environment
- Modify Playwright version retrieval to use `npm ls` for accuracy
- Enhance caching strategy with restore keys for Playwright binaries
- Refactor Playwright installation steps to handle dependencies based on cache status

* Remove Playwright container image specification from GitHub Actions workflow

* Add GitHub Action to install Playwright with caching support

- Created a new composite GitHub Action `install-playwright` to install Playwright and its dependencies with caching.
- Updated `typescript_test.yml` workflow to use the new `install-playwright` action, simplifying the installation process and ensuring efficient use of cache.
- The action supports specifying a working directory and selecting browsers to install.

* Remove redundant Playwright caching steps from GitHub Actions workflow

* Update Playwright version extraction logic in GitHub Action

- Modify script to read `package.json` directly for Playwright version.
- Support both `dependencies` and `devDependencies` for version retrieval.
- Remove caret and tilde symbols from version string.

* Optimize Node.js setup and caching in GitHub Actions workflow

* Set UV_CACHE_DIR environment variable in GitHub workflows

* Refactor SignUpPage to import InputComponent from the core components directory

* Set default test suites to an empty array in TypeScript test workflow

* Fix conditional logic in TypeScript test workflow for release builds

* Fix syntax error in conditional statement in GitHub Actions workflow
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-11-25 18:16:30 -03:00 committed by GitHub
commit 87e5b86f48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 93 additions and 41 deletions

View file

@ -33,6 +33,8 @@ jobs:
build:
name: Unit Tests - Python ${{ matrix.python-version }} - Group ${{ matrix.group }}
runs-on: ubuntu-latest
env:
UV_CACHE_DIR: /tmp/.uv-cache
strategy:
matrix:
python-version: ${{ fromJson(inputs.python-versions || '["3.10", "3.11", "3.12"]' ) }}

View file

@ -12,7 +12,7 @@ on:
description: "Test suites to run (JSON array)"
required: false
type: string
default: '["starter-projects", "components", "workspace", "api", "database"]'
default: '[]'
release:
description: "Whether this is a release build"
required: false
@ -81,7 +81,7 @@ jobs:
RELEASE="${{ inputs.release || 'false' }}"
echo "Release build: $RELEASE"
if [[ "$RELEASE" == "true" || "$SUITES" == "[]" ]]; then
if [[ "$RELEASE" == "true" ]]; then
SUITES='["release"]'
echo "Release build detected - setting suites to: $SUITES"
# No grep pattern for release - run all tests
@ -166,13 +166,13 @@ jobs:
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shardTotal: [10]
env:
OPENAI_API_KEY: ${{ inputs.openai_api_key || secrets.OPENAI_API_KEY }}
STORE_API_KEY: ${{ inputs.store_api_key || secrets.STORE_API_KEY }}
SEARCH_API_KEY: "${{ secrets.SEARCH_API_KEY }}"
ASTRA_DB_APPLICATION_TOKEN: "${{ secrets.ASTRA_DB_APPLICATION_TOKEN }}"
ASTRA_DB_API_ENDPOINT: "${{ secrets.ASTRA_DB_API_ENDPOINT }}"
UV_CACHE_DIR: /tmp/.uv-cache
outputs:
failed: ${{ steps.check-failure.outputs.failed }}
steps:
@ -183,50 +183,24 @@ jobs:
# else checkout the default ref
ref: ${{ inputs.ref || github.ref }}
- name: Setup Node.js
- name: Setup Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
id: setup-node
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node.js dependencies
uses: actions/cache@v4
id: npm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('src/frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
cache: "npm"
cache-dependency-path: ./src/frontend/package-lock.json
- name: Install Node.js dependencies
run: |
cd src/frontend
npm ci
if: ${{ steps.setup-node.outputs.cache-hit != 'true' }}
- name: Get Playwright version
run: echo "PLAYWRIGHT_VERSION=$(jq '.devDependencies["@playwright/test"]' src/frontend/package.json -r)" >> $GITHUB_ENV
- name: Cache Playwright binaries
id: playwright-cache
uses: actions/cache@v4
run: npm ci
working-directory: ./src/frontend
- name: Install Playwright
id: install-playwright
uses: ./.github/actions/install-playwright
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ runner.os }}-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Frontend dependencies
run: |
cd src/frontend
npm ci
- name: Install Playwright's browser binaries
run: |
cd src/frontend
npx playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Install Playwright's dependencies
run: |
cd src/frontend
npx playwright install-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: ./src/frontend
browsers: chromium
- name: "Setup Environment"
uses: ./.github/actions/setup-uv