Skip to content

Commit

Permalink
chore: restructure project
Browse files Browse the repository at this point in the history
add:
- self-test workflow
- base.in and test.in requirements
- pip-tools configuration file

remove:
- commitizen configuration and CHANGELOG
- pr-build workflow
- virtualenv.in requirements (switching to venv)
  • Loading branch information
cesarcoatl committed Jul 19, 2024
1 parent 9b063ed commit 4cdf82a
Show file tree
Hide file tree
Showing 15 changed files with 387 additions and 160 deletions.
7 changes: 0 additions & 7 deletions .cz.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/pr-build.yml

This file was deleted.

76 changes: 42 additions & 34 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
name: publish

on:
release:
types:
- published
push:
branches:
- 'coatl'
paths:
- '.github/workflows/publish.yml'
- 'Dockerfile'
schedule:
- cron: '30 20 * * 1,5'

jobs:
build:
semver:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tags.outputs.version }}
major_minor: ${{ steps.tags.outputs.major_minor }}
major: ${{ steps.tags.outputs.major }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
coatldev/devpi
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract version number
id: tags
run: |
# Extract the Python version from the Dockerfile
VERSION=$(grep -oP 'devpi-server==\K[0-9]+\.[0-9]+\.[0-9]+' requirements/devpi.txt)
echo "VERSION=${VERSION}"
# Trim the version to the first two segments (major.minor)
MAJOR_MINOR=$(echo "$VERSION" | grep -oP '[0-9]+\.[0-9]+')
echo "MAJOR_MINOR=${MAJOR_MINOR}"
# Trim the version to the first segment (major)
MAJOR=$(echo "$MAJOR_MINOR" | grep -oP '^[0-9]+')
echo "MAJOR=${MAJOR}"
# Export the extracted version to GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "major_minor=${MAJOR_MINOR}" >> $GITHUB_OUTPUT
echo "major=${MAJOR}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: |
linux/amd64
linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish:
needs: semver
uses: coatl-dev/workflows/.github/workflows/docker-publish-multi-platform.yml@v4
with:
registry-image: coatldev/six
metadata-tags: |
type=raw,value=${{ needs.semver.outputs.version }}
type=raw,value=${{ needs.semver.outputs.major_minor }}
type=raw,value=${{ needs.semver.outputs.major }}
dockerhub-username: ${{ vars.DOCKERHUB_USERNAME }}
secrets:
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
81 changes: 81 additions & 0 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: self-test

on:
push:
pull_request:

env:
devpi-password: abcd1234
devpi-username: root
devpi-port: 3141

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build container
run: |
docker build -t devpi .
- name: Run container
run: |
docker run docker run \
--name devpi-server \
--detach \
--publish 3141:3141 \
--env DEVPI_PASSWORD=${{ env.devpi-password }} \
devpi
- name: Set up Python
uses: actions/setup-python@v5
id: setup-python
with:
python-version: '3.12'

- name: Cache Python
id: cache-python
uses: actions/cache@v4
with:
path: ${{ steps.setup-python.outputs.python-path }}
key: py-${{ steps.setup-python.outputs.python-version }}-${{ runner.os }}-${{ hashFiles('requirements/test.txt') }}

- name: Install requirements
run: |
python -m pip install --requirement requirements/test.txt
- name: Create the stub package importable directory
run: mkdir -pv src/test_package
- name: Populate the stub package `__init__.py`
run: echo '__version__ = "0.1"' > src/test_package/__init__.py
- name: Populate the stub package `README.md`
run: echo "# Test Package" > README.md
- name: Populate the stub package `pyproject.toml`
run: echo "$CONTENTS" > pyproject.toml
env:
CONTENTS: |
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=61.2",
]
[project]
name = "test-package"
version = "0.1"
readme = "README.md"
- name: Build the stub package
run: |
python -m build
- name: Upload package
run: |
python -m twine upload --verbose dist/*
env:
TWINE_USERNAME: ${{ env.devpi-username }}
TWINE_PASSWORD: ${{ env.devpi-password }}
TWINE_REPOSITORY_URL: http://localhost:${{ env.devpi-port }}/${{ env.devpi-username }}/public/
5 changes: 5 additions & 0 deletions .pip-tools.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.pip-tools]
allow-unsafe = true
generate-hashes = true
resolver = "backtracking"
strip-extras = false
47 changes: 0 additions & 47 deletions CHANGELOG.md

This file was deleted.

6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ RUN set -eux; \
# Copy requirements
COPY requirements /tmp/requirements/

# Install virtualenv
# Install base deps
RUN set -eux; \
\
python -m pip install \
--requirement /tmp/requirements/virtualenv.txt
--requirement /tmp/requirements/base.txt

# Create virtualenv
RUN set -eux; \
\
python -m virtualenv ${VIRTUAL_ENV}
python -m venv --upgrade-deps ${VIRTUAL_ENV}

# Prepend virtualenv to PATH
ENV PATH=${VIRTUAL_ENV}/bin:${PATH}
Expand Down
24 changes: 4 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ using [`python:3.12-slim`].

## Supported tags

- [`6`, `6.12`, `6.12.0`, `latest`] - Comes with `devpi-server` 6.12.0,
`devpi-web` 4.2.2 and `devpi-client` 7.0.3.
- [`6.11`, `6.11.0`] - Comes with `devpi-server` 6.11.0, `devpi-web` 4.2.2 and
`devpi-client` 7.0.3.
- [`6.10`, `6.10.0`] - Comes with `devpi-server` 6.10.0, `devpi-web` 4.2.1 and
`devpi-client` 7.0.2.
- [`6.9`, `6.9.2`] - Comes with `devpi-server` 6.9.2, `devpi-web` 4.2.1 and
`devpi-client` 6.0.5.
- [`6.9.1`] - Comes with `devpi-server` 6.9.1, `devpi-web` 4.2.1 and
`devpi-client` 6.0.5.
- [`6.9.0`] - Comes with `devpi-server` 6.9.0, `devpi-web` 4.2.0 and
`devpi-client` 6.0.4.
For the full list of supported tags, [click here].

## How to use this image

Expand All @@ -30,15 +19,10 @@ docker run \
--name devpi-server \
--detach \
--publish 3141:3141 \
--volume /tmp/devpi:/devpi \
--volume devpi-data:/data
--env DEVPI_PASSWORD=password \
coatldev/devpi:6.12.0
coatldev/devpi:latest
```

[`6`, `6.12`, `6.12.0`, `latest`]: https://github.com/coatl-dev/docker-devpi/blob/6.12.0/Dockerfile
[`6.11`, `6.11.0`]: https://github.com/coatl-dev/docker-devpi/blob/6.11.0/Dockerfile
[`6.10`, `6.10.0`]: https://github.com/coatl-dev/docker-devpi/blob/6.10.0/Dockerfile
[`6.9`, `6.9.2`]: https://github.com/coatl-dev/docker-devpi/blob/6.9.2/Dockerfile
[`6.9.1`]: https://github.com/coatl-dev/docker-devpi/blob/6.9.1/Dockerfile
[`6.9.0`]: https://github.com/coatl-dev/docker-devpi/blob/6.9.0/Dockerfile
[click here]: https://hub.docker.com/repository/docker/coatldev/devpi/tags
[`python:3.12-slim`]: https://github.com/docker-library/python/blob/HEAD/3.12/slim-bookworm/Dockerfile
3 changes: 3 additions & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pip
setuptools
wheel
20 changes: 20 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --allow-unsafe --config=../.pip-tools.toml --generate-hashes base.in
#
wheel==0.43.0 \
--hash=sha256:465ef92c69fa5c5da2d1cf8ac40559a8c940886afcef87dcf14b9470862f1d85 \
--hash=sha256:55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81
# via -r base.in

# The following packages are considered to be unsafe in a requirements file:
pip==24.1.2 \
--hash=sha256:7cd207eed4c60b0f411b444cd1464198fe186671c323b6cd6d433ed80fc9d247 \
--hash=sha256:e5458a0b89f2755e0ee8c0c77613fe5273e05f337907874d64f13171a898a7ff
# via -r base.in
setuptools==71.0.3 \
--hash=sha256:3d8531791a27056f4a38cd3e54084d8b1c4228ff9cf3f2d7dd075ec99f9fd70d \
--hash=sha256:f501b6e6db709818dc76882582d9c516bf3b67b948864c5fa1d1624c09a49207
# via -r base.in
14 changes: 7 additions & 7 deletions requirements/devpi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --allow-unsafe --generate-hashes devpi.in
# pip-compile --allow-unsafe --config=../.pip-tools.toml --generate-hashes devpi.in
#
anyio==4.4.0 \
--hash=sha256:5aadc6a1bbb7cdb0bede386cac5e2940f5e2ff3aa20277e991cf028e0585ce94 \
Expand Down Expand Up @@ -291,9 +291,9 @@ defusedxml==0.7.1 \
# via
# devpi-server
# devpi-web
devpi-client==7.0.3 \
--hash=sha256:3090788aa5bffe3d35f5f8e5789eab77c28b211b4982b1c2b4b744fdb3f64e0b \
--hash=sha256:e5a17a10816785fcb00de01f59237e79952968ee9d88f08fe501d3d7563f2102
devpi-client==7.1.0 \
--hash=sha256:3706e1ae88f13894a90ef324d0c6c01826e3992f33da0d729d6eb3ce056fcbf3 \
--hash=sha256:d65a16277b5a7bb47ce04b2e902f8eab6e043d975d2e8345fe40fa3a55e6b1af
# via -r devpi.in
devpi-common==4.0.4 \
--hash=sha256:235a0a9a45c96e54c60ba6ba2f77d856cf90f1a69c1bee949887e9edc03a41cc \
Expand Down Expand Up @@ -604,9 +604,9 @@ zope-interface==6.4.post2 \
# via pyramid

# The following packages are considered to be unsafe in a requirements file:
setuptools==70.3.0 \
--hash=sha256:f171bab1dfbc86b132997f26a119f6056a57950d058587841a0082e8830f9dc5 \
--hash=sha256:fe384da74336c398e0d956d1cae0669bc02eed936cdb1d49b57de1990dc11ffc
setuptools==71.0.3 \
--hash=sha256:3d8531791a27056f4a38cd3e54084d8b1c4228ff9cf3f2d7dd075ec99f9fd70d \
--hash=sha256:f501b6e6db709818dc76882582d9c516bf3b67b948864c5fa1d1624c09a49207
# via
# check-manifest
# pyramid
Expand Down
2 changes: 2 additions & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
twine
Loading

0 comments on commit 4cdf82a

Please sign in to comment.