Skip to content

Commit

Permalink
refactor build toolchain
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain Hellegouarch <[email protected]>
  • Loading branch information
Lawouach committed Dec 2, 2024
1 parent 99d5eb8 commit c59103f
Show file tree
Hide file tree
Showing 18 changed files with 2,706 additions and 235 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*
!requirements.txt
!py12-linux.lock
!pyproject.toml
!README.md
!chaosreport
59 changes: 32 additions & 27 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build, Test, and Lint
name: Build

on:
push:
Expand All @@ -8,31 +8,36 @@ on:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: ["ubuntu-24.04", "macos-latest"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
- name: Build the package
run : |
make build
- uses: actions/checkout@v4
with:
fetch-depth: 0

lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install dependencies
run: |
make install-dev
- name: Lint
run: |
make lint
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
cache: true
prerelease: true

- name: Ensure lock file is up to date
run: |
pdm lock --check
pdm lock --lockfile py12-linux.lock --check
- name: Install dependencies
run: |
pdm sync -d
- name: Run Lint
run: |
pdm run lint
- name: Run Tests
run: |
pdm run test
48 changes: 23 additions & 25 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,59 +1,57 @@
name: Release

on:
pull_request:
branches-ignore:
- 'main'
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+rc[0-9]+'

jobs:
release-to-pypi:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.7'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine
- name: Build and publish
cache: true
- name: Build
run: pdm build
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PWD }}
run: |
python3 setup.py release
twine upload dist/*
# push artifacts for other jobs to use
PDM_BUILD_SCM_VERSION: ${{github.ref_name}}
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Upload packages as artifacts
uses: actions/upload-artifact@v2-preview
uses: actions/upload-artifact@v4
with:
name: chaostoolkit-reporting-packages
path: dist/chaostoolkit_reporting-*
path: dist/lueur*

create-gh-release:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Create Release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
name: Release ${{ github.ref }}
draft: false
prerelease: false

upload-gh-release-assets:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
needs:
- create-gh-release
- release-to-pypi
steps:
- name: Download pypi artifacts
uses: actions/download-artifact@v2-preview
uses: actions/download-artifact@v4
with:
name: chaostoolkit-reporting-packages
path: dist
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,8 @@ junit-test-results.xml


journal*.json
report.*
report.*
.ruff_cache/
.pytest_cache/
.pdm-build/
.pdm-python
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

## [Unreleased][]

[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-reporting/compare/0.17.2...HEAD
[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-reporting/compare/0.18.0...HEAD

## [0.18.0][] - 2024-12-02

[0.18.0]: https://github.com/chaostoolkit/chaostoolkit-reporting/compare/0.17.2...0.18.0

### Changed

- Refactor the build toolchain to use PDM instead of pip
- Requires now Python 3.10 at minimum due to numpy undirect dependency

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

Expand Down
30 changes: 15 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
FROM ubuntu:latest
FROM ubuntu:24.04

LABEL maintainer="chaostoolkit <[email protected]>"
# you can overwrite this otherwise just leave it as-is as placeholder for
# pdm to be happy
ARG PDM_BUILD_SCM_VERSION=0.0.0

RUN groupadd -g 1001 svc && useradd -r -u 1001 -g svc svc
WORKDIR /home/svc
COPY . /home/svc

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

ENTRYPOINT ["/usr/local/bin/chaos"]
ENTRYPOINT ["/home/svc/.venv/bin/chaos"]
CMD ["report", "--export-format=pdf", "/tmp/result/journal.json", "/tmp/result/report.pdf"]
7 changes: 0 additions & 7 deletions MANIFEST.in

This file was deleted.

28 changes: 0 additions & 28 deletions Makefile

This file was deleted.

14 changes: 9 additions & 5 deletions chaosreport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import io
import itertools
import json
import logging
import os
import os.path
import shlex
Expand All @@ -10,6 +11,7 @@
import tempfile
from base64 import b64encode
from datetime import datetime, timedelta
from importlib.metadata import version, PackageNotFoundError
from typing import Any, Dict, List

import cairosvg
Expand All @@ -24,7 +26,6 @@
from chaoslib.caching import cache_activities, lookup_activity
from chaoslib.types import Configuration, Experiment, Journal, Run, Secrets
from jinja2 import Environment, PackageLoader
from logzero import logger
from natural import date
from pygal.style import DefaultStyle, LightColorizedStyle

Expand All @@ -34,7 +35,12 @@
"generate_report_header",
"save_report",
]
__version__ = "0.17.2"
try:
__version__ = version("chaostoolkit-reporting")
except PackageNotFoundError:
__version__ = "unknown"

logger = logging.getLogger("chaostoolkit")

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

if export_format in ["html", "html5"]:
run["charts"].append(
chart.render(disable_xml_declaration=True)
) # noqa
run["charts"].append(chart.render(disable_xml_declaration=True)) # noqa
else:
run["charts"].append(
b64encode(
Expand Down
Loading

0 comments on commit c59103f

Please sign in to comment.