2021-06-14 18:14:43 +00:00
|
|
|
name: Cypress
|
2021-05-07 14:30:38 +00:00
|
|
|
on:
|
2021-06-14 18:14:43 +00:00
|
|
|
push:
|
|
|
|
branches-ignore:
|
|
|
|
- 'renovate/**'
|
2021-05-06 04:33:06 +00:00
|
|
|
pull_request:
|
2020-08-08 20:11:56 +00:00
|
|
|
|
2020-04-21 08:11:20 +00:00
|
|
|
jobs:
|
2021-08-25 16:18:31 +00:00
|
|
|
build-client:
|
|
|
|
name: Build
|
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout Source Files
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Checkout client-config
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
repository: freeCodeCamp/client-config
|
|
|
|
path: client-config
|
|
|
|
|
|
|
|
- name: Use Node.js 14.x
|
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: 14.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@v2
|
|
|
|
with:
|
|
|
|
name: client-artifact
|
|
|
|
path: client-artifact.tar
|
|
|
|
|
|
|
|
- name: Upload Webpack Stats
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: webpack-stats
|
|
|
|
path: client/public/stats.json
|
|
|
|
|
|
|
|
|
2020-04-21 08:11:20 +00:00
|
|
|
cypress-run:
|
2020-08-10 20:37:19 +00:00
|
|
|
name: Test
|
2020-07-27 12:36:58 +00:00
|
|
|
runs-on: ubuntu-18.04
|
2021-08-25 16:18:31 +00:00
|
|
|
needs: build-client
|
2020-09-14 07:07:00 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-08-25 16:18:31 +00:00
|
|
|
browsers: [chrome, firefox, electron]
|
2021-03-26 11:37:02 +00:00
|
|
|
node-version: [14.x]
|
2021-08-25 16:18:31 +00:00
|
|
|
include:
|
|
|
|
- browsers: electron
|
|
|
|
spec: cypress/integration/learn/challenges/projects.js
|
2020-04-21 08:11:20 +00:00
|
|
|
services:
|
|
|
|
mongodb:
|
2020-08-08 18:09:03 +00:00
|
|
|
image: mongo:3.6.19
|
2020-04-21 08:11:20 +00:00
|
|
|
ports:
|
|
|
|
- 27017:27017
|
2021-05-07 14:30:38 +00:00
|
|
|
# We need mailhog to catch any emails the api tries to send.
|
|
|
|
mailhog:
|
|
|
|
image: mailhog/mailhog
|
|
|
|
ports:
|
|
|
|
- 1025:1025
|
2020-08-08 18:09:03 +00:00
|
|
|
|
2020-04-21 08:11:20 +00:00
|
|
|
steps:
|
2021-03-10 19:56:07 +00:00
|
|
|
# We use .npmrc to set the default version to 0, and prevents download during development.
|
2020-10-13 11:52:06 +00:00
|
|
|
# This installs it specifically in the CI runs.
|
|
|
|
- name: Set Action Environment Variables
|
|
|
|
run: |
|
|
|
|
echo "CYPRESS_RECORD_KEY=${{ secrets.CYPRESS_RECORD_KEY }}" >> $GITHUB_ENV
|
|
|
|
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
|
2021-08-24 18:26:48 +00:00
|
|
|
echo "CYPRESS_INSTALL_BINARY=7.7.0" >> $GITHUB_ENV
|
2020-10-13 11:52:06 +00:00
|
|
|
|
2020-08-08 18:09:03 +00:00
|
|
|
- name: Checkout Source Files
|
2020-06-09 20:17:13 +00:00
|
|
|
uses: actions/checkout@v2
|
2020-04-21 08:11:20 +00:00
|
|
|
|
2021-08-25 16:18:31 +00:00
|
|
|
- uses: actions/download-artifact@v2
|
2021-08-14 02:57:13 +00:00
|
|
|
with:
|
2021-08-25 16:18:31 +00:00
|
|
|
name: client-artifact
|
|
|
|
|
|
|
|
- name: Unpack Client Artifact
|
|
|
|
run: |
|
|
|
|
tar -xf client-artifact.tar
|
|
|
|
rm client-artifact.tar
|
2021-08-14 02:57:13 +00:00
|
|
|
|
2020-08-08 18:09:03 +00:00
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
2021-03-10 19:56:07 +00:00
|
|
|
uses: actions/setup-node@v2
|
2020-08-08 18:09:03 +00:00
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node-version }}
|
2021-07-03 13:09:25 +00:00
|
|
|
cache: 'npm'
|
2020-09-24 17:51:45 +00:00
|
|
|
|
2020-10-13 11:52:06 +00:00
|
|
|
- name: Set freeCodeCamp Environment Variables
|
2020-04-21 08:11:20 +00:00
|
|
|
run: cp sample.env .env
|
2020-06-09 20:17:13 +00:00
|
|
|
|
2021-08-25 16:18:31 +00:00
|
|
|
- name: Install and Build
|
2020-08-08 18:09:03 +00:00
|
|
|
run: |
|
|
|
|
npm ci
|
|
|
|
npm run ensure-env
|
2021-08-25 16:18:31 +00:00
|
|
|
npm run build:curriculum
|
|
|
|
npm run build:server
|
2021-08-14 02:57:13 +00:00
|
|
|
|
2020-08-08 18:09:03 +00:00
|
|
|
- name: Seed Database
|
|
|
|
run: npm run seed
|
|
|
|
|
2020-04-21 08:11:20 +00:00
|
|
|
- name: Cypress run
|
2020-11-17 11:22:15 +00:00
|
|
|
uses: cypress-io/github-action@v2
|
2020-04-21 08:11:20 +00:00
|
|
|
with:
|
2020-05-07 09:56:18 +00:00
|
|
|
record: ${{ env.CYPRESS_RECORD_KEY != 0 }}
|
2021-02-25 20:02:35 +00:00
|
|
|
start: npm run start-ci
|
2020-04-21 08:11:20 +00:00
|
|
|
wait-on: http://localhost:8000
|
|
|
|
wait-on-timeout: 1200
|
|
|
|
config: baseUrl=http://localhost:8000
|
2020-09-14 07:07:00 +00:00
|
|
|
browser: ${{ matrix.browsers }}
|
|
|
|
headless: true
|
2021-08-25 16:18:31 +00:00
|
|
|
spec: ${{ matrix.spec }}
|