mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-06 06:01:31 -05:00
171 lines
5.5 KiB
YAML
171 lines
5.5 KiB
YAML
# TODO: remove this workflow once we use containers in the other workflows. This
|
|
# workflow is intended to prevent regressions until that has been achieved.
|
|
name: CI - E2E - Containers
|
|
on:
|
|
workflow_dispatch:
|
|
workflow_run:
|
|
workflows: ['CI - Node.js']
|
|
types:
|
|
- completed
|
|
# TODO: refactor with a workflow_call
|
|
pull_request:
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
branches:
|
|
- 'main'
|
|
- 'next-**'
|
|
- 'e2e-**'
|
|
|
|
jobs:
|
|
build-client:
|
|
name: Build Client (Container)
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix:
|
|
node-version: [20.x]
|
|
|
|
steps:
|
|
- name: Checkout Source Files
|
|
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
|
|
|
- name: Create Image
|
|
run: |
|
|
docker build \
|
|
--build-arg HOME_LOCATION=http://localhost:8000 \
|
|
--build-arg API_LOCATION=http://localhost:3000 \
|
|
--build-arg FORUM_LOCATION=https://forum.freecodecamp.org \
|
|
--build-arg NEWS_LOCATION=https://www.freecodecamp.org/news \
|
|
--build-arg RADIO_LOCATION=https://coderadio.freecodecamp.org \
|
|
--build-arg CLIENT_LOCALE=english \
|
|
--build-arg CURRICULUM_LOCALE=english \
|
|
--build-arg SHOW_LOCALE_DROPDOWN_MENU=false \
|
|
--build-arg ALGOLIA_APP_ID=app_id_from_algolia_dashboard \
|
|
--build-arg ALGOLIA_API_KEY=api_key_from_algolia_dashboard \
|
|
--build-arg STRIPE_PUBLIC_KEY=pk_from_stripe_dashboard \
|
|
--build-arg PAYPAL_CLIENT_ID=id_from_paypal_dashboard \
|
|
--build-arg PATREON_CLIENT_ID=id_from_patreon_dashboard \
|
|
--build-arg DEPLOYMENT_ENV=staging \
|
|
--build-arg SHOW_UPCOMING_CHANGES=false \
|
|
--build-arg SHOW_NEW_CURRICULUM=true \
|
|
--build-arg GROWTHBOOK_URI=api_URI_from_Growthbook_dashboard \
|
|
--build-arg FREECODECAMP_NODE_ENV=development \
|
|
-t fcc-client \
|
|
-f docker/web/Dockerfile .
|
|
|
|
- name: Save Image
|
|
run: docker save fcc-client > client-artifact.tar
|
|
|
|
- name: Upload Client Artifact
|
|
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
|
|
with:
|
|
name: client-artifact
|
|
path: client-artifact.tar
|
|
|
|
# TODO: Figure out what to do with the webpack stats file. Create it
|
|
# during the build via a mounted host directory? i.e. docker build -t
|
|
# myimage -v /path/on/host:/output/dir -f Dockerfile . It's important to
|
|
# ensure it doesn't end up in the final image, as it's a large file.
|
|
# - name: Upload Webpack Stats
|
|
# uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3
|
|
# with:
|
|
# name: webpack-stats
|
|
# path: client/public/stats.json
|
|
|
|
build-api:
|
|
name: Build Api (Container)
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix:
|
|
node-version: [20.x]
|
|
|
|
steps:
|
|
- name: Checkout Source Files
|
|
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
|
|
|
- name: Create Image
|
|
run: |
|
|
docker build \
|
|
-t fcc-api \
|
|
-f docker/api/Dockerfile .
|
|
|
|
- name: Save Image
|
|
run: docker save fcc-api > api-artifact.tar
|
|
|
|
- name: Upload Api Artifact
|
|
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
|
|
with:
|
|
name: api-artifact
|
|
path: api-artifact.tar
|
|
|
|
build-new-api:
|
|
name: Build New Api (Container)
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix:
|
|
node-version: [20.x]
|
|
|
|
steps:
|
|
- name: Checkout Source Files
|
|
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
|
|
|
- name: Create Image
|
|
run: |
|
|
docker build \
|
|
-t fcc-new-api \
|
|
-f docker/new-api/Dockerfile .
|
|
|
|
cypress-run:
|
|
name: Test
|
|
runs-on: ubuntu-22.04
|
|
needs: [build-client, build-api]
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# To avoid wasting resources we're only using chrome for now.
|
|
browsers: [chrome]
|
|
node-version: [20.x]
|
|
|
|
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@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
|
|
|
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
|
|
|
|
# Cypress calls some pnpm scripts, so we need to install pnpm.
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
|
|
- name: Install Dependencies
|
|
run: pnpm install
|
|
|
|
- name: Load Images
|
|
run: |
|
|
docker load < client-artifact/client-artifact.tar
|
|
docker load < api-artifact/api-artifact.tar
|
|
|
|
- name: Set freeCodeCamp Environment Variables (needed by api)
|
|
run: cp sample.env .env
|
|
|
|
- name: Cypress run
|
|
uses: cypress-io/github-action@v6
|
|
with:
|
|
record: ${{ env.CYPRESS_RECORD_KEY != 0 }}
|
|
start: docker compose up -d
|
|
wait-on: http://localhost:8000, http://localhost:3000
|
|
wait-on-timeout: 1200
|
|
config: baseUrl=http://localhost:8000
|
|
browser: ${{ matrix.browsers }}
|
|
spec: ${{ matrix.spec }}
|