Skip to content

Commit

Permalink
Merge branch 'ci' into py-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatterson committed Feb 8, 2024
2 parents 143d461 + 950a3b0 commit 1eb81a3
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 57 deletions.
4 changes: 0 additions & 4 deletions .env.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ PROJECT_GITHUB_PAT=${PROJECT_GITHUB_PAT}

# Constants specific to this project or checkout used in variable substitutions in
# `./docker-compose*.yml`. Don't change these during the ordinary course of development:
# Make non-default `./docker-compose*.yml` files the default:
# https://pscheit.medium.com/docker-compose-advanced-configuration-541356d121de#9aa6
COMPOSE_PATH_SEPARATOR=:
COMPOSE_FILE=./docker-compose.yml:./gitlab-runner/docker-compose.yml:./docker-compose.override.yml
# Capture the path of the checkout directory as seen by the real host running `#
# dockerd` so that following bind volumes have the correct source paths:
CHECKOUT_DIR=${CHECKOUT_DIR}
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ env:
PGID: "1001"
# Project specific values:
PROJECT_NAMESPACE: "rpatterson"
PROJECT_NAME: "project-structure"
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}"
GPG_SIGNING_PRIVATE_KEY: "${{ secrets.GPG_SIGNING_PRIVATE_KEY }}"
DOCKER_PASS: "${{ secrets.DOCKER_PASS }}"
Expand Down Expand Up @@ -105,7 +104,7 @@ jobs:
git config --global --add safe.directory
/__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}
&&
init-job.sh entrypoint.sh make -j -O -e release-all
init-job.sh entrypoint.sh make -j -O release-all
# Upload build artifacts:
# https://github.com/actions/upload-artifact#usage
Expand Down Expand Up @@ -141,7 +140,7 @@ jobs:
Test Suite Reports
(${{ matrix.DOCKER_OSES }}-${{ matrix.DOCKER_LANGUAGES }})
path: >-
./build/reports/*unit.xml
./build/reports/*/*unit.xml
reporter: "java-junit"
build-test-others:
needs: ["build-test-default"]
Expand Down Expand Up @@ -184,7 +183,7 @@ jobs:
git config --global --add safe.directory
/__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}
&&
init-job.sh entrypoint.sh make -j -O -e release-all
init-job.sh entrypoint.sh make -j -O release-all
# Upload build artifacts:
# https://github.com/actions/upload-artifact#usage
Expand Down Expand Up @@ -214,5 +213,5 @@ jobs:
Test Suite Reports
(${{ matrix.DOCKER_OSES }}-${{ matrix.DOCKER_LANGUAGES }})
path: >-
./build/reports/*unit.xml
./build/reports/*/*unit.xml
reporter: "java-junit"
15 changes: 9 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ build-test-default:
script:
# Delegate steps agnostic of the CI/CD platform to the `./Makefile`:
- >-
init-job.sh entrypoint.sh make -j -O -e release-all
init-job.sh entrypoint.sh make -j -O release-all
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
# Upload build artifacts:
Expand Down Expand Up @@ -152,7 +152,7 @@ build-test-others:
script:
# Delegate steps agnostic of the CI/CD platform to the `./Makefile`:
- >-
init-job.sh entrypoint.sh make -j -O -e release-all
init-job.sh entrypoint.sh make -j -O release-all
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
# Upload build artifacts:
Expand Down Expand Up @@ -199,7 +199,10 @@ release:
PYTHON_PKG_EXISTING: "true"
script:
- >-
init-job.sh entrypoint.sh make -j -O -e release-pkgs
init-job.sh entrypoint.sh make -j -O release-pkgs
artifacts:
paths:
- "./dist/project?structure-*"

merge-upgrade:
stage: "merge-upgrade"
Expand All @@ -209,7 +212,7 @@ merge-upgrade:
$CI_COMMIT_BRANCH =~ /^.+-upgrade$/
script:
- >-
init-job.sh entrypoint.sh make -j -O -e VCS_BRANCH_SUFFIX="upgrade" devel-merge
init-job.sh entrypoint.sh make -j -O VCS_BRANCH_SUFFIX="upgrade" devel-merge
release-bump:
stage: "release-bump"
Expand All @@ -233,7 +236,7 @@ release-bump:
&& $CI_PIPELINE_SOURCE != "schedule"
script:
- >-
init-job.sh entrypoint.sh make -j -O -e release-bump
init-job.sh entrypoint.sh make -j -O release-bump
# Workaround GitLab's handling of pipeline status when pushing both a branch and a tag:
release-version:
Expand Down Expand Up @@ -278,4 +281,4 @@ scheduled:
- "py311"
script:
- >-
init-job.sh entrypoint.sh make -j -O -e $SCHEDULED_TARGETS
init-job.sh entrypoint.sh make -j -O $SCHEDULED_TARGETS
64 changes: 32 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ PYTHON_REQUIREMENTS_INS=$(wildcard ./requirements/*.txt.in)
PYTHON_REQUIREMENTS_BASENAMES=$(PYTHON_REQUIREMENTS_INS:./requirements/%.in=%)
PYTHON_PROJECT_PACKAGE=$(subst -,,$(PROJECT_NAME))
PYTHON_PROJECT_GLOB=$(subst -,?,$(PROJECT_NAME))
PYTHON_PKG_EXISTING=false
PYTHON_PKG_EXISTING?=false

# Values derived from Version Control Systems (VCS):
VCS_LOCAL_BRANCH:=$(shell git branch --show-current)
CI_COMMIT_BRANCH=
GITHUB_REF_TYPE=
GITHUB_REF_NAME=
CI_COMMIT_BRANCH?=
GITHUB_REF_TYPE?=
GITHUB_REF_NAME?=
ifeq ($(VCS_LOCAL_BRANCH),)
ifneq ($(CI_COMMIT_BRANCH),)
VCS_LOCAL_BRANCH=$(CI_COMMIT_BRANCH)
Expand All @@ -170,7 +170,7 @@ VCS_LOCAL_BRANCH=$(GITHUB_REF_NAME)
endif
endif
VCS_TAG=
CI_COMMIT_TAG=
CI_COMMIT_TAG?=
ifeq ($(VCS_TAG),)
ifneq ($(CI_COMMIT_TAG),)
VCS_TAG=$(CI_COMMIT_TAG)
Expand Down Expand Up @@ -276,18 +276,18 @@ DOCKER_REQUIREMENTS_TARGETS=$(foreach language,$(PYTHON_ENVS)\
,$(foreach basename,$(PYTHON_REQUIREMENTS_BASENAMES)\
,$(DOCKER_OS_DEFAULT_VAR)-$(language)/log/requirements/$(basename).log))
TEST_CODE_PREREQS=./var/log/build-pkgs.log
GITLAB_CI=false
GITHUB_ACTIONS=false
CI_PROJECT_NAMESPACE=$(CI_UPSTREAM_NAMESPACE)
CI_TEMPLATE_REGISTRY_HOST=registry.gitlab.com
GITLAB_CI?=false
GITHUB_ACTIONS?=false
CI_PROJECT_NAMESPACE?=$(CI_UPSTREAM_NAMESPACE)
CI_TEMPLATE_REGISTRY_HOST?=registry.gitlab.com
ifeq ($(GITHUB_ACTIONS),true)
DOCKER_REGISTRY_HOST=ghcr.io
else
DOCKER_REGISTRY_HOST=$(CI_TEMPLATE_REGISTRY_HOST)
endif
export DOCKER_REGISTRY_HOST
CI_REGISTRY=$(CI_TEMPLATE_REGISTRY_HOST)/$(CI_PROJECT_NAMESPACE)
CI_REGISTRY_IMAGE=$(CI_REGISTRY)/$(CI_PROJECT_NAME)
CI_REGISTRY?=$(CI_TEMPLATE_REGISTRY_HOST)/$(CI_PROJECT_NAMESPACE)
CI_REGISTRY_IMAGE?=$(CI_REGISTRY)/$(CI_PROJECT_NAME)
DOCKER_REGISTRIES=GITLAB GITHUB DOCKER
DOCKER_REGISTRY=$(firstword $(DOCKER_REGISTRIES))
ifeq ($(GITHUB_ACTIONS),true)
Expand All @@ -296,7 +296,7 @@ endif
export DOCKER_REGISTRY
DOCKER_IMAGE_GITLAB=$(CI_REGISTRY_IMAGE)
DOCKER_IMAGE_GITHUB=ghcr.io/$(CI_PROJECT_NAMESPACE)/$(CI_PROJECT_NAME)
DOCKER_IMAGE_DOCKER=$(DOCKER_USER)/$(CI_PROJECT_NAME)
DOCKER_IMAGE_DOCKER=$(DOCKER_NAMESPACE)/$(PROJECT_NAME)
export DOCKER_IMAGE=$(DOCKER_IMAGE_$(DOCKER_REGISTRY))
DOCKER_IMAGES=
ifeq ($(GITLAB_CI),true)
Expand All @@ -306,6 +306,9 @@ DOCKER_IMAGES+=$(DOCKER_IMAGE_GITHUB)
else
DOCKER_IMAGES+=$(DOCKER_IMAGE_DOCKER)
endif
export DOCKER_PASS?=
DOCKER_COMPOSE_RUN_CMD=docker compose run --rm -T --quiet-pull
TEST_CODE_PREREQS=./var/log/build-pkgs.log

# Run Python tools in isolated environments managed by Tox:
# Values used to run Tox:
Expand All @@ -324,13 +327,13 @@ TOX_BUILD_BINS=pre-commit cz towncrier rstcheck sphinx-build sphinx-autobuild \

# Values derived from or overridden by CI environments:
CI_UPSTREAM_NAMESPACE=$(PROJECT_NAMESPACE)
CI_PROJECT_NAME=$(PROJECT_NAME)
CI_PROJECT_NAME?=$(PROJECT_NAME)
ifeq ($(CI),true)
TEMPLATE_IGNORE_EXISTING=true
endif
GITHUB_REPOSITORY_OWNER=$(CI_UPSTREAM_NAMESPACE)
GITHUB_REPOSITORY_OWNER?=$(CI_UPSTREAM_NAMESPACE)
# Is this checkout a fork of the upstream project?:
CI_IS_FORK=false
CI_IS_FORK?=false
ifeq ($(GITLAB_CI),true)
USER_EMAIL=$(USER_NAME)@runners-manager.gitlab.com
ifneq ($(VCS_BRANCH),develop)
Expand Down Expand Up @@ -359,14 +362,14 @@ endif
DOCKER_IMAGES+=$(DOCKER_IMAGE)
# Take GitHub auth from the environment under GitHub actions but from secrets on other
# project hosts:
GITHUB_TOKEN=
PROJECT_GITHUB_PAT=
GITHUB_TOKEN?=
PROJECT_GITHUB_PAT?=
ifeq ($(GITHUB_TOKEN),)
GITHUB_TOKEN=$(PROJECT_GITHUB_PAT)
GITHUB_TOKEN?=$(PROJECT_GITHUB_PAT)
else ifeq ($(PROJECT_GITHUB_PAT),)
PROJECT_GITHUB_PAT=$(GITHUB_TOKEN)
endif
GH_TOKEN=$(GITHUB_TOKEN)
GH_TOKEN?=$(GITHUB_TOKEN)
export GH_TOKEN
export GITHUB_TOKEN
export PROJECT_GITHUB_PAT
Expand Down Expand Up @@ -402,23 +405,20 @@ DOCKER_PLATFORMS=linux/amd64 linux/arm64 linux/arm/v7
endif
endif
endif
CI_REGISTRY_USER=$(CI_PROJECT_NAMESPACE)
CI_REGISTRY_USER?=$(CI_PROJECT_NAMESPACE)
# Avoid undefined variables warnings when running under local development:
PYPI_PASSWORD?=
export PYPI_PASSWORD
TEST_PYPI_PASSWORD?=
export TEST_PYPI_PASSWORD
VCS_REMOTE_PUSH_URL=
CODECOV_TOKEN=
DOCKER_PASS=
export DOCKER_PASS
CI_PROJECT_ID=
VCS_REMOTE_PUSH_URL?=
CODECOV_TOKEN?=
CI_PROJECT_ID?=
export CI_PROJECT_ID
CI_JOB_TOKEN=
CI_JOB_TOKEN?=
export CI_JOB_TOKEN
CI_REGISTRY_PASSWORD=
CI_REGISTRY_PASSWORD?=
export CI_REGISTRY_PASSWORD
GH_TOKEN=

# https://www.sphinx-doc.org/en/master/usage/builders/index.html
# Run these Sphinx builders to test the correctness of the documentation:
Expand Down Expand Up @@ -951,8 +951,8 @@ release: release-pkgs release-docker

.PHONY: release-pkgs
## Publish installable Python packages to PyPI if conventional commits require.
release-pkgs: ./var/log/build-pkgs.log $(HOME)/.local/bin/tox ~/.pypirc.~out~ \
./var/log/docker-compose-network.log ./var/log/git-fetch.log
release-pkgs: ./var/log/build-pkgs.log ./var/log/docker-compose-network.log \
./var/log/git-fetch.log
$(MAKE) test-clean
# Don't release unless from the `main` or `develop` branches:
ifeq ($(RELEASE_PUBLISH),true)
Expand Down Expand Up @@ -1753,8 +1753,8 @@ $(HOST_PREFIX)/bin/curl:
$(HOST_PKG_CMD) $(HOST_PKG_INSTALL_ARGS) "$(HOST_PKG_NAMES_CURL)"

# GNU Privacy Guard (GPG) signing key creation and management in CI:
export GPG_PASSPHRASE=
GPG_SIGNING_PRIVATE_KEY=
export GPG_PASSPHRASE?=
GPG_SIGNING_PRIVATE_KEY?=
./var/ci-cd-signing-subkey.asc: $(HOST_PREFIX)/bin/gpg
# Signing release commits and artifacts requires a GPG private key in the CI/CD
# environment. Use a subkey that you can revoke without affecting your main key. This
Expand Down
5 changes: 4 additions & 1 deletion build-host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
PS1?=$$

DOCKER_IMAGES=registry.gitlab.com/rpatterson/project-structure
DOCKER_IMAGES=\
registry.gitlab.com/rpatterson/project-structure \
ghcr.io/rpatterson/project-structure \
merpatterson/project-structure
DOCKER_IMAGE=$(firstword $(DOCKER_IMAGES))


Expand Down
5 changes: 0 additions & 5 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ services:

## Containers for simulating CI/CD:

# The container that runs CI/CD:
build-host:
image: "\
${DOCKER_REGISTRY_HOST:-registry.gitlab.com}/rpatterson/project-structure\
Expand Down Expand Up @@ -219,7 +218,3 @@ services:
# DEBUG: "true"
command: >-
make -j -O release-all
gitlab-runner:
profiles:
- "ci"
6 changes: 2 additions & 4 deletions styles/config/vocabularies/Code/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ allows
yaml
kill
[Gg]it
HEAD
head
[Hh][Ee][Aa][Dd]
via
[Ii][Nn][Ff][Oo]
PUID
Expand All @@ -51,8 +50,7 @@ junit
failure
[Cc]odecov
gh
GPG
gpg
[Gg][Pp][Gg]
gpgconf
agent
dummy
Expand Down

0 comments on commit 1eb81a3

Please sign in to comment.