Files
freeCodeCamp/.github/workflows/e2e-web.yml
renovate[bot] dca62c0430 chore(deps): update github actions (#48951)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-07 02:14:22 +00:00

147 lines
4.2 KiB
YAML

name: CI - E2E - Web browser
on:
push:
paths-ignore:
- 'docs/**'
branches-ignore:
- 'renovate/**'
- 'next-api'
pull_request:
paths-ignore:
- 'docs/**'
branches-ignore:
- 'next-api'
jobs:
build-client:
name: Build
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout Source Files
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: Checkout client-config
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
with:
repository: freeCodeCamp/client-config
path: client-config
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: ${{ matrix.node-version }}
- name: Set freeCodeCamp Environment Variables
run: cp sample.env .env
- name: Install and Build
run: |
npm ci
npm run build
- name: Move serve.json to Public Folder
run: cp client-config/serve.json client/public/serve.json
# We tar them for performance reasons - uploading a lot of files is slow.
- name: Tar Files
run: tar -cf client-artifact.tar client/public
- name: Upload Client Artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3
with:
name: client-artifact
path: client-artifact.tar
- name: Upload Webpack Stats
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3
with:
name: webpack-stats
path: client/public/stats.json
cypress-run:
name: Test
runs-on: ubuntu-20.04
needs: build-client
strategy:
fail-fast: false
matrix:
browsers: [chrome, firefox, electron]
node-version: [18.x]
include:
- browsers: electron
spec: cypress/e2e/default/learn/challenges/projects.js
- browsers: chrome
spec: cypress/e2e/default/**/*.{js,ts}
- browsers: firefox
spec: cypress/e2e/default/**/*.{js,ts}
services:
mongodb:
image: mongo:4.4
ports:
- 27017:27017
# We need mailhog to catch any emails the api tries to send.
mailhog:
image: mailhog/mailhog
ports:
- 1025:1025
steps:
- name: Set Action Environment Variables
run: |
echo "CYPRESS_RECORD_KEY=${{ secrets.CYPRESS_RECORD_KEY }}" >> $GITHUB_ENV
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
- name: Checkout Source Files
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
with:
name: client-artifact
- name: Unpack Client Artifact
run: |
tar -xf client-artifact.tar
rm client-artifact.tar
- name: Downgrade Firefox
run: |
curl https://ftp.mozilla.org/pub/firefox/releases/101.0/linux-x86_64/en-US/firefox-101.0.tar.bz2 --output firefox-101.0.tar.bz2
tar -xjf firefox-101.0.tar.bz2
sudo mv firefox /opt/
sudo mv /usr/bin/firefox /usr/bin/firefox_old
sudo ln -s /opt/firefox/firefox /usr/bin/firefox
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: ${{ matrix.node-version }}
- name: Set freeCodeCamp Environment Variables
run: cp sample.env .env
- name: Install and Build
run: |
npm ci
npm run create:config
npm run build:curriculum
npm run build:server
- name: Seed Database
run: npm run seed
- name: Cypress run
uses: cypress-io/github-action@v4
with:
record: ${{ env.CYPRESS_RECORD_KEY != 0 }}
start: npm run start-ci
wait-on: http://localhost:8000
wait-on-timeout: 1200
config: baseUrl=http://localhost:8000
browser: ${{ matrix.browsers }}
spec: ${{ matrix.spec }}