Skip to content

Merge branch 'Serious-senpai:main' into main #130

Merge branch 'Serious-senpai:main' into main

Merge branch 'Serious-senpai:main' into main #130

Workflow file for this run

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\`\`\``,
});
}
);