Skip to content

Commit

Permalink
ci: improve tests workflow speed (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored Dec 26, 2024
1 parent 0d28e6d commit 3ef12a7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
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

0 comments on commit 3ef12a7

Please sign in to comment.