131 lines
3.6 KiB
YAML
131 lines
3.6 KiB
YAML
name: CI - Cypress (e2e) tests
|
|
on:
|
|
push:
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
branches-ignore:
|
|
- 'renovate/**'
|
|
pull_request:
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
|
|
jobs:
|
|
build-client:
|
|
name: Build
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
- name: Checkout Source Files
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
|
|
|
- name: Checkout client-config
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
|
with:
|
|
repository: freeCodeCamp/client-config
|
|
path: client-config
|
|
|
|
- name: Use Node.js 16.x
|
|
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # tag=v3
|
|
with:
|
|
node-version: 16.x
|
|
cache: 'npm'
|
|
|
|
- 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@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3
|
|
with:
|
|
name: client-artifact
|
|
path: client-artifact.tar
|
|
|
|
- name: Upload Webpack Stats
|
|
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=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: [16.x]
|
|
include:
|
|
- browsers: electron
|
|
spec: cypress/integration/learn/challenges/projects.js
|
|
services:
|
|
mongodb:
|
|
image: mongo: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@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
|
|
|
- uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # tag=v3
|
|
with:
|
|
name: client-artifact
|
|
|
|
- name: Unpack Client Artifact
|
|
run: |
|
|
tar -xf client-artifact.tar
|
|
rm client-artifact.tar
|
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # tag=v3
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: 'npm'
|
|
|
|
- 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@v2
|
|
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 }}
|
|
headless: true
|
|
spec: ${{ matrix.spec }}
|