Prepare for GitHub migration #32
@@ -0,0 +1 @@
|
||||
* @IUCLabs/maintainers
|
||||
@@ -0,0 +1,3 @@
|
||||
self-hosted-runner:
|
||||
labels:
|
||||
- iuclabs-release
|
||||
@@ -0,0 +1,45 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
permissions: {}
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
uses: IUCLabs/workflows/.github/workflows/pre-commit.yml@v0.1.1
|
||||
permissions:
|
||||
contents: read
|
||||
with:
|
||||
go_version_file: go.mod
|
||||
|
||||
actions:
|
||||
uses: IUCLabs/workflows/.github/workflows/actions.yml@v0.1.1
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
go:
|
||||
uses: IUCLabs/workflows/.github/workflows/go-ci.yml@v0.1.1
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
with:
|
||||
# e2e tests sit behind the e2e build tag and need Docker, so they stay out
|
||||
test_args: -count=1 ./...
|
||||
|
||||
image:
|
||||
uses: IUCLabs/workflows/.github/workflows/release-go-image.yml@v0.1.1
|
||||
# the called job declares packages: write for the push; push: false uses none of it
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
with:
|
||||
main: .
|
||||
push: false
|
||||
runs_on: ubuntu-latest
|
||||
@@ -0,0 +1,16 @@
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v[0-9]*"]
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
uses: IUCLabs/workflows/.github/workflows/release-go-image.yml@v0.1.1
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
with:
|
||||
main: .
|
||||
@@ -0,0 +1,11 @@
|
||||
rules:
|
||||
unpinned-uses:
|
||||
config:
|
||||
policies:
|
||||
# shared workflows are pinned to their release tags
|
||||
"IUCLabs/*": ref-pin
|
||||
"*": hash-pin
|
||||
archived-uses:
|
||||
ignore:
|
||||
# dnephin/pre-commit-golang is archived but its hooks still work
|
||||
- .pre-commit-config.yaml
|
||||
@@ -0,0 +1,6 @@
|
||||
defaultBaseImage: gcr.io/distroless/static-debian12:nonroot
|
||||
builds:
|
||||
- id: pdbmux
|
||||
main: .
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Env.VERSION}}
|
||||
@@ -1,30 +0,0 @@
|
||||
# plugin-docker-buildx is the CA-baked variant; artifactapi's cert is not in the default trust store.
|
||||
when:
|
||||
- event: tag
|
||||
ref: refs/tags/v*
|
||||
|
||||
steps:
|
||||
- name: docker
|
||||
image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/plugin-docker-buildx:latest
|
||||
settings:
|
||||
registry: artifactapi.k8s.syd1.au.unkin.net
|
||||
repo: artifactapi.k8s.syd1.au.unkin.net/docker-internal/pdbmux
|
||||
dockerfile: Dockerfile
|
||||
buildkit_config: |
|
||||
[registry."artifactapi.k8s.syd1.au.unkin.net"]
|
||||
ca = ["/etc/docker/certs.d/artifactapi.k8s.syd1.au.unkin.net/ca.crt"]
|
||||
build_args:
|
||||
VERSION: ${CI_COMMIT_TAG}
|
||||
tags:
|
||||
- ${CI_COMMIT_TAG}
|
||||
- latest
|
||||
backend_options:
|
||||
kubernetes:
|
||||
serviceAccountName: default
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: 1
|
||||
limits:
|
||||
memory: 2Gi
|
||||
cpu: 2
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
FROM golang:1.25-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache git
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG VERSION=dev
|
||||
RUN CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION}" -o pdbmux .
|
||||
|
||||
FROM gcr.io/distroless/static-debian12:nonroot
|
||||
|
||||
COPY --from=builder /build/pdbmux /usr/local/bin/pdbmux
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["pdbmux", "serve"]
|
||||
@@ -5,7 +5,7 @@ GOFLAGS := -ldflags="-s -w -X main.version=$(VERSION)"
|
||||
OS ?= $(shell go env GOOS)
|
||||
ARCH ?= $(shell go env GOARCH)
|
||||
|
||||
.PHONY: all build test e2e lint fmt clean install patch minor major _tag
|
||||
.PHONY: all build test e2e lint fmt clean install patch minor major
|
||||
|
||||
all: build
|
||||
|
||||
@@ -31,23 +31,20 @@ clean:
|
||||
install:
|
||||
go install $(GOFLAGS) .
|
||||
|
||||
_LATEST := $(shell git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$' | head -1)
|
||||
_BASE := $(if $(_LATEST),$(_LATEST),v0.0.0)
|
||||
_MAJ := $(shell echo $(_BASE) | sed 's/^v//' | cut -d. -f1)
|
||||
_MIN := $(shell echo $(_BASE) | sed 's/^v//' | cut -d. -f2)
|
||||
_PAT := $(shell echo $(_BASE) | sed 's/^v//' | cut -d. -f3)
|
||||
DEFAULT_BRANCH ?= main
|
||||
|
||||
patch:
|
||||
@NEW=v$(_MAJ).$(_MIN).$(shell expr $(_PAT) + 1); \
|
||||
git tag $$NEW && echo "Tagged $$NEW" && $(MAKE) _tag TAG=$$NEW
|
||||
|
||||
minor:
|
||||
@NEW=v$(_MAJ).$(shell expr $(_MIN) + 1).0; \
|
||||
git tag $$NEW && echo "Tagged $$NEW" && $(MAKE) _tag TAG=$$NEW
|
||||
|
||||
major:
|
||||
@NEW=v$(shell expr $(_MAJ) + 1).0.0; \
|
||||
git tag $$NEW && echo "Tagged $$NEW" && $(MAKE) _tag TAG=$$NEW
|
||||
|
||||
_tag:
|
||||
git push origin $(TAG)
|
||||
# Publish the release with generated notes, then push the tag; no workflow
|
||||
# fills the release, so it is not drafted.
|
||||
patch minor major:
|
||||
@git fetch --quiet --tags origin $(DEFAULT_BRANCH)
|
||||
@test "$$(git branch --show-current)" = "$(DEFAULT_BRANCH)" || { echo "ERROR: not on $(DEFAULT_BRANCH)"; exit 1; }
|
||||
@test -z "$$(git status --porcelain)" || { echo "ERROR: working tree not clean"; exit 1; }
|
||||
@test "$$(git rev-parse HEAD)" = "$$(git rev-parse origin/$(DEFAULT_BRANCH))" || { echo "ERROR: HEAD is not origin/$(DEFAULT_BRANCH)"; exit 1; }
|
||||
@LATEST=$$(git tag --list 'v*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$' | head -1); \
|
||||
NEW=$$(echo "$${LATEST:-v0.0.0}" | sed 's/^v//' | awk -F. -v b=$@ '{ \
|
||||
if (b == "major") print "v" ($$1+1) ".0.0"; \
|
||||
else if (b == "minor") print "v" $$1 "." ($$2+1) ".0"; \
|
||||
else print "v" $$1 "." $$2 "." ($$3+1) }'); \
|
||||
SHA=$$(git rev-parse HEAD); \
|
||||
gh release create "$$NEW" --target "$$SHA" --generate-notes --title "$$NEW" || exit 1; \
|
||||
git push origin "$$SHA:refs/tags/$$NEW" || { gh release delete "$$NEW" --yes; exit 1; }
|
||||
|
||||
@@ -585,6 +585,8 @@ curl -s --get http://localhost:8080/pdb/query/v4/nodes \
|
||||
|
||||
## Build
|
||||
|
||||
Source: <https://github.com/IUCLabs/pdbmux>.
|
||||
|
||||
`make build` (static binary into `dist/`), `make test`, `make lint`. Requires Go 1.25+.
|
||||
|
||||
## End-to-end tests
|
||||
@@ -614,11 +616,13 @@ Every test asserts; the suite records no known gaps.
|
||||
|
||||
## Deployment
|
||||
|
||||
Container image only — no OS package. Every `v*` tag builds and pushes the image
|
||||
(`.woodpecker/docker.yaml`); registry and repository are pipeline settings. Tag
|
||||
with `make patch` / `minor` / `major`.
|
||||
Container image only — no OS package: `ghcr.io/iuclabs/pdbmux:<tag>` (and
|
||||
`latest`). Every `v*` tag builds it with ko (`.ko.yaml`) and pushes it via
|
||||
`.github/workflows/release.yml`. `make patch` / `minor` / `major` publishes a
|
||||
GitHub release with generated notes, then pushes the tag; it needs `gh`.
|
||||
|
||||
A static (`CGO_ENABLED=0`) binary on a distroless base. Configure it with
|
||||
A static (`CGO_ENABLED=0`) binary on a distroless nonroot base; the entrypoint
|
||||
runs `serve` by default. Configure it with
|
||||
`PDBMUX_*` env vars (at minimum `PDBMUX_BACKENDS`), or mount a config file — a
|
||||
configmap at `/etc/pdbmux/config.yaml` is picked up with no env var at all, and
|
||||
any other mount path works via `PDBMUX_CONFIG`. Env vars still override file
|
||||
|
||||
Reference in New Issue
Block a user