File tree Expand file tree Collapse file tree
actions/smoke-docker-image Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Smoke test Docker image
2+ description : Generate a small model with a datamodel-code-generator Docker image.
3+
4+ inputs :
5+ image :
6+ description : Docker image tag to smoke test.
7+ required : true
8+
9+ runs :
10+ using : composite
11+ steps :
12+ - name : Generate and validate model
13+ shell : bash
14+ env :
15+ SMOKE_IMAGE : ${{ inputs.image }}
16+ SMOKE_WORKSPACE : ${{ github.workspace }}
17+ run : |
18+ set -euo pipefail
19+
20+ output="$(
21+ docker run --rm \
22+ --volume "$SMOKE_WORKSPACE/tests/data/jsonschema:/data:ro" \
23+ "$SMOKE_IMAGE" \
24+ --input /data/simple_string.json \
25+ --input-file-type jsonschema \
26+ --disable-timestamp
27+ )"
28+
29+ printf '%s\n' "$output" | grep -Fqx "class Model(BaseModel):"
30+ printf '%s\n' "$output" | grep -Fqx " s: str"
31+ if printf '%s\n' "$output" | grep -Fq "timestamp:"; then
32+ echo "generated output contains a timestamp" >&2
33+ exit 1
34+ fi
Original file line number Diff line number Diff line change @@ -22,3 +22,11 @@ updates:
2222 github-actions :
2323 patterns :
2424 - " *"
25+ - package-ecosystem : docker
26+ directory : " /"
27+ schedule :
28+ interval : weekly
29+ day : thursday
30+ time : " 10:45"
31+ timezone : Asia/Tokyo
32+ open-pull-requests-limit : 5
Original file line number Diff line number Diff line change 1+ name : Docker
2+
3+ on :
4+ push :
5+ branches : [main]
6+ paths :
7+ - Dockerfile
8+ - .github/actions/smoke-docker-image/action.yml
9+ - .github/workflows/docker.yaml
10+ - .github/workflows/publish.yaml
11+ pull_request :
12+ branches : [main]
13+ paths :
14+ - Dockerfile
15+ - .github/actions/smoke-docker-image/action.yml
16+ - .github/workflows/docker.yaml
17+ - .github/workflows/publish.yaml
18+ workflow_dispatch :
19+
20+ concurrency :
21+ group : docker-${{ github.ref }}
22+ cancel-in-progress : true
23+
24+ permissions :
25+ contents : read
26+
27+ jobs :
28+ smoke :
29+ runs-on : ubuntu-24.04
30+ timeout-minutes : 20
31+ steps :
32+ - uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
33+ with :
34+ fetch-depth : 1
35+ persist-credentials : false
36+ - name : Resolve latest release version
37+ id : release
38+ run : |
39+ set -euo pipefail
40+ version="$(
41+ curl -fsSL https://pypi.org/pypi/datamodel-code-generator/json \
42+ | python3 -c 'import json, sys; print(json.load(sys.stdin)["info"]["version"])'
43+ )"
44+ echo "version=$version" >> "$GITHUB_OUTPUT"
45+ - name : Set up Docker Buildx
46+ uses : docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
47+ - name : Build Docker image
48+ uses : docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
49+ with :
50+ context : .
51+ load : true
52+ tags : datamodel-code-generator:smoke
53+ build-args : |
54+ VERSION=${{ steps.release.outputs.version }}
55+ - name : Smoke test Docker image
56+ uses : ./.github/actions/smoke-docker-image
57+ with :
58+ image : datamodel-code-generator:smoke
Original file line number Diff line number Diff line change 2020 persist-credentials : false
2121 - name : Install the latest version of uv
2222 uses : astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
23+ with :
24+ enable-cache : false
2325 - name : Build package
2426 run : uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist
2527 - name : Store the distribution packages
7779 uses : docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
7880 - name : Set up Docker Buildx
7981 uses : docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
82+ - name : Build Docker image for smoke test
83+ uses : docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
84+ with :
85+ context : .
86+ load : true
87+ tags : datamodel-code-generator:smoke
88+ build-args : |
89+ VERSION=${{ github.ref_name }}
90+ - name : Smoke test Docker image
91+ uses : ./.github/actions/smoke-docker-image
92+ with :
93+ image : datamodel-code-generator:smoke
8094 - name : Build and push
8195 uses : docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
8296 with :
Original file line number Diff line number Diff line change 1- FROM python:3.12.0-alpine3.17 as builder
1+ FROM python:3.14.2-slim-bookworm AS builder
2+
3+ ARG VERSION
4+
5+ ENV VIRTUAL_ENV=/opt/datamodel-code-generator
6+ ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
27
38LABEL maintainer="Koudai Aono <koxudaxi@gmail.com>"
49
5- RUN apk add --no-cache gcc musl-dev
10+ RUN test -n "${VERSION}" \
11+ || { echo "The VERSION build arg is required." >&2; exit 1; } \
12+ && python -m venv "${VIRTUAL_ENV}" \
13+ && pip install --no-cache-dir --upgrade pip \
14+ && pip install --no-cache-dir "datamodel-code-generator[http]==${VERSION}"
615
7- ARG VERSION
16+ FROM python:3.14.2-slim-bookworm
17+
18+ LABEL maintainer="Koudai Aono <koxudaxi@gmail.com>"
19+
20+ ENV VIRTUAL_ENV=/opt/datamodel-code-generator
21+ ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
822
9- RUN pip install "datamodel-code-generator[http]==$VERSION"
23+ RUN useradd --create-home --shell /usr/sbin/nologin appuser
24+ COPY --from=builder --chown=appuser:appuser /opt/datamodel-code-generator /opt/datamodel-code-generator
25+ USER appuser
1026
1127ENTRYPOINT ["datamodel-codegen" ]
You can’t perform that action at this time.
0 commit comments