From 2500fa351bcbb5e4f029310c4014ae770d07bcea Mon Sep 17 00:00:00 2001 From: AJ Slater Date: Fri, 23 Feb 2024 18:29:45 -0800 Subject: [PATCH] circleci build scripts --- .circleci/config.yml | 60 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 20 +++++++++++++ bin/docker-compose-exit.sh | 6 ++++ debian.sources | 11 +++++++ docker-compose.yaml | 21 +++++++++++++ pyproject.toml | 2 +- 6 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 .circleci/config.yml create mode 100644 Dockerfile create mode 100755 bin/docker-compose-exit.sh create mode 100644 debian.sources create mode 100644 docker-compose.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..65e2777 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,60 @@ +jobs: + build: + machine: + image: ubuntu-2204:current + environment: + DOCKER_CLI_EXPERIMENTAL: enabled + DOCKER_BUILDKIT: 1 + steps: + - checkout + - run: + command: docker compose build comicfn2dict-builder + name: Build Builder + - run: + command: ./bin/docker-compose-exit.sh comicfn2dict-lint + name: comicfn2dict Lint + - run: + command: ./bin/docker-compose-exit.sh comicfn2dict-test + name: comicfn2dict Test + - store_test_results: + path: test-results/pytest + - store_artifacts: + path: test-results/coverage + - run: + command: ./bin/docker-compose-exit.sh comicfn2dict-build + name: Build comicfn2dict Dist + - persist_to_workspace: + paths: + - ./README.md + - ./bin + - ./dist + - ./pyproject.toml + root: . + deploy: + docker: + - image: cimg/python:3.12.1 + steps: + - attach_workspace: + at: . + - run: + command: ./bin/publish-pypi.sh +version: 2.1 +workflows: + main: + jobs: + - build: + filters: + branches: + only: + - develop + - pre-release + - main + - deploy: + filters: + branches: + only: + - pre-release + - main + requires: + - build + version: 2.1 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..28b7b97 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM python:3.12.1-bookworm +LABEL maintainer="AJ Slater " + +COPY debian.sources /etc/apt/sources.list.d/ +# hadolint ignore=DL3008 +RUN apt-get clean \ + && apt-get update \ + && apt-get install --no-install-recommends -y \ + bash \ + npm \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY bin ./bin +COPY package.json package-lock.json pyproject.toml poetry.lock Makefile ./ +RUN make install-all + +COPY . . diff --git a/bin/docker-compose-exit.sh b/bin/docker-compose-exit.sh new file mode 100755 index 0000000..e2ad011 --- /dev/null +++ b/bin/docker-compose-exit.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Run a docker compose service and return its exit code +set -euo pipefail +SERVICE=$1 +# docker compose without the dash doesn't have the exit-code-from param +docker compose up --exit-code-from "$SERVICE" "$SERVICE" diff --git a/debian.sources b/debian.sources new file mode 100644 index 0000000..0780fac --- /dev/null +++ b/debian.sources @@ -0,0 +1,11 @@ +Types: deb +URIs: http://deb.debian.org/debian +Suites: bookworm bookworm-updates +Components: main contrib non-free +Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg + +Types: deb +URIs: http://deb.debian.org/debian-security +Suites: bookworm-security +Components: main contrib non-free +Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..c10d215 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,21 @@ +services: + comicfn2dict-builder: + build: . + image: comicfn2dict-builder + container_name: comicfn2dict-builder + comicfn2dict-lint: + image: comicfn2dict-builder + container_name: comicfn2dict-lint + command: make lint + comicfn2dict-test: + image: comicfn2dict-builder + container_name: comicfn2dict-test + command: make test + volumes: + - ./test-results/:/app/test-results/ + comicfn2dict-build: + image: comicfn2dict-builder + container_name: comicfn2dict-build + volumes: + - ./dist/:/app/dist/ + command: poetry build diff --git a/pyproject.toml b/pyproject.toml index 5f662e4..fb23c4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "comicfn2dict" -version = "0.2.0" +version = "0.2.0a0" description = "Parse common comic filenames and return a dict of metadata attributes. Includes a cli." license = "GPL-3.0-only" authors = ["AJ Slater "]