Skip to content

Commit

Permalink
Code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dottxado committed Feb 6, 2025
1 parent 0e57b05 commit bb71a77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/test-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ on:
type: number
default: 30
required: false
COMPOSER_DEPS_INSTALL:
description: Whether to install Composer dependencies.
type: boolean
default: false
required: false
NODE_VERSION:
description: Node version with which the node script will be executed.
default: 18
Expand All @@ -39,7 +44,7 @@ on:
type: string
PHP_VERSION:
description: PHP version with which the dependencies are installed.
default: ''
default: '8.2'
required: false
type: string
PLAYWRIGHT_BROWSER_ARGS:
Expand Down Expand Up @@ -98,14 +103,8 @@ jobs:
git config --global user.email "${{ env.GITHUB_USER_EMAIL }}"
git config --global user.name "${{ env.GITHUB_USER_NAME }}"
- name: Check if PHP installation is needed
run: |
if [ "${{ hashFiles('composer.json') }}" != "" ] && [ "${{ inputs.PHP_VERSION }}" != "" ]; then
echo "PHP_CHECK=true" >> $GITHUB_ENV
fi
- name: Set up PHP
if: ${{ env.PHP_CHECK == 'true' }}
if: ${{ input.COMPOSER_DEPS_INSTALL == 'true' }}

Check failure on line 107 in .github/workflows/test-playwright.yml

View workflow job for this annotation

GitHub Actions / actionlint

undefined variable "input". available variables are "env", "github", "inputs", "job", "matrix", "needs", "runner", "secrets", "steps", "strategy", "vars"

Check failure on line 107 in .github/workflows/test-playwright.yml

View workflow job for this annotation

GitHub Actions / actionlint

undefined variable "input". available variables are "env", "github", "inputs", "job", "matrix", "needs", "runner", "secrets", "steps", "strategy", "vars"
uses: shivammathur/setup-php@v2
env:
COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}'
Expand All @@ -115,7 +114,7 @@ jobs:
coverage: none

- name: Install Composer dependencies
if: ${{ env.PHP_CHECK == 'true' }}
if: ${{ input.COMPOSER_DEPS_INSTALL == 'true' }}

Check failure on line 117 in .github/workflows/test-playwright.yml

View workflow job for this annotation

GitHub Actions / actionlint

undefined variable "input". available variables are "env", "github", "inputs", "job", "matrix", "needs", "runner", "secrets", "steps", "strategy", "vars"

Check failure on line 117 in .github/workflows/test-playwright.yml

View workflow job for this annotation

GitHub Actions / actionlint

undefined variable "input". available variables are "env", "github", "inputs", "job", "matrix", "needs", "runner", "secrets", "steps", "strategy", "vars"
uses: ramsey/composer-install@v3
with:
composer-options: '--prefer-dist'
Expand All @@ -141,12 +140,11 @@ jobs:
run: |
touch .env.ci
echo "${{ secrets.ENV_FILE_DATA }}" >> .env.ci
# Ensure .env.ci is deleted on exit
trap 'rm -f .env.ci' EXIT
npm run ${{ inputs.SCRIPT_NAME }}
- name: Remove .env.ci file
run: |
rm .env.ci
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
Expand Down
15 changes: 6 additions & 9 deletions docs/test-playwright.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# Playwright test

This workflow executes Playwright-based tests in a controlled and isolated environment via GitHub
Actions.
This workflow executes Playwright-based tests in a controlled and isolated environment via GitHub Actions.

The workflow can:

- execute a building step, both for node and PHP environments (if the PHP version is provided and
a `composer.json` file is present)
- create an environment variables file named `.env.ci` dedicated to the test step; load this file
using `dotenv-ci` directly in your test script,
e.g., `./node_modules/.bin/dotenv -e .env.ci -- npm run e2e`
- execute a building step, both for node and PHP environments (if the PHP version is provided and a `composer.json` file is present)
- create an environment variables file named `.env.ci` dedicated to the test step; load this file using `dotenv-ci` directly in your test script, e.g., `./node_modules/.bin/dotenv -e .env.ci -- npm run e2e`
- execute the tests using Playwright
- upload the artifacts

Expand All @@ -34,11 +30,12 @@ jobs:
| Name | Default | Description |
|---------------------------------|---------------------------------|---------------------------------------------------------------------------------------------------|
| `ARTIFACT_INCLUDE_HIDDEN_FILES` | `false` | Whether to include hidden files in the provided path in the artifact |
| `ARTIFACT_INCLUDE_HIDDEN_FILES` | `false` | Whether to include hidden files in the artifact |
| `ARTIFACT_NAME` | `'artifact'` | Name for the artifact |
| `ARTIFACT_OVERWRITE` | `false` | Determine if an artifact with a matching name will be deleted before a new one is uploaded or not |
| `ARTIFACT_PATH` | | A file, directory or wildcard pattern that describes what to upload |
| `ARTIFACT_RETENTION_DAYS` | `30` | Duration after which artifact will expire in day |
| `COMPOSER_DEPS_INSTALL` | `false` | Whether to install Composer dependencies. |
| `NODE_VERSION` | `18` | Node version with which the node script will be executed |
| `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry |
| `PHP_VERSION` | | PHP version with which the dependencies are installed |
Expand All @@ -55,7 +52,6 @@ jobs:
| `GITHUB_USER_EMAIL` | Email address for the GitHub user configuration |
| `GITHUB_USER_NAME` | Username for the GitHub user configuration |
| `GITHUB_USER_SSH_KEY` | Private SSH key associated with the GitHub user passed as `GITHUB_USER_NAME` |
| `ENV_VARS` | Additional environment variables as a JSON formatted object |

**Example with configuration parameters:**

Expand All @@ -76,6 +72,7 @@ jobs:
playwright-report/
ARTIFACT_INCLUDE_HIDDEN_FILES: true
SCRIPT_NAME: 'ci-test-e2e'
COMPOSER_DEPS_INSTALL: true
PHP_VERSION: ${{ matrix.php }}
NODE_VERSION: 20
PLAYWRIGHT_BROWSER_ARGS: 'chromium --with-deps'
Expand Down

0 comments on commit bb71a77

Please sign in to comment.