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

Test with different Spring profiles (using --spec command line argument) #803

Merged
merged 18 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
File renamed without changes.
6 changes: 6 additions & 0 deletions .github/workflows/extractColumn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
#
# Usage:
# extractColumn.sh <file to extract> <key> <column number to extract, starting from index 1>
#
grep -v -E "^#" $1 | grep "^$2" | sed 's|\s\s*| |g' | cut -d" " -f$3
11 changes: 11 additions & 0 deletions .github/workflows/profiles-and-specs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file lists for each selection name what Spring
# profile to use for the backend and what specs to
# execute. It is spaces-delimited, because the specs field
# includes commas.
#
# Spring profile "none" is a magic value. For that
# value nu Spring profile is specified when the
mhdirkse marked this conversation as resolved.
Show resolved Hide resolved
# backend is run.
#
default none cypress/e2e/1-first.spec.ts,cypress/e2e/debug/**,cypress/e2e/misc/**,cypress/e2e/test/**
xml-storage storage.xml cypress/e2e/1-profile-storage-xml/**
File renamed without changes.
42 changes: 32 additions & 10 deletions .github/workflows/testing.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ on:

jobs:
testing:
strategy:
matrix:
selection: [
'default',
'xml-storage'
]
name: Unit tests
runs-on: ubuntu-latest

Expand All @@ -43,6 +49,16 @@ jobs:
if: ${{ github.event.inputs.frontendCommitToCheckout }}
run: git checkout ${{ github.event.inputs.frontendCommitToCheckout }}
working-directory: "ladybug-frontend"
- name: Choose profile to use backend with
id: backend-profile
run: echo "backend-profile=$(./extractColumn.sh profiles-and-specs.txt ${{ matrix.selection }} 2)" >> $GITHUB_OUTPUT
working-directory: ladybug-frontend/.github/workflows
- name: Choose specs to run
id: chosen-specs
run: echo "chosen-specs=$(./extractColumn.sh profiles-and-specs.txt ${{ matrix.selection }} 3)" >> $GITHUB_OUTPUT
working-directory: ladybug-frontend/.github/workflows
- name: Show chosen Spring profile for backend and chosen specs to run
run: echo "Start backend with Spring profile ${{ steps.backend-profile.outputs.backend-profile }} and run specs ${{ steps.chosen-specs.outputs.chosen-specs }}"

- uses: pnpm/action-setup@v4
name: Install pnpm
Expand Down Expand Up @@ -88,7 +104,7 @@ jobs:
${{ runner.os }}-cypress-

- name: Set Cypress environment variables
run: cp cypress.env.json.cicd cypress.env.json
run: cp .github/workflows/cypress.env.json.cicd cypress.env.json
working-directory: ladybug-frontend

- name: Run linter
Expand Down Expand Up @@ -118,6 +134,9 @@ jobs:
run: echo "maven.skip.javadoc=true" >> frank-runner/specials/ladybug/build.properties
- name: Set property to skip checking licenses
run: echo "maven.skip.copyright=true" >> frank-runner/specials/ladybug/build.properties
- name: Choose Spring profile for backend if it is not "none"
run: echo "spring.profiles.active=${{ steps.backend-profile.outputs.backend-profile }}" >> frank-runner/specials/ladybug/build.properties
if: ${{ steps.backend-profile.outputs.backend-profile != 'none' }}
- name: Set port where ladybug-test-webapp is served
run: echo "tomcat.connector.port=8090" > frank-runner/build.properties
- name: Prevent Java exception about binding port 443 (for https)
Expand Down Expand Up @@ -190,9 +209,10 @@ jobs:
with:
working-directory: ladybug-frontend
start: |
pnpm ng serve --proxy-config src/proxy.cicd.conf.json --host 0.0.0.0
pnpm ng serve --proxy-config .github/workflows/proxy.cicd.conf.json --host 0.0.0.0
wait-on: "http://0.0.0.0:8090, http://0.0.0.0:4200"
wait-on-timeout: 1000
spec: ${{ steps.chosen-specs.outputs.chosen-specs }}
browser: chrome
- name: Run cypress with chrome browser (production frontend that is included in backend)
uses: cypress-io/[email protected]
Expand All @@ -201,8 +221,10 @@ jobs:
working-directory: ladybug-frontend
wait-on: "http://0.0.0.0:8090"
wait-on-timeout: 1000
spec: ${{ steps.chosen-specs.outputs.chosen-specs }}
config: baseUrl=http://localhost:8090/ladybug
browser: chrome

- name: Show files
run: tree -d -L 5 .
if: always()
Expand All @@ -211,47 +233,47 @@ jobs:
uses: actions/upload-artifact@v4
if: always()
with:
name: installFrankRunnerEnv.log
name: installFrankRunnerEnv.log ${{ matrix.selection }}
path: frank-runner/installFrankRunnerEnv.log
- name: Store log of starting the server with the Frank!Runner
uses: actions/upload-artifact@v4
if: always()
with:
name: serverStartLog.log
name: serverStartLog.log ${{ matrix.selection }}
path: frank-runner/specials/ladybug/serverStartLog.log
- name: Store build.properties
uses: actions/upload-artifact@v4
if: always()
with:
name: specials_build.properties
name: specials_build.properties ${{ matrix.selection }}
path: frank-runner/specials/ladybug/build.properties
- name: Store Apache Tomcat log
uses: actions/upload-artifact@v4
if: always()
with:
name: logs
name: logs ${{ matrix.selection }}
path: frank-runner/build/*/logs/*
- name: Store Cypress screenshots
uses: actions/upload-artifact@v4
if: always()
with:
name: screenshots
name: screenshots ${{ matrix.selection }}
path: ladybug-frontend/cypress/screenshots/
- name: Store Cypress videos
uses: actions/upload-artifact@v4
if: always()
with:
name: videos
name: videos ${{ matrix.selection }}
path: ladybug-frontend/cypress/videos/
- name: Store Cypress screenshots for Firefox
uses: actions/upload-artifact@v4
if: always()
with:
name: Firefix screenshots
name: Firefix screenshots ${{ matrix.selection }}
path: ladybug-frontend/cypress/firefox/screenshots/
- name: Store Cypress videos for Firefox
uses: actions/upload-artifact@v4
if: always()
with:
name: Firefox videos
name: Firefox videos ${{ matrix.selection }}
path: ladybug-frontend/cypress/firefox/videos/
20 changes: 20 additions & 0 deletions cypress/e2e/1-first.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

// This test should be run as the first. Other tests
// have to delete all reports from the test tab and
// would remove pre-existing reports.
//
// We test here that there are no predefined reports
//
describe('Test that should be done before all other tests', () => {
beforeEach(() => {
cy.initializeApp();
cy.navigateToTestTabAndInterceptApiCall();
})

it('Report in src/test/testtool should not be shown', () => {
// We cannot search for 'Pre existing report' within the
// test rows when there are not table rows at all.
cy.getTestTableRows().should('not.exist')
})
})

14 changes: 14 additions & 0 deletions cypress/e2e/1-profile-storage-xml/1-pre-existing-report.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This test should be run as the first. Other tests
// have to delete all reports from the test tab and
// would remove pre-existing reports.
//
describe('Pre existing report', () => {
beforeEach(() => {
cy.initializeApp();
cy.navigateToTestTabAndInterceptApiCall();
})

it('Report present in src/test/testtool should be shown', () => {
cy.getTestTableRows().contains('Pre existing report').should('have.length', 1)
})
})
mhdirkse marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
File renamed without changes.
Loading