File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Unit Tests
2
+
3
+ # Trigger the workflow on pull request creation, pull request update, or push to main branch.
4
+ on :
5
+ pull_request :
6
+ branches :
7
+ - main
8
+ push :
9
+ branches :
10
+ - main
11
+
12
+ jobs :
13
+ build :
14
+ runs-on : ubuntu-latest
15
+
16
+ steps :
17
+ # Checkout the repository
18
+ - name : Checkout repository
19
+ uses : actions/checkout@v3
20
+
21
+ # Set up JDK 11 for Kotlin/Java projects (you can adjust the version if necessary)
22
+ - name : Set up JDK 17
23
+ uses : actions/setup-java@v3
24
+ with :
25
+ distribution : ' temurin'
26
+ java-version : ' 17'
27
+
28
+ # Cache Gradle dependencies (Optional, but improves build speed)
29
+ - name : Cache Gradle packages
30
+ uses : actions/cache@v3
31
+ with :
32
+ path : ~/.gradle/caches
33
+ key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
34
+ restore-keys : |
35
+ ${{ runner.os }}-gradle-
36
+
37
+ # Run unit tests
38
+ - name : Run Unit Tests
39
+ run : ./gradlew test
40
+
41
+ # Archive test results for inspection (optional step to store test reports)
42
+ - name : Archive test results
43
+ if : always()
44
+ uses : actions/upload-artifact@v3
45
+ with :
46
+ name : test-results
47
+ path : build/test-results/test/
48
+
49
+ # Publish test results to the pull request (Optional)
50
+ - name : Publish Test Results
51
+ if : always()
52
+ uses : mikepenz/action-junit-report@v3
53
+ with :
54
+ report_paths : ' **/build/test-results/test/TEST-*.xml'
55
+ check_name : ' Unit Test Results'
56
+ fail_on_failure : true
You can’t perform that action at this time.
0 commit comments