forked from Serious-senpai/tabu-search
-
Notifications
You must be signed in to change notification settings - Fork 0
245 lines (214 loc) · 7.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
name: Tests
on:
push:
branches:
- "main"
paths-ignore:
- "**.md"
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
tsp-test:
name: Solve TSP
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
problem: ["berlin52", "bier127", "ch150", "eil101"]
iterations: [2000]
tabu_size: [5, 10, 40]
shuffle_after: [5, 10, 100]
include:
- problem: "a280"
iterations: 1000
tabu_size: 5
shuffle_after: 5
verbose: "--verbose"
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v4
- name: Install dependencies
run: pip install -r dev-requirements.txt
- name: Test sample
timeout-minutes: 60
run: |
coverage run \
tsp.py ${{ matrix.problem }} \
--iterations ${{ matrix.iterations }} \
--tabu-size ${{ matrix.tabu_size }} \
--shuffle-after ${{ matrix.shuffle_after }} \
${{ matrix.verbose }} \
--dump output-${{ matrix.problem }}.${{ matrix.iterations }}.${{ matrix.tabu_size }}.${{ matrix.shuffle_after }}.json
- name: Combine coverage reports
if: ${{ !cancelled() }}
run: |
coverage combine
mv .coverage .coverage.${{ matrix.problem }}.${{ matrix.iterations }}.${{ matrix.tabu_size }}.${{ matrix.shuffle_after }}
- name: Upload solution
uses: actions/upload-artifact@v3
if: ${{ !cancelled() }}
with:
name: tsp-summary
path: |
output-**.json
.coverage.**
retention-days: 1
d2d-test:
name: Solve D2D
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
problem: [
"200.10.1", "200.10.2", "200.10.3", "200.10.4", "200.20.1", "200.20.2", "200.20.3", "200.20.4", "200.30.1", "200.30.2", "200.30.3", "200.30.4",
"200.40.1", "200.40.2", "200.40.3", "200.40.4", "50.20.1", "50.20.2", "50.20.3", "50.20.4", "50.30.1", "50.30.2", "50.30.3", "50.30.4", "50.40.1", "50.40.2", "50.40.3", "50.40.4",
]
iterations: [1000]
tabu_size: [10]
drone_config: ["3 3 3 3"]
energy_mode: ["linear", "non-linear"]
propagation_priority: ["min-distance", "max-distance", "ideal-distance"]
max_propagation: [5]
pool_size: [8]
include:
- problem: "100.10.1"
iterations: 500
tabu_size: 10
drone_config: "3 3 3 3"
energy_mode: "linear"
propagation_priority: "none"
max_propagation: 5
pool_size: 8
verbose: "--verbose"
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v4
- name: Install dependencies
run: pip install -r dev-requirements.txt
- name: Test sample
timeout-minutes: 600
run: |
coverage run \
d2d.py ${{ matrix.problem }} \
--iterations ${{ matrix.iterations }} \
--tabu-size ${{ matrix.tabu_size }} \
--drone-config-mapping ${{ matrix.drone_config }} \
--energy-mode ${{ matrix.energy_mode }} \
--propagation-priority ${{ matrix.propagation_priority }} \
--max-propagation ${{ matrix.max_propagation }} \
--pool-size ${{ matrix.pool_size }} \
${{ matrix.verbose }} \
--dump output-${{ matrix.problem }}.${{ matrix.iterations }}.${{ matrix.tabu_size }}.${{ matrix.energy_mode }}.${{ matrix.propagation_priority }}.${{ matrix.max_propagation }}.${{ matrix.pool_size }}.json \
- name: Combine coverage reports
if: ${{ !cancelled() }}
run: |
coverage combine
mv .coverage .coverage.${{ matrix.problem }}.${{ matrix.iterations }}.${{ matrix.tabu_size }}.${{ matrix.energy_mode }}.${{ matrix.propagation_priority }}.${{ matrix.max_propagation }}.${{ matrix.pool_size }}
- name: Upload solution
uses: actions/upload-artifact@v3
if: ${{ !cancelled() }}
with:
name: d2d-summary
path: |
output-*.json
.coverage.*
retention-days: 1
summary:
name: Summarize solutions
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
needs: [tsp-test, d2d-test]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Download TSP solutions
uses: actions/download-artifact@v3
with:
name: tsp-summary
path: tsp-summary/
- name: Download D2D solutions
uses: actions/download-artifact@v3
with:
name: d2d-summary
path: d2d-summary/
- name: Setup Python
uses: actions/setup-python@v4
- name: Install dependencies
run: pip install -r dev-requirements.txt
- name: Summarize solutions
run: |
export PYTHONPATH=$GITHUB_WORKSPACE
coverage run scripts/tsp-summary.py
coverage run scripts/d2d-summary.py --energy-mode 1 --propagation-priority 2
- name: Run pytest
run: coverage run -m pytest -v
- name: Combine coverage results
run: |
coverage combine tsp-summary/ d2d-summary/ .
coverage html --directory=coverage-html
- name: Report coverage results
run: |
coverage report
coverage report > coverage-report.txt
- name: Upload coverage result
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage-report.txt
retention-days: 1
- name: Upload summary as artifacts
uses: actions/upload-artifact@v3
with:
name: summary
path: |
tsp-summary/*.csv
d2d-summary/*.csv
d2d-summary/*.png
coverage-html/
comment:
name: Comment coverage results
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && !cancelled() }}
needs: summary
permissions:
pull-requests: write
steps:
- name: Download coverage results
uses: actions/download-artifact@v3
with:
name: coverage-report
path: .
- name: Send coverage results in PR
uses: actions/github-script@v7
with:
retries: 3
script: |
var fs = require("fs");
await fs.readFile(
"coverage-report.txt",
"utf-8",
function(error, data) {
if (error) throw error;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.pull_request.number }},
body: `🎉 All tests completed! Here is the coverage report.\n\`\`\`\n${data}\n\`\`\``,
});
}
);