-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (138 loc) · 4.31 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Project Tester
on:
# Run on push, pull request, and manual trigger
push:
# Only run when the specific files are changed
paths:
- 'src/**/*.java' # Java files
- 'src/**/*.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
jobs:
# ::---:: Maven Test ::---:: #
maven-test:
name: Maven Test / ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
env:
java-ver: 11
java-dist: temurin
DEBUG: ${{ inputs.debug }}
strategy:
matrix:
os: [Ubuntu, Windows]
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
# Caching Maven deps
- name: Cache Maven dependencies
id: cache-maven
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
${{ runner.os }}-maven-
# Setup Java
- name: Setup Java / ${{ matrix.os }}
uses: actions/setup-java@v3
with:
java-version: ${{ env.java-ver }}
distribution: ${{ env.java-dist }}
# Install deps
- name: Install dependencies
if: ${{ steps.cache-maven.outputs.cache-hit != true && env.DEBUG != true }}
run: mvn install -DskipTests
- name: Install dependencies (Debug)
if: ${{ steps.cache-maven.outputs.cache-hit != true && env.DEBUG == true }}
run: mvn install -DskipTests -X
# Packaging with source files
- name: Package source
if: ${{ env.DEBUG != true }}
run: mvn package -P include-src
- name: Package source (Debug)
if: ${{ env.DEBUG == true }}
run: mvn package -P include-src -X
# Test
- name: Test project
if: ${{ env.DEBUG != true }}
run: mvn test
- name: Test project (Debug)
if: ${{ env.DEBUG == true }}
run: mvn test -X
# Clean up
- name: Clean up the project
run: mvn clean
# ::---:: Make Test ::---:: #
make-test:
name: Make Test
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
py-ver: ['3.7', '3.x']
env:
arch: x64
DEPS_FILE: 'requirements.txt'
DEBUG: ${{ inputs.debug }}
steps:
# Checkout
- name: Checkout repository
uses: actions/checkout@v4
# Setup Python
- name: Setup Python ${{ matrix.py-ver }}
id: setup-py
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.py-ver }}
architecture: ${{ env.arch }}
cache: 'pip'
cache-dependency-path: '**/${{ env.DEPS_FILE }}'
# Install deps
- name: Install dependencies
if: ${{ steps.setup-py.outputs.cache-hit != true }}
run: |
if [ $DEBUG = 'true' ]; then
python -m pip install -r $DEPS_FILE --debug
else
python -m pip install -r $DEPS_FILE
fi
# 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/classes ] && make clean
make compile VERBOSE=$DEBUG LINT=true
# Package
- name: Packaging the project
run: |
make package VERBOSE=$DEBUG
- name: Packaging the project (with source)
run: |
make package INCLUDE-SRC=true VERBOSE=$DEBUG
# Build docs
- name: Build the docs
run: |
# Build docs
# For more information on debugging, we prefer to change it
# to "all" mode.
if [ $DEBUG = 'true' ]; then
make build-docs VERBOSE=all
else
make build-docs
fi
# Clean up
- name: Clean up the project
run: |
[ -d target ] && echo "Clean the project" && make clean