Skip to content

New test workflow

New test workflow #1

Workflow file for this run

name: Tests
on:
push:
branches:
- main
- develop
pull_request:
types: [opened, synchronize, reopened]
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:16-3.4
env:
POSTGRES_DB: p2p_shopping_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres -d p2p_shopping_test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mongodb:
image: mongo:7
env:
MONGO_INITDB_DATABASE: p2p_shopping_test
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.adminCommand(\"ping\")'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run tests
env:
SPRING_DATA_MONGODB_URI: mongodb://localhost:27017/p2p_shopping_test
run: ./gradlew test --info
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports
path: build/reports/tests/
retention-days: 7
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: build/reports/jacoco/
retention-days: 7