-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor E2E tests in CI #730
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
Open
markspolakovs
wants to merge
5
commits into
main
Choose a base branch
from
mp/ci-test-refactor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+103
−74
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4c7adee
Refactor E2E tests in CI
markspolakovs 4282543
Don't push, but do build server/jobrunner
markspolakovs c01c38b
Fix image tags
markspolakovs 339f8ed
Wrong quoting
markspolakovs c77b783
Make some test assertions exact
markspolakovs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: Run Test Services | ||
| description: Imports built Docker images, starts docker-compose-test, and migrates database | ||
| inputs: | ||
| image-from-artifacts: | ||
| description: If true, download images from GHA artifacts | ||
| docker-tag: | ||
| description: Docker tag of Server/Jobrunner | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Download built images | ||
| if: ${{ inputs.image-from-artifacts == 'true' }} | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: docker-* | ||
| path: /tmp | ||
| merge-multiple: true | ||
|
|
||
| - name: Import images | ||
| if: ${{ inputs.image-from-artifacts == 'true' }} | ||
| run: for f in /tmp/*.tar; do docker load -i $f; done | ||
| shell: bash | ||
|
|
||
| - name: Set ref in docker-compose | ||
| run: sed -i "s/__RC_REF__/${{ inputs.docker-tag }}/g" docker-compose-test.yml | ||
| shell: bash | ||
|
|
||
| - name: Docker Compose | ||
| uses: hoverkraft-tech/[email protected] | ||
| with: | ||
| compose-file: | | ||
| docker-compose.yml | ||
| docker-compose-test.yml | ||
|
|
||
| - name: Migrate database | ||
| run: | | ||
| yarn prisma:migrateProd | ||
| shell: bash | ||
|
|
||
| - name: Restart services | ||
| run: | | ||
| docker compose -f docker-compose.yml -f docker-compose-test.yml restart server jobrunner | ||
| shell: bash |
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,10 @@ on: | |||||
| type: string | ||||||
| required: true | ||||||
| description: Version to build, also the docker tag | ||||||
| build: | ||||||
| type: string | ||||||
| default: desktop,server,jobrunner | ||||||
| description: Comma-separated list of builds to run | ||||||
| strip_rc: | ||||||
| type: boolean | ||||||
| description: Strip -rc suffix from version number | ||||||
|
|
@@ -20,13 +24,19 @@ on: | |||||
| type: boolean | ||||||
| default: false | ||||||
| description: Build multi-arch docker images | ||||||
| export_artifacts: | ||||||
| type: boolean | ||||||
| default: true | ||||||
| # https://docs.docker.com/build/ci/github-actions/share-image-jobs/ | ||||||
| description: Export images to GitHub Actions artifacts | ||||||
|
|
||||||
| permissions: | ||||||
| contents: read | ||||||
| packages: write | ||||||
|
|
||||||
| jobs: | ||||||
| build-desktop-windows: | ||||||
| if: ${{ contains(inputs.build, 'desktop') }} | ||||||
| runs-on: windows-latest | ||||||
| strategy: | ||||||
| matrix: | ||||||
|
|
@@ -75,7 +85,7 @@ jobs: | |||||
|
|
||||||
| build-docker-server: | ||||||
| runs-on: ubuntu-latest | ||||||
| if: ${{ inputs.push_docker == true }} | ||||||
| if: ${{ contains(inputs.build, 'server') }} | ||||||
|
|
||||||
| steps: | ||||||
| - uses: actions/checkout@v4 | ||||||
|
|
@@ -110,17 +120,25 @@ jobs: | |||||
| uses: docker/build-push-action@v6 | ||||||
| with: | ||||||
| context: . | ||||||
| push: true | ||||||
| push: ${{ inputs.push_docker }} | ||||||
| tags: ${{ steps.meta.outputs.tags }} | ||||||
| labels: ${{ steps.meta.outputs.labels }} | ||||||
| platforms: ${{ inputs.multi_arch && 'linux/amd64,linux/arm64' || 'linux/amd64' }} | ||||||
| cache-from: type=gha | ||||||
| cache-to: type=gha,mode=max | ||||||
| outputs: ${{ inputs.export_artifacts && 'type=docker,dest=/tmp/server.tar' || '' }} | ||||||
| file: Dockerfile.server | ||||||
|
|
||||||
| - name: Upload to artifacts | ||||||
| if: ${{ inputs.export_artifacts }} | ||||||
| uses: actions/upload-artifact@v4 | ||||||
| with: | ||||||
| name: docker-server | ||||||
| path: /tmp/server.tar | ||||||
|
|
||||||
| build-docker-jobrunner: | ||||||
| runs-on: ubuntu-latest | ||||||
| if: ${{ inputs.push_docker == true }} | ||||||
| if: ${{ contains(inputs.build, 'jobrunner') }} | ||||||
|
|
||||||
| steps: | ||||||
| - uses: actions/checkout@v4 | ||||||
|
|
@@ -154,10 +172,18 @@ jobs: | |||||
| uses: docker/build-push-action@v6 | ||||||
| with: | ||||||
| context: . | ||||||
| push: true | ||||||
| push: ${{ inputs.push_docker }} | ||||||
| tags: ${{ steps.jr_meta.outputs.tags }} | ||||||
| labels: ${{ steps.jr_meta.outputs.labels }} | ||||||
| platforms: ${{ inputs.multi_arch && 'linux/amd64,linux/arm64' || 'linux/amd64' }} | ||||||
| cache-from: type=gha | ||||||
| cache-to: type=gha,mode=max | ||||||
| outputs: ${{ inputs.export_artifacts && 'type=docker,dest=/tmp/jobrunner.tar' || '' }} | ||||||
|
||||||
| outputs: ${{ inputs.export_artifacts && 'type=docker,dest=/tmp/jobrunner.tar' || '' }} | |
| output: ${{ inputs.export_artifacts && 'type=docker,dest=/tmp/jobrunner.tar' || '' }} |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,9 +128,20 @@ jobs: | |
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| files: ./server/coverage/coverage-final.json,./jobrunner/coverage/coverage-final.json | ||
|
|
||
| build: | ||
| uses: ./.github/workflows/build_shared.yml | ||
| with: | ||
| ref: ${{ github.ref }} | ||
| tag: test | ||
| build: server,jobrunner | ||
| multi_arch: false | ||
| push_docker: false | ||
| export_artifacts: true | ||
|
|
||
| test-e2e-server: | ||
| timeout-minutes: 60 | ||
| runs-on: ubuntu-latest | ||
| needs: [build] | ||
| env: | ||
| NODE_ENV: test | ||
| E2E_TEST: "true" | ||
|
|
@@ -144,33 +155,18 @@ jobs: | |
| cache: "yarn" | ||
| cache-dependency-path: "yarn.lock" | ||
|
|
||
| - name: Docker Compose | ||
| uses: hoverkraft-tech/[email protected] | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --immutable --inline-builds | ||
|
|
||
| - name: Build server | ||
| run: | | ||
| yarn build | ||
| cp -r public .next/standalone/server/public | ||
| mkdir -p .next/standalone/server/.next | ||
| cp -r .next/static .next/standalone/server/.next/static | ||
| working-directory: ./server | ||
|
|
||
| - name: Build Jobrunner | ||
| run: | | ||
| yarn build | ||
| cp ../utility/prisma/schema.prisma . | ||
| working-directory: ./jobrunner | ||
| - uses: ./.github/steps/run-test-services | ||
| with: | ||
| image-from-artifacts: "true" | ||
| docker-tag: test | ||
|
|
||
| - uses: ./.github/steps/setup-playwright | ||
| with: | ||
| working-directory: ./server | ||
|
|
||
| - name: Migrate database | ||
| run: yarn prisma:migrateProd | ||
|
|
||
| - name: Run Playwright tests | ||
| run: yarn ${{ runner.debug && 'test:e2e:debug' || 'test:e2e' }} | ||
| working-directory: ./server | ||
|
|
@@ -231,6 +227,7 @@ jobs: | |
| test-e2e-desktop-complete: | ||
| timeout-minutes: 60 | ||
| runs-on: ubuntu-latest | ||
| needs: [build] | ||
| env: | ||
| NODE_ENV: test | ||
| E2E_TEST: "true" | ||
|
|
@@ -245,52 +242,21 @@ jobs: | |
| cache: "yarn" | ||
| cache-dependency-path: "yarn.lock" | ||
|
|
||
| - name: Docker Compose | ||
| uses: hoverkraft-tech/[email protected] | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --immutable --inline-builds | ||
|
|
||
| - uses: FedericoCarboni/setup-ffmpeg@v3 | ||
| - uses: ./.github/steps/run-test-services | ||
| with: | ||
| ffmpeg-version: "release" | ||
|
|
||
| - name: Build server | ||
| run: | | ||
| yarn build | ||
| cp -r public .next/standalone/server/public | ||
| mkdir -p .next/standalone/server/.next | ||
| cp -r .next/static .next/standalone/server/.next/static | ||
| working-directory: ./server | ||
|
|
||
| - name: Build Jobrunner | ||
| run: | | ||
| yarn build | ||
| cp ../utility/prisma/schema.prisma . | ||
| working-directory: ./jobrunner | ||
| image-from-artifacts: "true" | ||
| docker-tag: test | ||
|
|
||
| - name: Build desktop | ||
| run: yarn build | ||
| working-directory: ./desktop | ||
|
|
||
| - name: Migrate database | ||
| run: yarn prisma:migrateProd | ||
|
|
||
| - name: Make logs folder | ||
| run: mkdir -p ${{ runner.temp }}/logs | ||
|
|
||
| - name: Start Jobrunner | ||
| run: | | ||
| node --enable-source-maps dist/index.cjs --watch --pidFile ${{ runner.temp }}/jobrunner.pid > ${{ runner.temp }}/logs/jobrunner.log 2>&1 & | ||
| npx -y wait-on file:/${{ runner.temp }}/jobrunner.pid | ||
| working-directory: ./jobrunner | ||
|
|
||
| - name: Start server | ||
| run: | | ||
| HOSTNAME=localhost node server/server.js > ${{ runner.temp }}/logs/server.log 2>&1 & | ||
| npx -y wait-on -v -t 120000 http://localhost:3000/api/healthz | ||
| working-directory: ./server/.next/standalone | ||
|
|
||
| - name: Run Playwright tests | ||
| run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn ${{ runner.debug && 'test:e2e:debug' || 'test:e2e' }} --project complete | ||
| working-directory: ./desktop | ||
|
|
||
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
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key 'outputs' should be 'output' in the docker/build-push-action step.