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

Add cypress in ci #19

Merged
merged 8 commits into from
Feb 6, 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
98 changes: 81 additions & 17 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name: run_tests
on: push

jobs:
build-and-test:
name: Build and test
build-and-test-backend:
name: Build backend and test backend
runs-on: ubuntu-latest

steps:
Expand All @@ -16,37 +16,101 @@ jobs:
with:
java-version: '17'
distribution: 'temurin'
- name: Define Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
cache: 'gradle'
- name: Build
run: ./gradlew build --build-cache --console plain

- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: tests-results # Name artifact for storage in cache
name: backend-tests-results # Name artifact for storage in cache
path: |
modules/**/build/test-results/**/*.xml
publish-test-results:
name: Publish tests results
build-and-run-frontend-unit-tests:
name: Build frontend and run frontend unit test
runs-on: ubuntu-latest
needs: build-and-test

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Define node modules cache
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: modules/ui/yarn.lock
- name: Install dependencies
working-directory: ./modules/ui
run: yarn install
- name: Run frontend tests
working-directory: ./modules/ui
run: yarn run test
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: frontend-unit-tests-results # Name artifact for storage in cache
path: |
./modules/ui/test-output.xml

execute-ui-e2e-tests:
name: Execute UI end to end tests
runs-on: ubuntu-latest
needs: [build-and-test-backend, build-and-run-frontend-unit-tests]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run docker with db
working-directory: modules/app-server/docker
run: docker-compose up -d
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Run server
run: ./gradlew :modules:app-server:app:run &
- name: Define node modules cache
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: modules/ui/yarn.lock
- name: Install UI dependencies
working-directory: modules/ui
run: yarn install
- name: Run UI
working-directory: modules/ui
run: npm run dev &
- name: Install Cypress and run tests
uses: cypress-io/github-action@v6
with:
wait-on: 'http://localhost:5173'
working-directory: modules/ui

publish-all-test-results:
name: Publish all tests results
runs-on: ubuntu-latest
needs: [build-and-test-backend, build-and-run-frontend-unit-tests, execute-ui-e2e-tests]
# the build-and-test job might be skipped, we don't need to run this job then
if: success() || failure()
permissions:
checks: write
pull-requests: write

steps:
- name: Download Artifacts
- name: Download backend tests artifact
uses: actions/download-artifact@v2
with:
name: backend-tests-results # Name of artifact in cache
path: tests-results/

- name: Download frontend unit tests
uses: actions/download-artifact@v2
with:
name: tests-results # Name of artifact in cache
name: frontend-unit-tests-results # Name of artifact in cache
path: tests-results/

- name: Publish Unit Test Results
Expand Down
2 changes: 2 additions & 0 deletions modules/ui/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
reporters: ['junit'],
outputFile: './test-output.xml'
},
})
Loading
Loading