Skip to content

Commit 65a7d02

Browse files
authored
Merge pull request #186 from pallets-eco/morernise-project-setup
Modernize project setup
2 parents 080bfd1 + 2f9a4f3 commit 65a7d02

22 files changed

+1994
-298
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
Dockerfile
22
docker-compose*
33
.git
4+
/dist/
5+
6+
/.tox/
7+
8+
/.idea/
9+
10+
/.coverage

.github/workflows/cicd.yml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
name: CI/CD
22
on:
33
push:
4+
branches:
5+
- main
46
pull_request:
57
workflow_dispatch:
68
schedule: [{cron: '1 0 * * 6'}]
79
env:
810
DOCKER_BUILDKIT: "1"
911
COMPOSE_DOCKER_CLI_BUILD: "1"
1012
BUILDKIT_PROGRESS: "plain"
11-
RELEASABLE_REPOS: "^kiorky/"
13+
RELEASABLE_REPOS: "^pallets-eco/croniter"
1214
RELEASABLE_BRANCHES: "^(refs/heads/)?(master|main|new-packaging)$"
15+
FORCE_COLOR: "true"
1316
jobs:
1417
test-code-QA:
1518
runs-on: ubuntu-latest
@@ -23,14 +26,19 @@ jobs:
2326
uses: actions/cache@v4
2427
with:
2528
path: .tox
26-
key: ${{ runner.os }}-${{ matrix.python }}-toxQA
27-
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v5
29-
with: {python-version: "${{ matrix.python-version }}", cache: pip, cache-dependency-path: 'requirements/*.txt'}
30-
- name: install tests dependencies
31-
run: pip install -r requirements/test.txt -r requirements/lint.txt -r requirements/mypy.txt -r requirements/tox.txt -r requirements/format.txt
29+
key: test-code-QA-${{ runner.os }}-${{ matrix.python }}-toxQA-${{ hashFiles('**/pyproject.toml') }}
30+
- name: Cache uv
31+
uses: actions/cache@v4
32+
with:
33+
path: ~/.cache/uv
34+
key: test-code-QA-${{ runner.os }}-${{ matrix.python }}-uvQA-${{ hashFiles('**/pyproject.toml') }}
35+
- name: Install uv and tox
36+
shell: sh
37+
run: |
38+
curl -LsSf https://astral.sh/uv/install.sh | sh
39+
uv tool install tox
3240
- name: formatters check
33-
run: tox --current-env -e lint,mypy,fmt
41+
run: tox -e lint,mypy,fmt
3442

3543
test-py3:
3644
runs-on: ubuntu-latest
@@ -44,26 +52,26 @@ jobs:
4452
uses: actions/cache@v4
4553
with:
4654
path: .tox
47-
key: ${{ runner.os }}-${{ matrix.python }}-tox
48-
- name: Set up Python ${{ matrix.python-version }}
49-
uses: actions/setup-python@v5
50-
with: {python-version: "${{ matrix.python-version }}", cache: pip, cache-dependency-path: 'requirements/*.txt'}
51-
- name: install tests dependencies
52-
run: pip install -r requirements/test.txt -r requirements/tox.txt
55+
key: test-py3-${{ runner.os }}-${{ matrix.python }}-tox-${{ hashFiles('**/pyproject.toml') }}
56+
- name: Cache uv
57+
uses: actions/cache@v4
58+
with:
59+
path: ~/.cache/uv
60+
key: test-py3-${{ runner.os }}-${{ matrix.python }}-uvQA-${{ hashFiles('**/pyproject.toml') }}
61+
- name: Install uv and tox
62+
shell: sh
63+
run: |
64+
curl -LsSf https://astral.sh/uv/install.sh | sh
65+
uv tool install tox
5366
- name: run tests with coverage
54-
run: tox --current-env -e cov
67+
run: tox -e cov
5568

5669
test-32bits:
5770
runs-on: ubuntu-latest
5871
steps:
5972
- uses: actions/checkout@v3
60-
- name: Cache tox environments
61-
uses: actions/cache@v4
62-
with:
63-
path: .dockertox
64-
key: ${{ runner.os }}-${{ matrix.python }}-dockertox
6573
- name: Test with pytest
6674
run: |
67-
docker compose build --build-arg BASE=corpusops/croniter:32bits
68-
docker compose run --rm app tox --current-env -e test
69-
env: {COMPOSE_FILE: "docker-compose.yml:docker-compose-32bits.yml"}
75+
docker compose run --build --rm --env FORCE_COLOR=true --env UV_LINK_MODE=copy app tox -e test
76+
env:
77+
COMPOSE_FILE: "docker-compose.yml:docker-compose-build.yml:docker-compose-32bits.yml"

.github/workflows/dockerimages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ env:
88
DOCKER_BUILDKIT: "1"
99
COMPOSE_DOCKER_CLI_BUILD: "1"
1010
BUILDKIT_PROGRESS: "plain"
11-
RELEASABLE_REPOS: "^kiorky/"
11+
RELEASABLE_REPOS: "^pallets-eco/croniter"
1212
RELEASABLE_BRANCHES: "^(refs/heads/)?(master|main|new-packaging)$"
1313
jobs:
1414
docker-build:
@@ -47,5 +47,5 @@ jobs:
4747
- name: Release
4848
run: |
4949
if [ "x${{steps.v.outputs.releasable}}" = "xtrue" ];then
50-
set -ex && docker push corpusops/croniter:${{matrix.FLAVOR}}
50+
set -ex && docker push pallets-eco/croniter:${{matrix.FLAVOR}}
5151
fi

Dockerfile

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,11 @@
1-
ARG RSYNC=corpusops/rsync
2-
ARG PY_VER=3.12.1
3-
ARG BASE=${BASE:-corpusops/ubuntu-bare:24.04}
4-
FROM $BASE AS base
5-
ENV CFLAGS="-I/usr/include/python3.12/"
6-
ADD apt.txt ./
7-
RUN <<EOF
8-
set -ex
9-
apt update
10-
sed -re "/^# dev deps/,$ d" /apt.txt|grep -vE "^\s*#"|tr "\n" " " > apt.runtime
11-
apt-get install -qq -y --no-install-recommends $( cat apt.runtime )
12-
if ! ( python --version );then
13-
ln -s /usr/bin/python3 /usr/bin/python
14-
fi
15-
if ! ( pip --version );then
16-
wget https://bootstrap.pypa.io/get-pip.py
17-
chmod +x get-pip.py
18-
./get-pip.py --break-system-packages
19-
fi
20-
rm -rf /var/lib/apt/lists/*
21-
EOF
22-
FROM base AS final
23-
RUN <<EOF
24-
set -ex
25-
apt update && apt-get install -qq -y --no-install-recommends $( grep -Ev '^#' apt.txt )
26-
( mkdir src || true ) && touch src/__init__.py
27-
EOF
28-
WORKDIR app
29-
ADD *.rst LICENSE MANIFEST.in *.txt *.cfg *.py *.ini ./
30-
ADD ./src/ src/
31-
ADD requirements/test.txt requirements/
32-
RUN pip install --no-cache-dir --break-system-packages -r req*/test.txt
33-
ADD requirements/lint.txt requirements/
34-
RUN pip install --no-cache-dir --break-system-packages -r req*/lint.txt
35-
ADD requirements/release.txt requirements/
36-
RUN pip install --no-cache-dir --break-system-packages -r req*/release.txt
37-
ADD requirements/tox.txt requirements/
38-
RUN pip install --no-cache-dir --break-system-packages -r req*/tox.txt
39-
RUN <<EOF
40-
set -ex
41-
apt remove -y python3-dev libpython3-dev cargo
42-
apt autoremove -y
43-
rm -rf /var/lib/apt/lists/*
44-
EOF
45-
46-
# SQUASH Stage
47-
FROM $RSYNC AS squashed-rsync
48-
FROM base AS squashed-ancestor
1+
FROM debian:bookworm-slim
2+
SHELL ["/bin/bash", "-o", "pipefail", "-o", "errexit", "-o", "nounset", "-o", "nolog", "-c"]
3+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
4+
RUN uv python install
5+
ENV PATH="/root/.local/bin:$PATH"
6+
RUN uv tool install tox
497
WORKDIR /app
50-
ARG ROOTFS="/BASE_ROOTFS_TO_COPY_THAT_WONT_COLLIDE_1234567890"
51-
ARG PATH="${ROOTFS}_rsync/bin:$PATH"
52-
RUN --mount=type=bind,from=final,target=$ROOTFS --mount=type=bind,from=squashed-rsync,target=${ROOTFS}_rsync \
53-
rsync -Aaz --delete ${ROOTFS}/ / --exclude=/proc --exclude=/sys --exclude=/etc/resolv.conf --exclude=/etc/hosts --exclude=$ROOTFS* --exclude=dev/shm --exclude=dev/pts --exclude=dev/mqueue
54-
ADD *.rst LICENSE MANIFEST.in *.txt *.cfg *.py *.ini *sh ./
8+
ADD *.rst LICENSE *.txt *.py *.ini *.sh *.toml ./
559
ADD src/ src/
5610
ENTRYPOINT ["/app/docker-entry.sh"]
5711
CMD []

MANIFEST.in

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

docker-compose-32bits.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
services:
22
app:
3-
image: "${CRONITER_IMAGE:-corpusops/croniter:32bits}"
3+
image: "${CRONITER_IMAGE:-pallets-eco/croniter:32bits}"

docker-compose-build-32bits.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
services:
22
app:
33
build:
4-
cache_from: ["${CRONITER_IMAGE:-corpusops/croniter:32bits}"]
54
args:
6-
BASE: "corpusops/debian-32:trixie"
5+
BASE: "debian-32:trixie"

docker-compose-build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
services:
22
app:
33
build:
4-
cache_from: ["${CRONITER_IMAGE:-corpusops/croniter:latest}"]
54
context: .
65
args:
76
BUILDKIT_INLINE_CACHE: "1"

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
services:
22
app:
3-
image: "${CRONITER_IMAGE:-corpusops/croniter:latest}"
3+
image: "${CRONITER_IMAGE:-pallets-eco/croniter:latest}"
44
volumes:
55
- ./docker-entry.sh:/app/docker-entry.sh
66
- ./.dockertox:/app/.tox
7-
- ./setup.cfg:/app/setup.cfg
87
- ./pyproject.toml:/app/pyproject.toml
98
- ./src:/app/src
109
- ./tox.ini:/app/tox.ini

docker-entry.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#!/usr/bin/env bash
22
[[ -n "${SDEBUG}" ]] && set -x
3-
cd /app
4-
python -m pip install -e . >/dev/null 2>&1
53
if [[ -z $@ ]];then
64
exec bash
75
else
86
exec "$@"
97
fi
10-
# vim:set et sts=4 ts=4 tw=0:

0 commit comments

Comments
 (0)