Skip to content

chore: add e2e tests #5153

chore: add e2e tests

chore: add e2e tests #5153

Workflow file for this run

name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main, next and v1 branches
on:
push:
branches:
- main
- next
- v1
paths-ignore:
- '**/docs/**'
- '**.md'
pull_request:
types: [opened, synchronize, reopened, edited, ready_for_review]
paths-ignore:
- '**/docs/**'
- '**.md'
concurrency: ci-${{ github.ref }}
jobs:
# This job will run the minimal checks: linting, unit tests and type checking.
BasicChecks:
name: Basic Checks
runs-on: ubuntu-latest
# Do not run if the pull request is a draft
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '20'
scope: '@farfetch'
cache: 'yarn'
always-auth: true
- name: Install dependencies
run: yarn install --ignore-engines --frozen-lockfile
- name: Lint
run: yarn lint
- name: Unit Tests
run: yarn test --ci
- name: Type checking
run: yarn ci:types
# This job will run integration tests, possibly only the critical ones if the branch is master or next
IntegrationTests:
name: Integration Tests
runs-on: ubuntu-latest
env:
PROXY_TARGET: ${{ secrets.E2E_TESTS_PROXY_TARGET }}
TEST_ACCOUNT_USERNAME: ${{ secrets.E2E_TESTS_ACCOUNT_USERNAME }}
TEST_ACCOUNT_PASSWORD: ${{ secrets.E2E_TESTS_ACCOUNT_PASSWORD }}
# Do not run if the pull request is a draft
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '20'
scope: '@farfetch'
cache: 'yarn'
always-auth: true
- name: Install dependencies
run: yarn install --ignore-engines --frozen-lockfile
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Update version and build packages
run: yarn ci:release --dry-run && yarn build && yarn build:copy-package-json
- name: Build test application
run: yarn test:e2e:build
- name: Setup host alias
run: |
sudo echo "127.0.0.1 development.blackandwhite-ff.com" | sudo tee -a /etc/hosts
- name: Start server
run: yarn test:e2e:server &
- name: Sleep to wait for server to start
run: sleep 5
- name: Run critical tests
run: yarn test:e2e:run:critical
- name: Run non critical tests
if: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/next' }}
run: yarn test:e2e:run:non-critical
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: tests/e2e/report
retention-days: 30
# This will make a release after the dependant checks are finished and
# it is in a branch that allows publishing (master and next).
Release:
runs-on: ubuntu-latest
# Do not run if the pull request is a draft
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }}
needs: [BasicChecks, IntegrationTests]
steps:
# Use fetch-depth: 0 so that all tags and branches are fetched
# Use persist-credentials: false so that the make release step uses another personal access
# token which has admin access and can push the version commit without the restriction
# of creating a pull-request.
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '20'
scope: '@farfetch'
cache: 'yarn'
always-auth: true
# This is needed for lerna to commit and push the
# new version when making a release
- name: Checkout the source branch in a pull request for lerna
env:
HEAD_REF: ${{ github.head_ref }}
if: ${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'rc/') }}
run: git checkout "$HEAD_REF"
# This is needed for lerna to commit and push the
# new version when making a release
- name: Checkout the branch for pushes to a branch for lerna
env:
REF_NAME: ${{ github.ref_name }}
if: ${{ github.event_name == 'push' }}
run: git checkout "$REF_NAME"
# Retrieves the commit message to be used in the
# make release step
- name: Get commit message
id: get-commit-message
run: |
COMMIT_MSG=$(git log -1 --pretty=format:"%s")
echo "Commit message is: ${COMMIT_MSG})"
echo ::set-output name=message::${COMMIT_MSG}
- name: Install dependencies
run: yarn install --ignore-engines --frozen-lockfile
# Only make a release if it is a run of the 'main' or 'next' branches
# or a pull request that contains a 'chore: make release' message
- name: Make release
if: |
github.ref_name == 'main' ||
github.ref_name == 'next'
env:
MAKE_RELEASE_COMMIT_MESSAGE: 'chore: make release'
PUBLISH_COMMIT_MESSAGE: 'chore: publish [skip build]'
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.RELEASE_BOT_GIT_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.RELEASE_BOT_GIT_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.RELEASE_BOT_GIT_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.RELEASE_BOT_GIT_EMAIL }}
run: yarn ci:release