1- # This workflow uses actions that are not certified by GitHub.
2- # They are provided by a third-party and are governed by
3- # separate terms of service, privacy policy, and support
4- # documentation.
5- # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
7-
81name : Backend CI
92
103on :
1710
1811jobs :
1912 build :
20-
2113 runs-on : ubuntu-latest
2214 permissions :
2315 contents : read
2416 defaults :
2517 run :
2618 working-directory : ./backend
2719
20+ services :
21+ postgres :
22+ image : postgres:15
23+ env :
24+ POSTGRES_USER : testuser
25+ POSTGRES_PASSWORD : testpassword
26+ POSTGRES_DB : testdb
27+ ports :
28+ - 5432:5432
29+ options : >-
30+ --health-cmd "pg_isready -U testuser -d testdb"
31+ --health-interval 10s
32+ --health-timeout 5s
33+ --health-retries 5
34+
2835 steps :
2936 - uses : actions/checkout@v4
3037 - name : Set up JDK 21
@@ -33,30 +40,23 @@ jobs:
3340 java-version : ' 21'
3441 distribution : ' temurin'
3542
36- # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
37- # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
3843 - name : Grant execute permission for gradlew
3944 run : chmod +x gradlew
4045
4146 - name : Setup Gradle
4247 uses : gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
4348
4449 - name : Build with Gradle Wrapper
45- run : ./gradlew build
50+ run : ./gradlew build -x test
4651
47- # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
48- # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
49- #
50- # - name: Setup Gradle
51- # uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
52- # with:
53- # gradle-version: '8.9'
54- #
55- # - name: Build with Gradle 8.9
56- # run: gradle build
52+ - name : Run Tests
53+ env :
54+ SPRING_DATASOURCE_URL : jdbc:postgresql://localhost:5432/testdb
55+ SPRING_DATASOURCE_USERNAME : testuser
56+ SPRING_DATASOURCE_PASSWORD : testpassword
57+ run : ./gradlew test
5758
5859 dependency-submission :
59-
6060 runs-on : ubuntu-latest
6161 permissions :
6262 contents : write
7272 java-version : ' 21'
7373 distribution : ' temurin'
7474
75- # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
76- # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
7775 - name : Generate and submit dependency graph
7876 uses : gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
7977 with :
8078 gradle-version : ' 8.12.1'
81- build-root-directory : ./backend
79+ build-root-directory : ./backend
0 commit comments