Skip to content

Commit 0e8fa55

Browse files
Merge pull request #75 from inteon/makefile_modules
Introduce makefile-modules and add e2e test
2 parents 084acbb + 46d074c commit 0e8fa55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3532
-484
lines changed

.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+
}

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
bin
9+
testbin/*
10+
11+
# Test binary, build with `go test -c`
12+
*.test
13+
14+
# Output of the go coverage tool, specifically when used with LiteIDE
15+
*.out
16+
17+
# Kubernetes Generated files - skip generated files, except for vendored files
18+
19+
!vendor/**/zz_generated.*
20+
21+
# editor and IDE paraphernalia
22+
.idea
23+
*.swp
24+
*.swo
25+
*~
26+
27+
_bin
28+
_certs
29+
.vscode

.golangci.yaml

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

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Apache License
32
Version 2.0, January 2004
43
http://www.apache.org/licenses/

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

0 commit comments

Comments
 (0)