-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (145 loc) · 4.59 KB
/
test.yml
File metadata and controls
174 lines (145 loc) · 4.59 KB
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
168
169
170
171
172
173
174
name: Running Tests
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
jobs:
detect_doc_changes:
runs-on: ubuntu-latest
outputs:
docs_only: ${{ steps.set_result.outputs.docs_only }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Detect docs-only changes
id: set_result
run: |
set -e
echo "Event: ${{ github.event_name }}"
if [ "${{ github.event_name }}" = "push" ]; then
files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
else
git fetch origin ${{ github.base_ref }}
files=$(git diff --name-only origin/${{ github.base_ref }} HEAD)
fi
echo "Changed files:"
echo "$files"
non_docs=$(echo "$files" | grep -vE '(^docs/|\.md$)' || true)
if [ -n "$non_docs" ]; then
echo "docs_only=false" >> $GITHUB_OUTPUT
else
echo "docs_only=true" >> $GITHUB_OUTPUT
fi
timefold_test:
runs-on: ubuntu-latest
needs: detect_doc_changes
if: needs.detect_doc_changes.outputs.docs_only == 'false'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Java JDK
uses: actions/setup-java@v4
with:
java-version-file: .java-version
distribution: temurin
- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and test Timefold module
run: mvn clean verify
working-directory: backend/timefold
- name: Upload Timefold JAR
uses: actions/upload-artifact@v4
with:
name: timefold-jar
path: backend/timefold/target/*.jar
skjolber_test:
runs-on: ubuntu-latest
needs: detect_doc_changes
if: needs.detect_doc_changes.outputs.docs_only == 'false'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Java JDK
uses: actions/setup-java@v4
with:
java-version-file: .java-version
distribution: temurin
- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and test Skjolber module
run: mvn clean verify
working-directory: backend/skjolber
- name: Upload Skjolber JAR
uses: actions/upload-artifact@v4
with:
name: skjolber-jar
path: backend/skjolber/target/*.jar
backend_test:
runs-on: ubuntu-latest
needs: [detect_doc_changes, timefold_test, skjolber_test]
if: needs.detect_doc_changes.outputs.docs_only == 'false'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Java JDK
uses: actions/setup-java@v4
with:
java-version-file: .java-version
distribution: temurin
- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Download Timefold JAR
uses: actions/download-artifact@v4
with:
name: timefold-jar
path: backend/timefold/target
- name: Download Skjolber JAR
uses: actions/download-artifact@v4
with:
name: skjolber-jar
path: backend/skjolber/target
- name: Run Spotless check
run: mvn spotless:check
working-directory: backend/box-optimizer-api
- name: Build and test API module
run: mvn clean verify
working-directory: backend/box-optimizer-api
frontend_test:
runs-on: ubuntu-latest
needs: [detect_doc_changes, backend_test]
if: needs.detect_doc_changes.outputs.docs_only == 'false'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install frontend dependencies
run: |
cd frontend
npm install
- name: Run frontend tests
run: |
cd frontend
npm test -- --watchAll=false