-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: refactor CI workflow and update test scripts (#314)
### TL;DR Updated CI workflows, test scripts, and environment configurations to improve the development and testing process. ### What changed? - Added a new reusable GitHub Action for setup and installation - Created a new comprehensive CI workflow (ci.yml) replacing the old main.yml - Updated the Chromatic workflow for visual regression testing - Modified test scripts in package.json for better organization and clarity - Updated the .env.test file to use quotes for the DATABASE_URL - Updated the load test README with the correct build command ### How to test? 1. Review the new CI workflow in .github/workflows/ci.yml 2. Run the updated test scripts locally: - `npm run test:vitest` for unit and integration tests - `npm run test:e2e` for end-to-end tests 3. Verify that the Chromatic workflow runs correctly on pull requests 4. Check that the load test build command works: `npm run load-test:build` ### Why make this change? These changes aim to: - Streamline the CI process with a more comprehensive and organized workflow - Improve test script naming and execution for better developer experience - Ensure consistent setup across different GitHub Actions - Enhance the reliability and efficiency of the testing and deployment pipeline
- Loading branch information
Showing
7 changed files
with
121 additions
and
80 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: 'Setup and install' | ||
description: 'Common setup steps for Actions' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'npm' | ||
|
||
- shell: bash | ||
run: npm ci | ||
|
||
# Add more steps here as needed |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
# add more branches here for this job to run on | ||
# - staging | ||
# - production | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
install: | ||
name: Install dependencies | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
- name: Lint | ||
run: npm run lint | ||
|
||
unit-integration-tests: | ||
name: Unit & integration tests | ||
needs: | ||
- install | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
- name: Test | ||
run: npm run test:vitest | ||
|
||
end-to-end-tests: | ||
name: End-to-end tests | ||
needs: | ||
- install | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
- name: Install Playwright (Chromium) | ||
run: npx playwright install chromium | ||
- name: Load .env file | ||
uses: xom9ikk/dotenv@v2 | ||
with: | ||
mode: test | ||
- name: Next.js cache | ||
uses: actions/cache@v4 | ||
with: | ||
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node | ||
path: | | ||
~/.npm | ||
${{ github.workspace }}/.next/cache | ||
# Generate a new cache whenever packages or source files change. | ||
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | ||
# If source files changed but packages didn't, rebuild from a prior cache. | ||
restore-keys: | | ||
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | ||
- name: Start test containers | ||
run: npm run setup:test | ||
|
||
- name: Build app | ||
run: npm run build | ||
|
||
- name: Run Playwright tests | ||
run: npm run test-ci:e2e | ||
|
||
- name: Stop test containers | ||
run: npm run teardown | ||
|
||
- name: Upload test results | ||
if: ${{ !cancelled() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: playwright-report | ||
path: playwright/test-results/ | ||
retention-days: 7 |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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