Integration test (Next.js) #8209
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Integration test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: '0 0 * * *' # end of each day (UTC) | |
| pull_request: | |
| env: | |
| NEXTJS_FOLDER: next-js-test | |
| jobs: | |
| test: | |
| if: ${{ github.repository == 'primer/brand' }} | |
| name: Next.js | |
| runs-on: | |
| labels: ubuntu-latest-16-cores | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24.14.1 | |
| - name: Caching dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| # Restore the previous NPM modules and Cypress binary archives. | |
| # Any updated archives will be saved automatically after the entire | |
| # workflow successfully finishes. | |
| # See https://github.com/actions/cache | |
| - name: Cache Cypress binary | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/Cypress | |
| key: cypress-${{ runner.os }}-cypress-${{ hashFiles('**/package.json') }} | |
| restore-keys: | | |
| cypress-${{ runner.os }}-cypress- | |
| - name: Installing dependencies | |
| run: npm ci | |
| - name: install dependencies and verify Cypress | |
| env: | |
| # make sure every Cypress install prints minimal information | |
| CI: 1 | |
| # print Cypress and OS info | |
| run: | | |
| npx cypress@15.13.0 install --force | |
| npx cypress@15.13.0 verify | |
| npx cypress@15.13.0 info | |
| npx cypress@15.13.0 version | |
| npx cypress@15.13.0 version --component package | |
| npx cypress@15.13.0 version --component binary | |
| npx cypress@15.13.0 version --component electron | |
| npx cypress@15.13.0 version --component node | |
| - name: Build | |
| run: npm run build:lib | |
| - name: Bundling output | |
| run: cd ./packages/react && npm pack | |
| - name: Configuring Next.js | |
| run: yes | npx create-next-app@16.2.2 ${{env.NEXTJS_FOLDER}} --typescript | |
| - name: Retrieving package version | |
| id: package-version | |
| uses: martinbeentjes/npm-get-version-action@3cf273023a0dda27efcd3164bdfb51908dd46a5b # v1.3.1 | |
| with: | |
| path: packages/repo-configs | |
| - name: Installing local build | |
| run: | | |
| cd ${{env.NEXTJS_FOLDER}} | |
| cp ../packages/react/primer-react-brand-${{ steps.package-version.outputs.current-version}}.tgz ./ | |
| npm install primer-react-brand-${{ steps.package-version.outputs.current-version}}.tgz | |
| - name: Prefer ESM imports | |
| run: | | |
| mv ./packages/e2e/integration-tests/fixtures/index.esm.ts ./packages/e2e/integration-tests/fixtures/index.ts | |
| rm ./packages/e2e/integration-tests/fixtures/index.cjs.ts | |
| - name: Copying required files | |
| run: | | |
| rm ./${{env.NEXTJS_FOLDER}}/app/page.tsx | |
| cp ./packages/e2e/integration-tests/nextjs/page.tsx ./${{env.NEXTJS_FOLDER}}/app | |
| - name: Copying required files | |
| run: | | |
| cp ./packages/e2e/integration-tests/nextjs/page.tsx ./${{env.NEXTJS_FOLDER}}/app | |
| cp ./packages/e2e/cypress.config.js ./${{env.NEXTJS_FOLDER}} | |
| mkdir ${{env.NEXTJS_FOLDER}}/integration-tests | |
| cp -r ./packages/e2e/integration-tests/fixtures ./${{env.NEXTJS_FOLDER}}/integration-tests | |
| cp -r ./packages/e2e/integration-tests/tests ./${{env.NEXTJS_FOLDER}}/integration-tests | |
| - name: Excluded cypress tests in-place | |
| # includes temp workaround for cypress bug. remove when fixed | |
| # https://github.com/cypress-io/cypress/issues/27448 | |
| run: npx json@11.0.0 -I -f ${{env.NEXTJS_FOLDER}}/tsconfig.json -e 'this.exclude=["node_modules", "**/*.cy.ts"]; this.compilerOptions.moduleResolution="node"' | |
| - name: Fix monorepo-related linting issues | |
| run: | | |
| npm run lint -- --fix | |
| # Needed to fix compilation errors and conflicts between TS and React type defs. | |
| # All subsequent steps should not be dependent on the primer/brand repo contents. | |
| - name: Clean workspace before testing | |
| run: | | |
| find . -maxdepth 1 -mindepth 1 -not -name ${{env.NEXTJS_FOLDER}} -exec rm -rf {} + | |
| - name: Testing compile-time build | |
| run: cd ${{env.NEXTJS_FOLDER}} && npm run build | |
| - name: Test runtime for errors and warnings | |
| run: cd ${{env.NEXTJS_FOLDER}} && npx start-server-and-test@3.0.0 'start' 3000 'npx cypress@15.13.0 run --spec "./integration-tests/tests/*" --config video=false' |