Skip to content

Commit c00ce00

Browse files
committed
chore!: modernize toolchain and project automation
Migrate CI and release automation from Drone to GitHub Actions. Upgrade Go and CoreDNS dependencies, modernize linting, adopt generated typed mocks, and verify full CoreDNS builds in CI. Rename the plugin directive to dohproxy to coexist with the built-in CoreDNS https plugin and document local integration testing. BREAKING CHANGE: Go 1.26.0 or later is now required. The Corefile directive is renamed from https to dohproxy, and Prometheus metric prefixes change from coredns_https_ to coredns_dohproxy_.
1 parent 55e0603 commit c00ce00

21 files changed

Lines changed: 1171 additions & 821 deletions

.commitlintrc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extends:
2+
- '@commitlint/config-conventional'
3+
4+
rules:
5+
header-max-length: [0, 'always', 100]

.drone.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
changes:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
go_ci: ${{ steps.filter.outputs.go_ci }}
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v6
25+
26+
- name: Detect changed paths
27+
id: filter
28+
uses: dorny/paths-filter@v4
29+
with:
30+
filters: |
31+
go_ci:
32+
- '**/*.go'
33+
- 'go.mod'
34+
- 'go.sum'
35+
- '.golangci.yml'
36+
- '.github/workflows/ci.yml'
37+
38+
go:
39+
needs: changes
40+
if: needs.changes.outputs.go_ci == 'true'
41+
runs-on: ubuntu-latest
42+
container: golang:1.26-alpine
43+
env:
44+
CGO_ENABLED: 0
45+
GOFLAGS: -buildvcs=false
46+
GOMODCACHE: /go/pkg/mod
47+
GOCACHE: /root/.cache/go-build
48+
defaults:
49+
run:
50+
shell: bash
51+
52+
steps:
53+
- name: Install system dependencies
54+
shell: sh
55+
run: apk add --no-cache bash ca-certificates git
56+
57+
- name: Checkout repository
58+
uses: actions/checkout@v6
59+
60+
- name: Cache Go modules and build outputs
61+
uses: actions/cache@v5
62+
with:
63+
path: |
64+
/go/pkg/mod
65+
/root/.cache/go-build
66+
key: ${{ runner.os }}-go-1.26-${{ hashFiles('**/go.sum') }}
67+
restore-keys: |
68+
${{ runner.os }}-go-1.26-
69+
70+
- name: Verify generated files and module metadata
71+
run: |
72+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
73+
go generate ./...
74+
go mod tidy
75+
git diff --exit-code
76+
77+
- name: Check Go formatting
78+
run: test -z "$(gofmt -l .)"
79+
80+
- name: Run golangci-lint
81+
uses: golangci/golangci-lint-action@v9
82+
with:
83+
version: v2.12
84+
args: --verbose
85+
86+
- name: Run Go tests
87+
run: go test ./... -v -cover
88+
89+
- name: Run Go build
90+
run: go build ./...
91+
92+
- name: Build CoreDNS with the local plugin
93+
run: |
94+
plugin_dir="$GITHUB_WORKSPACE"
95+
coredns_version="$(go list -m -f '{{.Version}}' github.com/coredns/coredns)"
96+
coredns_dir="$(mktemp -d)"
97+
98+
git clone --depth 1 --branch "$coredns_version" https://github.com/coredns/coredns.git "$coredns_dir"
99+
cd "$coredns_dir"
100+
go mod edit -replace "github.com/v-byte-cpu/coredns-https=$plugin_dir"
101+
go get github.com/v-byte-cpu/coredns-https@v0.0.0
102+
COREDNS_PLUGINS="dohproxy:github.com/v-byte-cpu/coredns-https" go generate coredns.go
103+
go build -o coredns .
104+
./coredns -plugins | grep -Fx dohproxy

.github/workflows/commitlint.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Commit checks
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: commitlint-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
commitlint:
18+
if: >-
19+
(github.event_name == 'pull_request' && github.event.pull_request.user.login != 'dependabot[bot]')
20+
|| (github.event_name == 'push' && github.event.head_commit.author.name != 'dependabot[bot]')
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Enforce single-commit PRs
25+
if: github.event_name == 'pull_request'
26+
env:
27+
PR_COMMIT_COUNT: ${{ github.event.pull_request.commits }}
28+
run: test "$PR_COMMIT_COUNT" -eq 1
29+
30+
- name: Checkout repository
31+
uses: actions/checkout@v6
32+
with:
33+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
34+
35+
- name: Set up Node
36+
uses: actions/setup-node@v6
37+
with:
38+
node-version: "22"
39+
40+
- name: Install commitlint
41+
run: npm install --no-save --no-package-lock @commitlint/cli @commitlint/config-conventional
42+
43+
- name: Validate PR title
44+
if: github.event_name == 'pull_request'
45+
env:
46+
PR_TITLE: ${{ github.event.pull_request.title }}
47+
run: printf '%s\n' "$PR_TITLE" | npx commitlint --verbose
48+
49+
- name: Validate last commit
50+
run: npx commitlint --last --verbose

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
concurrency:
12+
group: release-${{ github.ref }}
13+
cancel-in-progress: false
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
env:
19+
NOTES_PATH: ${{ github.workspace }}/release-notes.md
20+
defaults:
21+
run:
22+
shell: bash
23+
24+
steps:
25+
- name: Validate release tag
26+
id: release_flags
27+
env:
28+
RELEASE_TAG: ${{ github.ref_name }}
29+
run: |
30+
set -euo pipefail
31+
32+
if [[ ! "${RELEASE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
33+
echo "invalid release tag: ${RELEASE_TAG}" >&2
34+
exit 1
35+
fi
36+
37+
if [[ "${RELEASE_TAG}" =~ -rc\.[0-9]+$ ]]; then
38+
echo "prerelease=true" >> "$GITHUB_OUTPUT"
39+
echo "make_latest=false" >> "$GITHUB_OUTPUT"
40+
else
41+
echo "prerelease=false" >> "$GITHUB_OUTPUT"
42+
echo "make_latest=true" >> "$GITHUB_OUTPUT"
43+
fi
44+
45+
- name: Checkout repository
46+
uses: actions/checkout@v6
47+
with:
48+
ref: ${{ github.ref }}
49+
fetch-depth: 0
50+
fetch-tags: true
51+
52+
- name: Install git-cliff
53+
uses: taiki-e/install-action@git-cliff
54+
55+
- name: Generate release notes
56+
env:
57+
RELEASE_TAG: ${{ github.ref_name }}
58+
run: |
59+
set -euo pipefail
60+
61+
ignore_rc_tags='^v[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$'
62+
if [[ "${RELEASE_TAG}" =~ -rc\.[0-9]+$ ]]; then
63+
git-cliff --current --output "${NOTES_PATH}"
64+
else
65+
git-cliff --current --ignore-tags "${ignore_rc_tags}" --output "${NOTES_PATH}"
66+
fi
67+
68+
cat "${NOTES_PATH}" >> "$GITHUB_STEP_SUMMARY"
69+
70+
- name: Create draft GitHub Release
71+
uses: softprops/action-gh-release@v3
72+
with:
73+
tag_name: ${{ github.ref_name }}
74+
name: ${{ github.ref_name }}
75+
body_path: ${{ env.NOTES_PATH }}
76+
draft: true
77+
prerelease: ${{ steps.release_flags.outputs.prerelease }}
78+
make_latest: ${{ steps.release_flags.outputs.make_latest }}

.golangci.yml

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,71 @@
1+
version: "2"
2+
13
linters:
4+
disable:
5+
- errcheck
26
enable:
37
- dogsled
4-
- errname
5-
- errorlint
6-
- exportloopref
8+
- gochecknoinits
79
- funlen
810
- gocognit
911
- goconst
1012
- gocritic
1113
- gocyclo
12-
- gofmt
13-
- goimports
14+
- nolintlint
15+
- paralleltest
16+
- testifylint
1417
- staticcheck
1518
- gosec
16-
- govet
1719
- misspell
1820
- nestif
1921
- prealloc
22+
- revive
2023
- unconvert
2124
- unparam
25+
exclusions:
26+
rules:
27+
# CoreDNS external plugins must register themselves during package initialization.
28+
- linters:
29+
- gochecknoinits
30+
path: setup\.go
31+
text: "don't use `init` function"
32+
# Runtime configuration limits poolLen to maxUpstreams before this conversion.
33+
- linters:
34+
- gosec
35+
path: policy\.go
36+
text: "G115"
37+
- linters:
38+
- funlen
39+
- goconst
40+
path: _test\.go
41+
settings:
42+
revive:
43+
severity: warning
44+
confidence: 0.8
45+
rules:
46+
- name: blank-imports
47+
- name: context-as-argument
48+
- name: context-keys-type
49+
- name: dot-imports
50+
- name: error-return
51+
- name: error-strings
52+
- name: empty-block
53+
- name: superfluous-else
54+
- name: unhandled-error
55+
- name: unused-receiver
56+
- name: unreachable-code
57+
- name: range-val-in-closure
58+
- name: range-val-address
59+
- name: waitgroup-by-value
60+
- name: atomic
61+
- name: early-return
62+
- name: unconditional-recursion
63+
- name: identical-branches
2264

23-
run:
24-
timeout: 5m
65+
formatters:
66+
enable:
67+
- gofmt
68+
- goimports
2569

26-
issues:
27-
exclude-rules:
28-
- linters:
29-
- funlen
30-
- gosec
31-
path: _test\.go
70+
run:
71+
timeout: 3m

0 commit comments

Comments
 (0)