Skip to content

Commit c59103f

Browse files
committed
refactor build toolchain
Signed-off-by: Sylvain Hellegouarch <[email protected]>
1 parent 99d5eb8 commit c59103f

File tree

18 files changed

+2706
-235
lines changed

18 files changed

+2706
-235
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
*
2-
!requirements.txt
2+
!py12-linux.lock
3+
!pyproject.toml
4+
!README.md
5+
!chaosreport

.github/workflows/build.yaml

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build, Test, and Lint
1+
name: Build
22

33
on:
44
push:
@@ -8,31 +8,36 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-22.04
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
python-version: ["3.10", "3.11", "3.12"]
15+
os: ["ubuntu-24.04", "macos-latest"]
1216
steps:
13-
- uses: actions/checkout@v3
14-
- name: Set up Python
15-
uses: actions/setup-python@v4
16-
with:
17-
python-version: '3.7'
18-
- name: Install dependencies
19-
run: |
20-
python -m pip install --upgrade pip setuptools wheel
21-
- name: Build the package
22-
run : |
23-
make build
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
2420

25-
lint:
26-
runs-on: ubuntu-22.04
27-
steps:
28-
- uses: actions/checkout@v3
29-
- name: Set up Python
30-
uses: actions/setup-python@v4
31-
with:
32-
python-version: '3.7'
33-
- name: Install dependencies
34-
run: |
35-
make install-dev
36-
- name: Lint
37-
run: |
38-
make lint
21+
- name: Set up PDM
22+
uses: pdm-project/setup-pdm@v4
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
cache: true
26+
prerelease: true
27+
28+
- name: Ensure lock file is up to date
29+
run: |
30+
pdm lock --check
31+
pdm lock --lockfile py12-linux.lock --check
32+
33+
- name: Install dependencies
34+
run: |
35+
pdm sync -d
36+
37+
- name: Run Lint
38+
run: |
39+
pdm run lint
40+
41+
- name: Run Tests
42+
run: |
43+
pdm run test

.github/workflows/release.yaml

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,57 @@
11
name: Release
22

33
on:
4+
pull_request:
5+
branches-ignore:
6+
- 'main'
47
push:
58
tags:
69
- '[0-9]+.[0-9]+.[0-9]+'
710
- '[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
811

912
jobs:
1013
release-to-pypi:
11-
runs-on: ubuntu-22.04
14+
runs-on: ubuntu-24.04
15+
environment: release
16+
permissions:
17+
id-token: write
1218
steps:
13-
- uses: actions/checkout@v3
14-
- name: Set up Python
15-
uses: actions/setup-python@v4
19+
- uses: actions/checkout@v4
20+
- name: Set up PDM
21+
uses: pdm-project/setup-pdm@v4
1622
with:
17-
python-version: '3.7'
18-
- name: Install dependencies
19-
run: |
20-
python -m pip install --upgrade pip
21-
pip install --upgrade setuptools wheel twine
22-
- name: Build and publish
23+
cache: true
24+
- name: Build
25+
run: pdm build
2326
env:
24-
TWINE_USERNAME: __token__
25-
TWINE_PASSWORD: ${{ secrets.PYPI_PWD }}
26-
run: |
27-
python3 setup.py release
28-
twine upload dist/*
29-
# push artifacts for other jobs to use
27+
PDM_BUILD_SCM_VERSION: ${{github.ref_name}}
28+
- name: Publish package distributions to PyPI
29+
uses: pypa/gh-action-pypi-publish@release/v1
3030
- name: Upload packages as artifacts
31-
uses: actions/upload-artifact@v2-preview
31+
uses: actions/upload-artifact@v4
3232
with:
3333
name: chaostoolkit-reporting-packages
34-
path: dist/chaostoolkit_reporting-*
34+
path: dist/lueur*
3535

3636
create-gh-release:
37-
runs-on: ubuntu-22.04
37+
runs-on: ubuntu-24.04
3838
steps:
3939
- name: Create Release
40-
uses: actions/create-release@latest
41-
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
40+
uses: softprops/action-gh-release@v2
4341
with:
4442
tag_name: ${{ github.ref }}
45-
release_name: Release ${{ github.ref }}
43+
name: Release ${{ github.ref }}
4644
draft: false
4745
prerelease: false
4846

4947
upload-gh-release-assets:
50-
runs-on: ubuntu-22.04
48+
runs-on: ubuntu-24.04
5149
needs:
5250
- create-gh-release
5351
- release-to-pypi
5452
steps:
5553
- name: Download pypi artifacts
56-
uses: actions/download-artifact@v2-preview
54+
uses: actions/download-artifact@v4
5755
with:
5856
name: chaostoolkit-reporting-packages
5957
path: dist

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,8 @@ junit-test-results.xml
114114

115115

116116
journal*.json
117-
report.*
117+
report.*
118+
.ruff_cache/
119+
.pytest_cache/
120+
.pdm-build/
121+
.pdm-python

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

33
## [Unreleased][]
44

5-
[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-reporting/compare/0.17.2...HEAD
5+
[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-reporting/compare/0.18.0...HEAD
6+
7+
## [0.18.0][] - 2024-12-02
8+
9+
[0.18.0]: https://github.com/chaostoolkit/chaostoolkit-reporting/compare/0.17.2...0.18.0
10+
11+
### Changed
12+
13+
- Refactor the build toolchain to use PDM instead of pip
14+
- Requires now Python 3.10 at minimum due to numpy undirect dependency
615

716
## [0.17.2][] - 2024-12-02
817

Dockerfile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
FROM ubuntu:latest
1+
FROM ubuntu:24.04
22

3-
LABEL maintainer="chaostoolkit <[email protected]>"
3+
# you can overwrite this otherwise just leave it as-is as placeholder for
4+
# pdm to be happy
5+
ARG PDM_BUILD_SCM_VERSION=0.0.0
6+
7+
RUN groupadd -g 1001 svc && useradd -r -u 1001 -g svc svc
8+
WORKDIR /home/svc
9+
COPY . /home/svc
410

5-
ADD requirements.txt requirements.txt
611
RUN export DEBIAN_FRONTEND=noninteractive && \
7-
apt-get update && \
8-
apt-get install -y python3 \
9-
python3-pip \
10-
texlive-latex-base \
11-
texlive-fonts-recommended \
12-
texlive-latex-extra \
13-
curl \
14-
pandoc && \
15-
pip install --no-cache-dir -U pip && \
16-
pip install --no-cache-dir -r requirements.txt && \
17-
pip install --no-cache-dir -U chaostoolkit chaostoolkit-reporting && \
12+
apt-get update -y && \
13+
apt-get install -y --no-install-recommends build-essential curl gcc texlive-latex-base texlive-fonts-recommended texlive-latex-extra pandoc && \
14+
apt-get install -y python3.12 python3.12-dev python3-pip python3.12-venv && \
15+
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 - && \
16+
export PATH=/root/.local/bin:$PATH && \
17+
pdm install -v --prod -G ctk --no-editable --lock /py12-linux.lock && \
1818
apt autoremove && \
1919
apt autoclean && \
2020
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
@@ -23,5 +23,5 @@ ENV MPLCONFIGDIR=/tmp/result/
2323
VOLUME /tmp/result
2424
WORKDIR /tmp/result
2525

26-
ENTRYPOINT ["/usr/local/bin/chaos"]
26+
ENTRYPOINT ["/home/svc/.venv/bin/chaos"]
2727
CMD ["report", "--export-format=pdf", "/tmp/result/journal.json", "/tmp/result/report.pdf"]

MANIFEST.in

Lines changed: 0 additions & 7 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 28 deletions
This file was deleted.

chaosreport/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import io
33
import itertools
44
import json
5+
import logging
56
import os
67
import os.path
78
import shlex
@@ -10,6 +11,7 @@
1011
import tempfile
1112
from base64 import b64encode
1213
from datetime import datetime, timedelta
14+
from importlib.metadata import version, PackageNotFoundError
1315
from typing import Any, Dict, List
1416

1517
import cairosvg
@@ -24,7 +26,6 @@
2426
from chaoslib.caching import cache_activities, lookup_activity
2527
from chaoslib.types import Configuration, Experiment, Journal, Run, Secrets
2628
from jinja2 import Environment, PackageLoader
27-
from logzero import logger
2829
from natural import date
2930
from pygal.style import DefaultStyle, LightColorizedStyle
3031

@@ -34,7 +35,12 @@
3435
"generate_report_header",
3536
"save_report",
3637
]
37-
__version__ = "0.17.2"
38+
try:
39+
__version__ = version("chaostoolkit-reporting")
40+
except PackageNotFoundError:
41+
__version__ = "unknown"
42+
43+
logger = logging.getLogger("chaostoolkit")
3844

3945
curdir = os.getcwd()
4046
basedir = os.path.dirname(__file__)
@@ -664,9 +670,7 @@ def add_chart(chart: pygal.Graph):
664670
run["charts"] = []
665671

666672
if export_format in ["html", "html5"]:
667-
run["charts"].append(
668-
chart.render(disable_xml_declaration=True)
669-
) # noqa
673+
run["charts"].append(chart.render(disable_xml_declaration=True)) # noqa
670674
else:
671675
run["charts"].append(
672676
b64encode(

0 commit comments

Comments
 (0)