langflow/.github/actions/install-playwright/action.yml
Gabriel Luiz Freitas Almeida 87e5b86f48
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
2024-11-25 21:16:30 +00:00

76 lines
2.5 KiB
YAML

name: Install Playwright
description: Install Playwright and dependencies with cache
# https://github.com/microsoft/playwright/issues/7249
inputs:
working-directory:
description: Where to install Playwright
default: ./
browsers:
description: Browsers to install
default: chromium webkit firefox
outputs:
version:
description: Installed version of Playwright
value: ${{ steps.version.outputs.version }}
cache-hit:
description: Whether cache for Playwright was found
value: ${{ steps.cache.outputs.cache-hit }}
runs:
using: composite
steps:
- name: Get Playwright version
uses: actions/github-script@v7
id: version
with:
script: |
const fs = require('fs');
const path = require('path');
// Get working directory
const workingDirectory = "${{ inputs.working-directory }}";
console.debug("Specified working directory:", workingDirectory);
if (workingDirectory) process.chdir(workingDirectory);
console.debug("Actual working directory:", process.cwd());
// Read package.json
let version = "";
try {
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
version = (
packageJson.devDependencies?.['@playwright/test'] ||
packageJson.dependencies?.['@playwright/test'] ||
packageJson.dependencies?.['playwright'] ||
packageJson.devDependencies?.['playwright']
)?.replace(/[\^~]/g, '');
} catch (error) {
console.log(error.message);
}
console.debug("Version:", version);
if (version) {
core.exportVariable("PLAYWRIGHT_VERSION", version);
core.setOutput("version", version);
} else core.setFailed("Couldn't get Playwright version");
- name: Cache Playwright
id: cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Playwright and its dependencies
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{ inputs.working-directory }}
run: npx playwright install ${{ inputs.browsers }} --with-deps
- name: Install just Playwright's dependencies
shell: bash
if: steps.cache.outputs.cache-hit == 'true'
working-directory: ${{ inputs.working-directory }}
run: npx playwright install-deps