OPHYK-214 Use a db instance/engine combo that is actually supported #9
This file contains 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
name: organisaatio | |
on: | |
workflow_dispatch: | |
push: | |
branches: [master] | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:12.14 | |
ports: | |
- 5433:5432 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_DB: organisaatio | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_HOST_AUTH_METHOD: trust | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: "npm" | |
cache-dependency-path: organisaatio-ui/package-lock.json | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: "21" | |
distribution: "corretto" | |
- uses: szenius/[email protected] | |
with: | |
timezoneLinux: "Europe/Helsinki" | |
- name: Build frontend | |
working-directory: organisaatio-ui | |
run: | | |
npm ci | |
npm run lint | |
npm run prettier | |
CI=true npm run test | |
npm run build | |
- uses: gradle/actions/wrapper-validation@v3 | |
- uses: gradle/actions/setup-gradle@v3 | |
- name: Build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: ./gradlew clean build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: organisaatio-service-jar | |
path: organisaatio-service/build/libs/organisaatio-service.jar | |
cypress: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_HOST_AUTH_METHOD: trust | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cypress coverrage cache | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-cypress-coverage | |
with: | |
path: organisaatio-ui/cypress-coverage | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: "npm" | |
cache-dependency-path: organisaatio-ui/package-lock.json | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: "21" | |
distribution: "corretto" | |
- name: pre scripts | |
run: | | |
PGPASSWORD=postgres psql -c 'CREATE DATABASE organisaatio;' -h localhost -U postgres | |
cd mock-api && npm install && cd - | |
cd organisaatio-ui && npm ci --force && cd - | |
- uses: gradle/actions/wrapper-validation@v3 | |
- uses: gradle/actions/setup-gradle@v3 | |
- name: Build backend with no tests | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: ./gradlew clean build -x test | |
- name: Run Cypress | |
run: | | |
cd mock-api && npm run mock-api & | |
cd organisaatio-ui && npm run start & | |
java -jar -Xms2g -Xmx2g -Dspring.config.location=classpath:application.properties,classpath:application-test-envs.properties -Dspring.profiles.active=dev -Dspring.flyway.enabled=true -Durl-virkailija=http://localhost:9000 -Dhost.virkailija=localhost:9000 -Durl-ytj=http://localhost:9000/ytj -Durl-oidservice=http://localhost:9000/oidservice -Dcas.service.organisaatio-service=http://localhost:8080/organisaatio-service-not-available organisaatio-service/build/libs/organisaatio-service.jar & | |
cd organisaatio-ui && npm run cypress:ci | |
kill $(jobs -p) || true | |
playwright: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_HOST_AUTH_METHOD: trust | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: "npm" | |
cache-dependency-path: organisaatio-ui/package-lock.json | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: "21" | |
distribution: "corretto" | |
- name: pre scripts | |
run: | | |
PGPASSWORD=postgres psql -c 'CREATE DATABASE organisaatio;' -h localhost -U postgres | |
cd mock-api && npm ci && cd - | |
cd organisaatio-ui && npm ci --force && cd - | |
cd playwright && npm ci && npx playwright install --with-deps && cd - | |
- uses: gradle/actions/wrapper-validation@v3 | |
- uses: gradle/actions/setup-gradle@v3 | |
- name: Build backend with no tests | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: ./gradlew clean build -x test | |
- name: | |
run: | | |
cd mock-api && npm run mock-api & | |
cd organisaatio-ui && npm run start & | |
java -jar -Xms2g -Xmx2g -Dspring.config.location=classpath:application.properties,classpath:application-test-envs.properties -Dspring.profiles.active=dev -Dspring.flyway.enabled=true -Durl-virkailija=http://localhost:9000 -Dhost.virkailija=localhost:9000 -Durl-ytj=http://localhost:9000/ytj -Durl-oidservice=http://localhost:9000/oidservice -Dcas.service.organisaatio-service=http://localhost:8080/organisaatio-service-not-available organisaatio-service/build/libs/organisaatio-service.jar & | |
while ! nc -z localhost 3003; do | |
sleep 1; echo "Sleeping 3003" | |
done | |
while ! nc -z localhost 8080; do | |
sleep 1; echo "Sleeping 8080" | |
done | |
cd playwright && npx playwright test | |
kill $(jobs -p) || true | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright/playwright-report/ | |
retention-days: 30 | |
sonarcloud: | |
needs: [cypress, playwright] | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:12.14 | |
ports: | |
- 5433:5432 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_DB: organisaatio | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_HOST_AUTH_METHOD: trust | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set timezone | |
uses: szenius/[email protected] | |
with: | |
timezoneLinux: "Europe/Helsinki" | |
- name: Cypress coverrage cache | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-cypress-coverage | |
with: | |
path: organisaatio-ui/cypress-coverage | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }} | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: "corretto" | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Build and analyze | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: ./gradlew build sonarqube |