Skip to content

Commit 26b915d

Browse files
committed
improve CI
1 parent 55a9cad commit 26b915d

2 files changed

Lines changed: 97 additions & 26 deletions

File tree

.github/workflows/ci.yml

Lines changed: 93 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,28 @@ jobs:
2424
- name: Install system dependencies
2525
run: |
2626
sudo apt-get update
27-
sudo apt-get install -y libspatialindex-dev
27+
sudo apt-get install -y build-essential cmake git
28+
29+
- name: Cache libspatialindex
30+
uses: actions/cache@v3
31+
id: libspatialindex-cache
32+
with:
33+
path: |
34+
/usr/local/lib/libspatialindex*
35+
/usr/local/include/spatialindex
36+
key: ${{ runner.os }}-libspatialindex-${{ hashFiles('**/poetry.lock') }}
37+
restore-keys: |
38+
${{ runner.os }}-libspatialindex-
39+
40+
- name: Build libspatialindex
41+
if: steps.libspatialindex-cache.outputs.cache-hit != 'true'
42+
run: |
43+
git clone https://github.com/libspatialindex/libspatialindex.git /tmp/libspatialindex
44+
cd /tmp/libspatialindex
45+
cmake -DCMAKE_BUILD_TYPE=Release -DSIDX_BUILD_TESTS=OFF .
46+
make -j$(nproc)
47+
sudo make install
48+
sudo ldconfig
2849
- name: Install Poetry
2950
uses: snok/install-poetry@v1
3051
with:
@@ -56,7 +77,28 @@ jobs:
5677
- name: Install system dependencies
5778
run: |
5879
sudo apt-get update
59-
sudo apt-get install -y libspatialindex-dev
80+
sudo apt-get install -y build-essential cmake git
81+
82+
- name: Cache libspatialindex
83+
uses: actions/cache@v3
84+
id: libspatialindex-cache
85+
with:
86+
path: |
87+
/usr/local/lib/libspatialindex*
88+
/usr/local/include/spatialindex
89+
key: ${{ runner.os }}-libspatialindex-${{ hashFiles('**/poetry.lock') }}
90+
restore-keys: |
91+
${{ runner.os }}-libspatialindex-
92+
93+
- name: Build libspatialindex
94+
if: steps.libspatialindex-cache.outputs.cache-hit != 'true'
95+
run: |
96+
git clone https://github.com/libspatialindex/libspatialindex.git /tmp/libspatialindex
97+
cd /tmp/libspatialindex
98+
cmake -DCMAKE_BUILD_TYPE=Release -DSIDX_BUILD_TESTS=OFF .
99+
make -j$(nproc)
100+
sudo make install
101+
sudo ldconfig
60102
- name: Install Poetry
61103
uses: snok/install-poetry@v1
62104
with:
@@ -88,7 +130,28 @@ jobs:
88130
- name: Install system dependencies
89131
run: |
90132
sudo apt-get update
91-
sudo apt-get install -y libspatialindex-dev
133+
sudo apt-get install -y build-essential cmake git
134+
135+
- name: Cache libspatialindex
136+
uses: actions/cache@v3
137+
id: libspatialindex-cache
138+
with:
139+
path: |
140+
/usr/local/lib/libspatialindex*
141+
/usr/local/include/spatialindex
142+
key: ${{ runner.os }}-libspatialindex-${{ hashFiles('**/poetry.lock') }}
143+
restore-keys: |
144+
${{ runner.os }}-libspatialindex-
145+
146+
- name: Build libspatialindex
147+
if: steps.libspatialindex-cache.outputs.cache-hit != 'true'
148+
run: |
149+
git clone https://github.com/libspatialindex/libspatialindex.git /tmp/libspatialindex
150+
cd /tmp/libspatialindex
151+
cmake -DCMAKE_BUILD_TYPE=Release -DSIDX_BUILD_TESTS=OFF .
152+
make -j$(nproc)
153+
sudo make install
154+
sudo ldconfig
92155
- name: Install Poetry
93156
uses: snok/install-poetry@v1
94157
with:
@@ -137,7 +200,28 @@ jobs:
137200
- name: Install system dependencies
138201
run: |
139202
sudo apt-get update
140-
sudo apt-get install -y libspatialindex-dev
203+
sudo apt-get install -y build-essential cmake git
204+
205+
- name: Cache libspatialindex
206+
uses: actions/cache@v3
207+
id: libspatialindex-cache
208+
with:
209+
path: |
210+
/usr/local/lib/libspatialindex*
211+
/usr/local/include/spatialindex
212+
key: ${{ runner.os }}-libspatialindex-${{ hashFiles('**/poetry.lock') }}
213+
restore-keys: |
214+
${{ runner.os }}-libspatialindex-
215+
216+
- name: Build libspatialindex
217+
if: steps.libspatialindex-cache.outputs.cache-hit != 'true'
218+
run: |
219+
git clone https://github.com/libspatialindex/libspatialindex.git /tmp/libspatialindex
220+
cd /tmp/libspatialindex
221+
cmake -DCMAKE_BUILD_TYPE=Release -DSIDX_BUILD_TESTS=OFF .
222+
make -j$(nproc)
223+
sudo make install
224+
sudo ldconfig
141225
- name: Install Poetry
142226
uses: snok/install-poetry@v1
143227
with:
@@ -163,17 +247,17 @@ jobs:
163247
# Run tests with coverage (continue even if tests fail)
164248
- name: Run tests with coverage
165249
run: |
166-
poetry run python -m pytest --cov=o2 --cov-report=xml:/tmp/coverage-reports/coverage.xml --cov-report=html:/tmp/coverage-reports/html || true
250+
poetry run python -m pytest --cov=o2 --cov-report=term-missing --cov-report=xml:/tmp/coverage-reports/coverage.xml --cov-report=html:/tmp/coverage-reports/html || true
167251
168252
# Generate the coverage badge (even if tests failed)
169253
- name: Generate coverage badge
170254
run: |
171255
if [ -f /tmp/coverage-reports/coverage.xml ]; then
172-
COVERAGE=$(python -c "import xml.etree.ElementTree as ET; print('{:.2f}%'.format(float(ET.parse('/tmp/coverage-reports/coverage.xml').getroot().attrib['line-rate']) * 100))")
173-
COLOR=$(python -c "import xml.etree.ElementTree as ET; rate = float(ET.parse('/tmp/coverage-reports/coverage.xml').getroot().attrib['line-rate']); print('red' if rate < 0.5 else 'yellow' if rate < 0.75 else 'green')")
256+
COVERAGE=$(python -c "import xml.etree.ElementTree as ET; print('{:.0f}%'.format(float(ET.parse('/tmp/coverage-reports/coverage.xml').getroot().attrib['line-rate']) * 100))")
257+
COLOR=$(python -c "import xml.etree.ElementTree as ET; rate = float(ET.parse('/tmp/coverage-reports/coverage.xml').getroot().attrib['line-rate']); print('e05d44' if rate < 0.5 else 'dfb317' if rate < 0.75 else '97ca00')")
174258
else
175-
COVERAGE="0.00%"
176-
COLOR="red"
259+
COVERAGE="0%"
260+
COLOR="e05d44"
177261
fi
178262
179263
# Create badge with actual values instead of variables
@@ -201,16 +285,6 @@ jobs:
201285
</svg>
202286
EOF
203287
204-
# Show directory contents for debugging
205-
- name: Debug directory contents
206-
run: |
207-
echo "Contents of /tmp/coverage-reports:"
208-
ls -la /tmp/coverage-reports
209-
echo "Contents of /tmp/coverage-reports/html:"
210-
ls -la /tmp/coverage-reports/html || echo "HTML directory empty"
211-
echo "Contents of /tmp/coverage-reports/badges:"
212-
ls -la /tmp/coverage-reports/badges || echo "Badges directory empty"
213-
214288
# Save coverage report as an artifact
215289
- name: Save coverage report artifact
216290
uses: actions/upload-artifact@v4
@@ -227,9 +301,6 @@ jobs:
227301
cp -r /tmp/coverage-reports/html/* /tmp/coverage-reports/
228302
# Keep badges directory
229303
mkdir -p /tmp/coverage-reports/badges
230-
cp /tmp/coverage-reports/badges/coverage.svg /tmp/coverage-reports/badges/
231-
# Keep coverage.xml
232-
cp /tmp/coverage-reports/coverage.xml /tmp/coverage-reports/
233304
234305
- name: Deploy to GitHub Pages
235306
if: github.ref == 'refs/heads/main'

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Optimos V2
22

3-
[![CI](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml/badge.svg)](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml)
3+
[![Tests](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml/badge.svg?label=Tests)](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml)
44
[![Coverage](https://github.com/AutomatedProcessImprovement/optimos_v2/raw/gh-pages/badges/coverage.svg?raw=true)](https://automatedprocessimprovement.github.io/optimos_v2/)
5-
[![Format](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml/badge.svg?event=push&job=format)](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml)
6-
[![Spell Check](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml/badge.svg?event=push&job=spellcheck)](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml)
7-
[![Type Check](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml/badge.svg?event=push&job=typecheck)](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml)
5+
[![Format](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml/badge.svg?event=push&job=format&label=Format)](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml)
6+
[![Spell Check](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml/badge.svg?event=push&job=spellcheck&label=Spell%20Check)](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml)
7+
[![Type Check](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml/badge.svg?event=push&job=typecheck&label=Type%20Check)](https://github.com/AutomatedProcessImprovement/optimos_v2/actions/workflows/ci.yml)
88

99
The next generation of Optimos. A Resource, Roster and Batching optimizer using Prosimos simulator.
1010

0 commit comments

Comments
 (0)