Skip to content

Commit

Permalink
Run tests in github actions (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erikvv authored Dec 4, 2024
1 parent 54ef246 commit 222dace
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:

jobs:
variables:
needs:
- test
runs-on: ubuntu-latest
outputs:
VERSION_TAG: ${{ fromJson(steps.variables.outputs.result).VERSION_TAG }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Remove test services
name: Remove pullrequest environment

on:
pull_request:
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Run automated tests

on:
workflow_dispatch:
push:
branches:
- main
- production
pull_request:
types: [ opened, synchronize, reopened ]

jobs:
# Tests with a database
zorm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: docker cache
uses: actions/cache@v4
with:
path: /var/lib/docker
key: var-lib-docker
- run: >
docker compose
--project-directory .
--file github-actions/compose.yaml
run --rm --user root
zorm-test-github-actions
# Tests without a database
gradle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- run: gradle excel-read-named:test
- run: gradle zummon:jvmTest

frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- run: npm install
working-directory: ./frontend
- run: npm run test
working-directory: ./frontend
20 changes: 19 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ services:
POSTGRES_URL: jdbc:postgresql://postgres:5432/test
POSTGRES_USER: postgres

zorm-test-github-actions:
extends:
service: gradle-base
depends_on:
- postgres-github-actions
volumes:
- gradle-zorm-test-home:/home/gradle/.gradle
command: zorm:test --no-daemon
environment:
POSTGRES_URL: jdbc:postgresql://postgres-github-actions:5432/postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: github-actions

## Production version
ztor-production:
build:
Expand Down Expand Up @@ -218,7 +231,7 @@ services:
- 127.0.0.1:2015:2015

postgres:
image: postgres:13.9 # same as on Azure
image: postgres:17.2
ports:
- 127.0.0.1:5432:5432
volumes:
Expand All @@ -227,6 +240,11 @@ services:
env_file:
- docker/local/postgres.env

postgres-github-actions:
image: postgres:17.2
environment:
POSTGRES_PASSWORD: github-actions

volumes:
gradle-vallum-test-cache:
gradle-vallum-test-stuff:
Expand Down
33 changes: 33 additions & 0 deletions github-actions/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

# Compose file to run tests in GitHub Actions
services:
gradle-base:
image: gradle:8.10.0-jdk21
working_dir: /home/gradle/zero
user: gradle
volumes:
- .:/home/gradle/zero
- gradle-base-cache:/home/gradle/.gradle
entrypoint: gradle --project-cache-dir=/tmp/gradle

zorm-test-github-actions:
extends:
service: gradle-base
depends_on:
- postgres-github-actions
volumes:
- gradle-zorm-test-home:/home/gradle/.gradle
command: zorm:test --no-daemon
environment:
POSTGRES_URL: jdbc:postgresql://postgres-github-actions:5432/postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: github-actions

postgres-github-actions:
image: postgres:17.2
environment:
POSTGRES_PASSWORD: github-actions

volumes:
gradle-base-cache:
gradle-zorm-test-home:

0 comments on commit 222dace

Please sign in to comment.