Skip to content

Commit 97607f5

Browse files
Merge pull request #4 from cert-manager/add_makefile_modules
Add makefile modules
2 parents fb02f87 + ae2ebae commit 97607f5

34 files changed

+2416
-0
lines changed

.github/dependabot.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
2+
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base-dependabot/.github/dependabot.yaml instead.
3+
4+
# Update Go dependencies and GitHub Actions dependencies daily.
5+
version: 2
6+
updates:
7+
- package-ecosystem: gomod
8+
directory: /
9+
schedule:
10+
interval: daily
11+
groups:
12+
all:
13+
patterns: ["*"]
14+
- package-ecosystem: github-actions
15+
directory: /
16+
schedule:
17+
interval: daily
18+
groups:
19+
all:
20+
patterns: ["*"]

.github/workflows/govulncheck.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
2+
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/go/base/.github/workflows/govulncheck.yaml instead.
3+
4+
# Run govulncheck at midnight every night on the main branch,
5+
# to alert us to recent vulnerabilities which affect the Go code in this
6+
# project.
7+
name: govulncheck
8+
on:
9+
workflow_dispatch: {}
10+
schedule:
11+
- cron: '0 0 * * *'
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
govulncheck:
18+
runs-on: ubuntu-latest
19+
20+
if: github.repository_owner == 'cert-manager'
21+
22+
steps:
23+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
# Adding `fetch-depth: 0` makes sure tags are also fetched. We need
25+
# the tags so `git describe` returns a valid version.
26+
# see https://github.com/actions/checkout/issues/701 for extra info about this option
27+
with: { fetch-depth: 0 }
28+
29+
- id: go-version
30+
run: |
31+
make print-go-version >> "$GITHUB_OUTPUT"
32+
33+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
34+
with:
35+
go-version: ${{ steps.go-version.outputs.result }}
36+
37+
- run: make verify-govulncheck
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
2+
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/.github/workflows/make-self-upgrade.yaml instead.
3+
4+
name: make-self-upgrade
5+
concurrency: make-self-upgrade
6+
on:
7+
workflow_dispatch: {}
8+
schedule:
9+
- cron: '0 0 * * *'
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
self_upgrade:
16+
runs-on: ubuntu-latest
17+
18+
if: github.repository_owner == 'cert-manager'
19+
20+
permissions:
21+
contents: write
22+
pull-requests: write
23+
24+
env:
25+
SOURCE_BRANCH: "${{ github.ref_name }}"
26+
SELF_UPGRADE_BRANCH: "self-upgrade-${{ github.ref_name }}"
27+
28+
steps:
29+
- name: Fail if branch is not head of branch.
30+
if: ${{ !startsWith(github.ref, 'refs/heads/') && env.SOURCE_BRANCH != '' && env.SELF_UPGRADE_BRANCH != '' }}
31+
run: |
32+
echo "This workflow should not be run on a non-branch-head."
33+
exit 1
34+
35+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
36+
# Adding `fetch-depth: 0` makes sure tags are also fetched. We need
37+
# the tags so `git describe` returns a valid version.
38+
# see https://github.com/actions/checkout/issues/701 for extra info about this option
39+
with: { fetch-depth: 0 }
40+
41+
- id: go-version
42+
run: |
43+
make print-go-version >> "$GITHUB_OUTPUT"
44+
45+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
46+
with:
47+
go-version: ${{ steps.go-version.outputs.result }}
48+
49+
- run: |
50+
git checkout -B "$SELF_UPGRADE_BRANCH"
51+
52+
- run: |
53+
make -j upgrade-klone
54+
make -j generate
55+
56+
- id: is-up-to-date
57+
shell: bash
58+
run: |
59+
git_status=$(git status -s)
60+
is_up_to_date="true"
61+
if [ -n "$git_status" ]; then
62+
is_up_to_date="false"
63+
echo "The following changes will be committed:"
64+
echo "$git_status"
65+
fi
66+
echo "result=$is_up_to_date" >> "$GITHUB_OUTPUT"
67+
68+
- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
69+
run: |
70+
git config --global user.name "cert-manager-bot"
71+
git config --global user.email "[email protected]"
72+
git add -A && git commit -m "BOT: run 'make upgrade-klone' and 'make generate'" --signoff
73+
git push -f origin "$SELF_UPGRADE_BRANCH"
74+
75+
- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
76+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
77+
with:
78+
script: |
79+
const { repo, owner } = context.repo;
80+
const pulls = await github.rest.pulls.list({
81+
owner: owner,
82+
repo: repo,
83+
head: owner + ':' + process.env.SELF_UPGRADE_BRANCH,
84+
base: process.env.SOURCE_BRANCH,
85+
state: 'open',
86+
});
87+
88+
if (pulls.data.length < 1) {
89+
const result = await github.rest.pulls.create({
90+
title: '[CI] Merge ' + process.env.SELF_UPGRADE_BRANCH + ' into ' + process.env.SOURCE_BRANCH,
91+
owner: owner,
92+
repo: repo,
93+
head: process.env.SELF_UPGRADE_BRANCH,
94+
base: process.env.SOURCE_BRANCH,
95+
body: [
96+
'This PR is auto-generated to bump the Makefile modules.',
97+
].join('\n'),
98+
});
99+
await github.rest.issues.addLabels({
100+
owner,
101+
repo,
102+
issue_number: result.data.number,
103+
labels: ['skip-review']
104+
});
105+
}

.golangci.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
version: "2"
2+
linters:
3+
default: none
4+
exclusions:
5+
generated: lax
6+
presets: [comments, common-false-positives, legacy, std-error-handling]
7+
paths: [third_party, builtin$, examples$]
8+
warn-unused: true
9+
settings:
10+
staticcheck:
11+
checks: ["all", "-ST1000", "-ST1001", "-ST1003", "-ST1005", "-ST1012", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-QF1001", "-QF1003", "-QF1008"]
12+
enable:
13+
- asasalint
14+
- asciicheck
15+
- bidichk
16+
- bodyclose
17+
- canonicalheader
18+
- contextcheck
19+
- copyloopvar
20+
- decorder
21+
- dogsled
22+
- dupword
23+
- durationcheck
24+
- errcheck
25+
- errchkjson
26+
- errname
27+
- exhaustive
28+
- exptostd
29+
- forbidigo
30+
- ginkgolinter
31+
- gocheckcompilerdirectives
32+
- gochecksumtype
33+
- gocritic
34+
- goheader
35+
- goprintffuncname
36+
- gosec
37+
- gosmopolitan
38+
- govet
39+
- grouper
40+
- importas
41+
- ineffassign
42+
- interfacebloat
43+
- intrange
44+
- loggercheck
45+
- makezero
46+
- mirror
47+
- misspell
48+
- musttag
49+
- nakedret
50+
- nilerr
51+
- nilnil
52+
- noctx
53+
- nosprintfhostport
54+
- predeclared
55+
- promlinter
56+
- protogetter
57+
- reassign
58+
- sloglint
59+
- staticcheck
60+
- tagalign
61+
- testableexamples
62+
- unconvert
63+
- unparam
64+
- unused
65+
- usestdlibvars
66+
- usetesting
67+
- wastedassign
68+
formatters:
69+
enable: [gci, gofmt]
70+
settings:
71+
gci:
72+
sections:
73+
- standard # Standard section: captures all standard packages.
74+
- default # Default section: contains all imports that could not be matched to another section type.
75+
- prefix(github.com/cert-manager/webhook-cert-lib) # Custom section: groups all imports with the specified Prefix.
76+
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
77+
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
78+
exclusions:
79+
generated: lax
80+
paths: [third_party, builtin$, examples$]

Makefile

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Copyright 2023 The cert-manager Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
16+
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/Makefile instead.
17+
18+
# NOTE FOR DEVELOPERS: "How do the Makefiles work and how can I extend them?"
19+
#
20+
# Shared Makefile logic lives in the make/_shared/ directory. The source of truth for these files
21+
# lies outside of this repository, eg. in the cert-manager/makefile-modules repository.
22+
#
23+
# Logic specific to this repository must be defined in the make/00_mod.mk and make/02_mod.mk files:
24+
# - The make/00_mod.mk file is included first and contains variable definitions needed by
25+
# the shared Makefile logic.
26+
# - The make/02_mod.mk file is included later, it can make use of most of the shared targets
27+
# defined in the make/_shared/ directory (all targets defined in 00_mod.mk and 01_mod.mk).
28+
# This file should be used to define targets specific to this repository.
29+
30+
##################################
31+
32+
# Some modules build their dependencies from variables, we want these to be
33+
# evaluated at the last possible moment. For this we use second expansion to
34+
# re-evaluate the generate and verify targets a second time.
35+
#
36+
# See https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html
37+
.SECONDEXPANSION:
38+
39+
# For details on some of these "prelude" settings, see:
40+
# https://clarkgrubb.com/makefile-style-guide
41+
MAKEFLAGS += --warn-undefined-variables --no-builtin-rules
42+
SHELL := /usr/bin/env bash
43+
.SHELLFLAGS := -uo pipefail -c
44+
.DEFAULT_GOAL := help
45+
.DELETE_ON_ERROR:
46+
.SUFFIXES:
47+
FORCE:
48+
49+
noop: # do nothing
50+
51+
# Set empty value for MAKECMDGOALS to prevent the "warning: undefined variable 'MAKECMDGOALS'"
52+
# warning from happening when running make without arguments
53+
MAKECMDGOALS ?=
54+
55+
##################################
56+
# Host OS and architecture setup #
57+
##################################
58+
59+
# The reason we don't use "go env GOOS" or "go env GOARCH" is that the "go"
60+
# binary may not be available in the PATH yet when the Makefiles are
61+
# evaluated. HOST_OS and HOST_ARCH only support Linux, *BSD and macOS (M1
62+
# and Intel).
63+
host_os := $(shell uname -s | tr A-Z a-z)
64+
host_arch := $(shell uname -m)
65+
HOST_OS ?= $(host_os)
66+
HOST_ARCH ?= $(host_arch)
67+
68+
ifeq (x86_64, $(HOST_ARCH))
69+
HOST_ARCH = amd64
70+
else ifeq (aarch64, $(HOST_ARCH))
71+
# linux reports the arm64 arch as aarch64
72+
HOST_ARCH = arm64
73+
endif
74+
75+
##################################
76+
# Git and versioning information #
77+
##################################
78+
79+
git_version := $(shell git describe --tags --always --match='v*' --abbrev=14 --dirty)
80+
VERSION ?= $(git_version)
81+
IS_PRERELEASE := $(shell git describe --tags --always --match='v*' --abbrev=0 | grep -q '-' && echo true || echo false)
82+
GITCOMMIT := $(shell git rev-parse HEAD)
83+
GITEPOCH := $(shell git show -s --format=%ct HEAD)
84+
85+
##################################
86+
# Global variables and dirs #
87+
##################################
88+
89+
bin_dir := _bin
90+
91+
# The ARTIFACTS environment variable is set by the CI system to a directory
92+
# where artifacts should be placed. These artifacts are then uploaded to a
93+
# storage bucket by the CI system (https://docs.prow.k8s.io/docs/components/pod-utilities/).
94+
# An example of such an artifact is a jUnit XML file containing test results.
95+
# If the ARTIFACTS environment variable is not set, we default to a local
96+
# directory in the _bin directory.
97+
ARTIFACTS ?= $(bin_dir)/artifacts
98+
99+
$(bin_dir) $(ARTIFACTS) $(bin_dir)/scratch:
100+
mkdir -p $@
101+
102+
.PHONY: clean
103+
## Clean all temporary files
104+
## @category [shared] Tools
105+
clean:
106+
rm -rf $(bin_dir)
107+
108+
##################################
109+
# Include all the Makefiles #
110+
##################################
111+
112+
-include make/00_mod.mk
113+
-include make/_shared/*/00_mod.mk
114+
-include make/_shared/*/01_mod.mk
115+
-include make/02_mod.mk
116+
-include make/_shared/*/02_mod.mk

OWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
approvers:
2+
- cm-maintainers
3+
reviewers:
4+
- cm-maintainers

OWNERS_ALIASES

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
2+
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/OWNERS_ALIASES instead.
3+
4+
aliases:
5+
cm-maintainers:
6+
- munnerz
7+
- joshvanl
8+
- wallrj
9+
- jakexks
10+
- maelvls
11+
- sgtcodfish
12+
- inteon
13+
- thatsmrtalbot
14+
- erikgb

0 commit comments

Comments
 (0)