diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml index acb3249..f328164 100644 --- a/.woodpecker/build.yaml +++ b/.woodpecker/build.yaml @@ -6,13 +6,22 @@ depends_on: - test steps: -# isitatag: -# image: ghcr.io/astral-sh/uv:python3.13-alpine -# when: -# evaluate: '"CI_COMMIT_TAG" in $env' + container_build_release_push: + #image: docker.io/maltegrosse/woodpecker-buildah:0.0.12 + image: code.philo.ydns.eu/philorg/woodpecker-buildah + settings: + registry: code.philo.ydns.eu + repository: philorg/test-woodpecker-python + tags: ${CI_COMMIT_SHA} + architectures: amd64 + context: Containerfile + username: + from_secret: registry_username + password: + from_secret: registry_password sync: - image: ghcr.io/astral-sh/uv:python3.13-alpine + image: code.philo.ydns.eu/philorg/uv volumes: - uv-cache:/uv-cache environment: @@ -22,7 +31,7 @@ steps: - uv sync build: - image: ghcr.io/astral-sh/uv:python3.13-alpine + image: code.philo.ydns.eu/philorg/uv volumes: - uv-cache:/uv-cache environment: @@ -32,27 +41,13 @@ steps: - uv build --wheel - uv cache prune --ci - - - push_python: -# TODO: when git tag - image: code.philo.ydns.eu/philorg/twine + image: code.philo.ydns.eu/philorg/uv environment: OWNER: philorg REGISTRY_URL: https://code.philo.ydns.eu - USERNAME: - from_secret: forgejo_username - PASSWORD: - from_secret: forgejo_password + REGISTRY_TOKEN: + from_secret: registry_token commands: - - twine upload --repository-url $REGISTRY_URL/api/packages/$OWNER/pypi -u $USERNAME -p $PASSWORD --non-interactive dist/*.whl + - uv publish --publish-url $REGISTRY_URL/api/packages/$OWNER/pypi --token $REGISTRY_TOKEN dist/*.whl failure: ignore - -# TODO: container - # For podman build: see https://woodpecker-ci.org/blog/podman-image-build-sigstore - # podman-privileged-test: - # image: quay.io/podman/stable - # commands: - # - echo From https://docs.gitlab.com/runner/executors/kubernetes/use_podman_with_kubernetes/ - # - podman build . -t playground-bis:testing diff --git a/.woodpecker/test.yaml b/.woodpecker/test.yaml index a649443..6326edc 100644 --- a/.woodpecker/test.yaml +++ b/.woodpecker/test.yaml @@ -2,11 +2,11 @@ when: - event: push branch: main - event: manual + - event: tag steps: - sync: - image: ghcr.io/astral-sh/uv:python3.13-alpine + image: code.philo.ydns.eu/philorg/uv volumes: - uv-cache:/uv-cache environment: @@ -16,7 +16,6 @@ steps: - uv sync test: - #image: ghcr.io/astral-sh/uv:alpine image: ghcr.io/astral-sh/uv:python3.13-alpine commands: - .venv/bin/pytest -s tests/basic.py diff --git a/Containerfile b/Containerfile index 373e514..f875859 100644 --- a/Containerfile +++ b/Containerfile @@ -1,15 +1,16 @@ -# Build: podman build -t code.philo.ydns.eu/k-net/knoc -f Containerfile +# Build: podman build -t code.philo.ydns.eu/philorg/test-woodpecker -f Containerfile -FROM docker.io/python:3.13-slim -#RUN apk add --no-cache git -COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/ -COPY --from=docker.io/python:3.13 /usr/bin/git /usr/local/bin/git +FROM docker.io/python:alpine COPY . /app -# Sync the project into a new environment, using the frozen lockfile WORKDIR /app -RUN uv pip install --system . +# Sync the project into a new environment, using the frozen lockfile +RUN \ + --mount=from=code.philo.ydns.eu/philorg/uv,source=/usr/local/bin/uv,target=/bin/uv \ + --mount=from=code.philo.ydns.eu/philorg/uv,source=/usr/lib/libpcre2-8.so.0,target=/usr/lib/libpcre2-8.so.0 \ + --mount=from=code.philo.ydns.eu/philorg/uv,source=/usr/bin/git,target=/usr/bin/git \ + uv pip install --system . -ENTRYPOINT ["knoc"] +ENTRYPOINT ["foo"] diff --git a/README.md b/README.md index 53ef454..26634f9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # test-woodpecker-ci -Yo +[![status-badge](https://code.philo.ydns.eu/woodpecker/api/badges/5/status.svg)](https://code.philo.ydns.eu/woodpecker/repos/5) + +This is a sandbox for building packages (pypi and container) with Woodpecker CI. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index e3d35d6..55559fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,22 +1,31 @@ [project] name = "test-woodpecker-ci" -version = "0.1.0" -description = "Add your description here" +dynamic = ["version"] +description = "Sandbox for Woodpecker CI" readme = "README.md" requires-python = ">=3.13" dependencies = [] [project.scripts] foo = "test_woodpecker_ci.main:main" + [build-system] -requires = ["hatchling"] +requires = ["hatchling", "uv-dynamic-versioning"] build-backend = "hatchling.build" +[tool.hatch.version] +source = "uv-dynamic-versioning" + [tool.hatch.build.targets.wheel] packages = ["src/test_woodpecker_ci"] [dependency-groups] -dev = [ - "httpx>=0.28.1", - "pytest>=8.4.1", +dev = ["dunamai>=1.24.1", "httpx>=0.28.1", "pytest>=8.4.1"] + +[tool.uv-dynamic-versioning] +style = "semver" + +[tool.uv] +extra-index-url = [ + "https://code.philo.ydns.eu/api/packages/philorg/pypi/simple/", ] diff --git a/src/test_woodpecker_ci/__init__.py b/src/test_woodpecker_ci/__init__.py new file mode 100644 index 0000000..6da5d7b --- /dev/null +++ b/src/test_woodpecker_ci/__init__.py @@ -0,0 +1,10 @@ +import importlib.metadata + +try: + from dunamai import Version, Style + + __version__ = Version.from_git().serialize(style=Style.SemVer, dirty=True) +except ImportError: + # __name__ can be used if the package name is the same + # as the directory. Otherwise, specify it explicitely. + __version__ = importlib.metadata.version(__name__) diff --git a/tests/basic.py b/tests/basic.py index 30e2c41..c6881ce 100644 --- a/tests/basic.py +++ b/tests/basic.py @@ -1,2 +1,6 @@ -def test_foo(): +def test_ok(): assert True + + +def no_test_fail(): + assert False diff --git a/uv.lock b/uv.lock index 72afab8..2cb8967 100644 --- a/uv.lock +++ b/uv.lock @@ -33,6 +33,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, ] +[[package]] +name = "dunamai" +version = "1.24.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "packaging" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/54/22/7f46b0146ef614cd6f80e4bcb188dabe33e90b4e0af028e16f597f5826ad/dunamai-1.24.1.tar.gz", hash = "sha256:3aa3348f77242da8628b23f11e89569343440f0f912bcef32a1fa891cf8e7215", size = 45616, upload-time = "2025-05-09T13:48:46.417Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1d/d6/6ed8b439906ca2e88d65bddf002e21239678aca6001d8fb82e8e2b196245/dunamai-1.24.1-py3-none-any.whl", hash = "sha256:4370e406d8ce195fc4b066b5c326bfa9adb269c4b8719b4e4fd90b63a2144bf7", size = 26654, upload-time = "2025-05-09T13:48:45.442Z" }, +] + [[package]] name = "h11" version = "0.16.0" @@ -142,11 +154,11 @@ wheels = [ [[package]] name = "test-woodpecker-ci" -version = "0.1.0" source = { editable = "." } [package.dev-dependencies] dev = [ + { name = "dunamai" }, { name = "httpx" }, { name = "pytest" }, ] @@ -155,6 +167,7 @@ dev = [ [package.metadata.requires-dev] dev = [ + { name = "dunamai", specifier = ">=1.24.1" }, { name = "httpx", specifier = ">=0.28.1" }, { name = "pytest", specifier = ">=8.4.1" }, ]