Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: improve tests workflow speed #686

Merged
merged 4 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 15 additions & 30 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,43 @@ jobs:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-interval 5s
--health-timeout 5s
--health-retries 5
--health-retries 3

steps:
- uses: actions/checkout@v4
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache Playwright binaries
uses: actions/cache@v4
id: playwright-cache
- uses: actions/setup-node@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install dependencies
node-version: 21
cache: "npm"
- name: Setup application
run: npm ci
- name: Install Playwright
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium

- name: Start backend
- name: Start backend and frontend
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_db
JWT_SECRET: ${{ secrets.JWT_SECRET }}
APP_URL: http://0.0.0.0:8080
API_URL: http://0.0.0.0:3333
LUNARY_PUBLIC_KEY: 259d2d94-9446-478a-ae04-484de705b522
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
timeout-minutes: 1
run: npm run migrate:db && npm run start:backend & npx wait-on http://localhost:3333/v1/health
- name: Start frontend
env:
API_URL: http://0.0.0.0:3333
NEXT_PUBLIC_API_URL: http://0.0.0.0:3333
timeout-minutes: 3
run: (npm run dev:frontend) & npx wait-on http://0.0.0.0:8080/
run: |
npm run migrate:db
npm run start:backend &
npm run dev:frontend &
npx wait-on http://localhost:3333/v1/health http://0.0.0.0:8080/

- name: Run tests
run: npx playwright test
env:
BASE_URL: http://0.0.0.0:8080
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_db

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default defineConfig({
projects: [
{ name: "setup", testMatch: "auth.setup.ts" },
{
// Projects tests need to be ran before all other tests to avoid project mismatches.
// Projects related tests need to be ran before all other tests to avoid project mismatches.
name: "projects",
testMatch: "projects.setup.ts",
use: {
Expand Down
Loading