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