1
- name : Project Tester
1
+ name : Test
2
2
3
3
on :
4
4
# Run on push, pull request, and manual trigger
5
5
push :
6
6
# Only run when the specific files are changed
7
7
paths :
8
- - ' src/ **/*.java' # Java files
9
- - ' src/ **/*.py' # Python files
8
+ - ' **/*.java' # Java files
9
+ - ' **/*.py' # Python files
10
10
11
11
# Unlike push, the workflow always runs on pull requests
12
12
pull_request :
20
20
required : false
21
21
type : boolean
22
22
23
+ # Environment variables definitions
24
+ env :
25
+ # # For Java installation
26
+ java-dist : temurin
27
+
28
+ # # For Python installation
29
+ arch : x64
30
+
31
+ # # Other environments
32
+ debug : ${{ inputs.debug }}
33
+ deps : requirements.txt
34
+
23
35
jobs :
24
36
# ::---:: Maven Test ::---:: #
25
37
maven-test :
26
- name : Maven Test / ${{ matrix.os }}
38
+ name : Maven Test / ${{ matrix.os }} / ${{ matrix.java-ver }}
27
39
runs-on : ${{ matrix.os }}-latest
28
40
29
41
env :
30
- java-ver : 11
31
- java-dist : temurin
32
- DEBUG : ${{ inputs.debug }}
42
+ # Maven's debug flag (`-X`)
43
+ mvnDebugFlag : ${{ inputs.debug == true && '-X' || '' }}
33
44
34
45
strategy :
46
+ # Set to maximum number of processes to speed up jobs run
47
+ max-parallel : 6
35
48
matrix :
36
- os : [Ubuntu, Windows]
49
+ os : [Ubuntu, Windows, macOS]
50
+ java-ver : [11, 17, 20] # JDK 11, 17 & 20
37
51
38
52
steps :
39
53
# Checkout repository
@@ -46,89 +60,70 @@ jobs:
46
60
uses : actions/cache@v3
47
61
with :
48
62
path : ~/.m2/repository
49
- key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
63
+ key : ${{ runner.os }}-jdk-${{ matrix.java-ver }}-${{ env.java-dist }}- maven-${{ hashFiles('**/pom.xml') }}
50
64
restore-keys : |
51
- ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
52
- ${{ runner.os }}-maven-
65
+ ${{ runner.os }}-jdk-${{ matrix.java-ver }}-${{ env.java-dist }}- maven-${{ hashFiles('**/pom.xml') }}
66
+ ${{ runner.os }}-jdk-${{ matrix.java-ver }}-${{ env.java-dist }}- maven-
53
67
54
68
# Setup Java
55
- - name : Setup Java / ${{ matrix.os }}
69
+ - name : Setup Java / ${{ matrix.os }} / ${{ matrix.java-ver }}
56
70
uses : actions/setup-java@v4
57
71
with :
58
- java-version : ${{ env .java-ver }}
72
+ java-version : ${{ matrix .java-ver }}
59
73
distribution : ${{ env.java-dist }}
74
+ cache : ' maven'
75
+ cache-dependency-path : ' **/pom.xml'
60
76
61
- # Install deps
62
- - name : Install dependencies
63
- if : ${{ steps.cache-maven.outputs.cache-hit != true && env.DEBUG != true }}
64
- run : mvn install -DskipTests
65
-
66
- - name : Install dependencies (Debug)
67
- if : ${{ steps.cache-maven.outputs.cache-hit != true && env.DEBUG == true }}
68
- run : mvn install -DskipTests -X
69
-
70
- # Packaging with source files
71
- - name : Package source
72
- if : ${{ env.DEBUG != true }}
73
- run : mvn package -P include-src
74
-
75
- - name : Package source (Debug)
76
- if : ${{ env.DEBUG == true }}
77
- run : mvn package -P include-src -X
78
-
79
- # Test
80
- - name : Test project
81
- if : ${{ env.DEBUG != true }}
82
- run : mvn test
83
-
84
- - name : Test project (Debug)
85
- if : ${{ env.DEBUG == true }}
86
- run : mvn test -X
77
+ # Build the project
78
+ - name : Build with Maven
79
+ run : mvn -B package -P include-src -P lint ${{ env.mvnDebugFlag }}
80
+ shell : bash
87
81
88
82
# Clean up
89
83
- name : Clean up the project
90
- run : mvn clean
84
+ run : mvn clean ${{ env.mvnDebugFlag }}
85
+ shell : bash
91
86
92
87
93
88
# ::---:: Make Test ::---:: #
94
89
make-test :
95
- name : Make Test
90
+ name : Make Test / Ubuntu / ${{ matrix.py-ver }}
96
91
runs-on : ubuntu-latest
97
- continue-on-error : true
92
+
93
+ env :
94
+ MAKE : ${{ inputs.debug == true && 'make -d' || 'make' }}
98
95
99
96
strategy :
97
+ # Set to maximum number of processes to speed up jobs run
98
+ max-parallel : 6
100
99
matrix :
101
- py-ver : ['3.7', '3.x']
102
-
103
- env :
104
- arch : x64
105
- DEPS_FILE : ' requirements.txt'
106
- DEBUG : ${{ inputs.debug }}
100
+ py-ver : [3.7, 3.x] # Python 3.7 & latest of version 3
107
101
108
102
steps :
109
103
# Checkout
110
104
- name : Checkout repository
111
105
uses : actions/checkout@v4
112
106
113
107
# Setup Python
114
- - name : Setup Python ${{ matrix.py-ver }}
108
+ - name : Setup Python / Ubuntu / ${{ matrix.py-ver }}
115
109
id : setup-py
116
110
uses : actions/setup-python@v4
117
111
with :
118
112
python-version : ${{ matrix.py-ver }}
119
113
architecture : ${{ env.arch }}
120
- cache : ' pip'
121
- cache-dependency-path : ' **/${{ env.DEPS_FILE }}'
114
+ cache : pip
115
+ cache-dependency-path : ' **/${{ env.deps }}'
122
116
123
117
# Install deps
124
- - name : Install dependencies
118
+ - name : Install Python dependencies
125
119
if : ${{ steps.setup-py.outputs.cache-hit != true }}
126
120
run : |
127
- if [ $DEBUG = 'true' ]; then
128
- python -m pip install -r $DEPS_FILE --debug
121
+ if [ $debug = 'true' ]; then
122
+ python -m pip install -r $(git ls-files **/$deps) --debug
129
123
else
130
- python -m pip install -r $DEPS_FILE
124
+ python -m pip install -r $(git ls-files **/$deps)
131
125
fi
126
+ shell : bash
132
127
133
128
# Sadly, Make cannot tests the project thoroughly due to unavailability
134
129
# of necessary packages (e.g "org.junit"), so here it just tests
@@ -137,31 +132,16 @@ jobs:
137
132
# Compile
138
133
- name : Compile the project
139
134
run : |
140
- [ -d target/classes ] && make clean
141
- make compile VERBOSE=$DEBUG LINT=true
142
-
143
- # Package
144
- - name : Packaging the project
145
- run : |
146
- make package VERBOSE=$DEBUG
147
-
148
- - name : Packaging the project (with source)
149
- run : |
150
- make package INCLUDE-SRC=true VERBOSE=$DEBUG
135
+ [ -d target ] && make clean > /dev/null
136
+ $MAKE compile LINT=true VERBOSE=$debug
137
+ shell : bash
151
138
152
- # Build docs
153
- - name : Build the docs
154
- run : |
155
- # Build docs
156
- # For more information on debugging, we prefer to change it
157
- # to "all" mode.
158
- if [ $DEBUG = 'true' ]; then
159
- make build-docs VERBOSE=all
160
- else
161
- make build-docs
162
- fi
139
+ # Build
140
+ - name : Build with Make
141
+ run : $MAKE package INCLUDE_SRC=true VERBOSE=$debug
142
+ shell : bash
163
143
164
144
# Clean up
165
145
- name : Clean up the project
166
- run : |
167
- [ -d target ] && echo "Clean the project" && make clean
146
+ run : $MAKE clean VERBOSE=$debug
147
+ shell : bash
0 commit comments