name: CI - Node.js on: push: branches: - 'main' - 'prod-**' pull_request: branches: - 'main' - 'temp-**' # Temporary branches allowed on Upstream concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.workflow_run.head_branch || github.ref }} cancel-in-progress: ${{ !contains(github.ref, 'main') && !contains(github.ref, 'prod-') }} permissions: contents: read jobs: lint: name: Lint runs-on: ubuntu-24.04 strategy: matrix: node-version: [22] fail-fast: false steps: - name: Checkout uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 with: submodules: 'recursive' - name: Check number of lockfiles run: | if [ $(find . -name 'package-lock.json' | grep -vc -e 'node_modules') -gt 0 ] then echo -e 'Error: found package-lock files in the repository.\nWe use pnpm workspaces to manage packages so all dependencies should be added via pnpm add' exit 1 fi - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6 with: node-version: ${{ matrix.node-version }} - name: Install pnpm uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4 id: pnpm-install with: run_install: false - name: Set Environment variables run: | cp sample.env .env cat .env - name: Install node_modules run: pnpm install - name: Check formatting run: | pnpm prettier --check . || [ $? -eq 1 ] && printf "\nTip: Run 'pnpm run format' in your terminal to fix this.\n\n" # The two prefixed installs are for the client update which are not, # currently, built as workspaces. - name: Lint Source Files run: | echo pnpm version $(pnpm -v) pnpm compile:ts pnpm run build:curriculum pnpm run lint # DONT REMOVE THIS JOB. # TODO: Refactor and use re-usable workflow and shared artifacts build: name: Build needs: lint runs-on: ubuntu-24.04 strategy: matrix: node-version: [22] steps: - name: Checkout uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 with: submodules: 'recursive' - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6 with: node-version: ${{ matrix.node-version }} - name: Install pnpm uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4 id: pnpm-install with: run_install: false - name: Set freeCodeCamp Environment Variables run: | cp sample.env .env - name: Install and Build run: | pnpm install pnpm run build test: name: Test needs: build runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: node-version: [22] steps: - name: Checkout uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 with: submodules: 'recursive' - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6 with: node-version: ${{ matrix.node-version }} - name: Install pnpm uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4 id: pnpm-install with: run_install: false - name: Set Environment variables run: | cp sample.env .env cat .env - name: Start MongoDB run: docker compose -f docker/docker-compose.yml up -d - name: Install Dependencies run: | echo pnpm version $(pnpm -v) pnpm install - name: Install Chrome for Puppeteer run: pnpm -F=curriculum install-puppeteer - name: Run Tests run: pnpm test test-upcoming: name: Test - Upcoming Changes needs: build runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: node-version: [22] steps: - name: Checkout uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 with: submodules: 'recursive' - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6 with: node-version: ${{ matrix.node-version }} - name: Install pnpm uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4 id: pnpm-install with: run_install: false - name: Set Environment variables run: | cp sample.env .env echo 'SHOW_UPCOMING_CHANGES=true' >> .env cat .env - name: Start MongoDB run: docker compose -f docker/docker-compose.yml up -d - name: Install Dependencies run: | echo pnpm version $(pnpm -v) pnpm install - name: Install Chrome for Puppeteer run: pnpm -F=curriculum install-puppeteer - name: Run Tests run: pnpm test test-localization: name: Test - i18n needs: build runs-on: ubuntu-24.04 if: github.event.pull_request.user.login == 'camperbot' && github.head_ref == 'chore/update-i18n-curriculum-submodule' strategy: fail-fast: false matrix: node-version: [22] locale: [portuguese, italian] steps: - name: Checkout uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 with: submodules: 'recursive' - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6 with: node-version: ${{ matrix.node-version }} - name: Install pnpm uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4 id: pnpm-install with: run_install: false - name: Set Environment variables run: | cp sample.env .env cat .env - name: Start MongoDB uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0 with: mongodb-version: 8.0 mongodb-replica-set: test-rs mongodb-port: 27017 - name: Install Dependencies env: CURRICULUM_LOCALE: ${{ matrix.locale }} CLIENT_LOCALE: ${{ matrix.locale }} run: | echo pnpm version $(pnpm -v) pnpm install # DONT REMOVE THIS STEP. # TODO: Refactor and use re-usable workflow and shared artifacts - name: Build Client in ${{ matrix.locale }} env: CURRICULUM_LOCALE: ${{ matrix.locale }} CLIENT_LOCALE: ${{ matrix.locale }} run: | pnpm run build - name: Install Chrome for Puppeteer run: pnpm -F=curriculum install-puppeteer - name: Run Tests env: CURRICULUM_LOCALE: ${{ matrix.locale }} CLIENT_LOCALE: ${{ matrix.locale }} run: pnpm test