Skip to content

Commit d1a8a67

Browse files
committed
Squashed 'build/' changes from 1d2c4be..97fc423
97fc423 Fix go integration test package name 5aae357 Fix golangci-lint version 7577691 Update golangci-lint version to v1.64.6 89dd57e Update ginkgo version to v2.22.2 892afbf Update go version to 1.24.0 bc2a5a3 Bump controller-gen version to v0.17.1 git-subtree-dir: build git-subtree-split: 97fc4239bb4a9169d77c36ac3c0df928e054782e
1 parent 2916a9e commit d1a8a67

70 files changed

Lines changed: 167 additions & 3517 deletions

Some content is hidden

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

.drone.yml

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
kind: pipeline
32
name: default
43

@@ -7,39 +6,90 @@ clone:
76

87
workspace:
98
base: /workspace
10-
path: src/github.com/presslabs/controller-util
9+
path: src/github.com/presslabs/build
1110

1211
steps:
13-
- name: git
14-
pull: default
12+
- name: clone
1513
image: plugins/git
1614
settings:
1715
depth: 0
1816
tags: true
1917

20-
- name: dependencies
18+
- name: install dependencies
2119
image: presslabs/build:stable
22-
pull: always
2320
commands:
24-
- make build.tools
21+
- make -j4 build.tools
2522

26-
- name: lint
23+
- name: build
24+
pull: true
2725
image: presslabs/build:stable
26+
environment:
27+
DOCKER_HOST: "unix:///workspace/docker.sock"
2828
commands:
29-
- make lint
29+
- make -j4 build
3030

31-
- name: test
31+
- name: publish
3232
image: presslabs/build:stable
3333
commands:
34-
- make test
34+
- /usr/local/bin/setup-credentials-helper.sh
35+
- make publish
36+
environment:
37+
DOCKER_HOST: "unix:///workspace/docker.sock"
38+
DOCKER_USERNAME: presslabsbot
39+
DOCKER_PASSWORD:
40+
from_secret: DOCKERHUB_TOKEN
41+
when:
42+
ref:
43+
- refs/heads/master
44+
- refs/heads/release-*
45+
46+
services:
47+
- name: docker
48+
image: docker:dind
49+
privileged: true
50+
commands:
51+
- /usr/local/bin/dockerd-entrypoint.sh dockerd --host "unix:///workspace/docker.sock" --storage-driver overlay2 --log-level error
52+
3553

3654
trigger:
3755
ref:
56+
- refs/pull/**
57+
- refs/heads/**
58+
event:
3859
exclude:
39-
- refs/heads/dependabot/**
60+
- promote
61+
- tag
4062

4163
---
42-
kind: signature
43-
hmac: f55df7a519243e9a5e52b55fb2ec90ea65d2f21c3a79f46c617c56c4255d02c8
64+
kind: pipeline
65+
name: promote
66+
67+
clone:
68+
disable: true
69+
70+
workspace:
71+
base: /workspace
72+
path: src/github.com/presslabs/build
4473

45-
...
74+
steps:
75+
- name: clone
76+
image: plugins/git
77+
settings:
78+
depth: 0
79+
tags: true
80+
81+
- name: promote
82+
image: presslabs/build:stable
83+
commands:
84+
- /usr/local/bin/setup-credentials-helper.sh
85+
- make promote CHANNEL=${DRONE_DEPLOY_TO} PROMOTE_IMAGE_TAG=${PUBLISH_TAG}
86+
- '[ "$PUBLISH_TAG" = "" ] || make tag VERSION=${PUBLISH_TAG}'
87+
environment:
88+
DOCKER_HOST: "unix:///workspace/docker.sock"
89+
DOCKER_USERNAME: presslabsbot
90+
DOCKER_PASSWORD:
91+
from_secret: DOCKERHUB_TOKEN
92+
93+
trigger:
94+
event:
95+
- promote

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/dependabot.yml

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

.gitignore

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
# Binaries for programs and plugins
2-
*.exe
3-
*.exe~
4-
*.dll
5-
*.so
6-
*.dylib
7-
8-
# Test binary, build with `go test -c`
9-
*.test
10-
11-
# Output of the go coverage tool, specifically when used with LiteIDE
12-
*.out
13-
14-
bin
15-
16-
.idea
17-
18-
.cache
191
_output
2+
.cache
203
.work
4+
/bin/
5+
.idea
216

7+
.#*

.golangci.yml

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

Makefile

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
# Project Setup
2-
PROJECT_NAME := controller-util
3-
PROJECT_REPO := github.com/presslabs/$(PROJECT_NAME)
2+
PROJECT_NAME := presslabs-build
3+
PROJECT_REPO := github.com/presslabs/build
44

5-
PLATFORMS = linux_amd64 darwin_amd64
5+
PLATFORMS = linux_amd64
66

7-
GO_SUBDIRS := pkg
7+
# this is required, since by default, the makelib files are under a ./build path prefix, but here,
8+
# they are under root
9+
ROOT_DIR := $(abspath $(shell cd ./ && pwd -P))
810

9-
GO111MODULE=on
11+
include makelib/common.mk
1012

11-
GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/wp-operator
12-
GO_LDFLAGS += -X $(PROJECT_REPO)/pkg/version.buildDate=$(BUILD_DATE) \
13-
-X $(PROJECT_REPO)/pkg/version.gitVersion=$(VERSION) \
14-
-X $(PROJECT_REPO)/pkg/version.gitCommit=$(GIT_COMMIT) \
15-
-X $(PROJECT_REPO)/pkg/version.gitTreeState=$(GIT_TREE_STATE)
13+
IMAGES ?= build
14+
DOCKER_REGISTRY ?= presslabs
1615

17-
include build/makelib/common.mk
18-
include build/makelib/golang.mk
19-
include build/makelib/kubebuilder.mk
16+
include makelib/image.mk

README.md

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,82 @@
1-
![Presslabs Logo](https://www.presslabs.com/logo.png)
1+
# build
2+
Presslabs GNU make based build system
23

3-
# controller-util
4+
## Goals
45

5-
[![Build Status](https://ci.presslabs.net/api/badges/presslabs/controller-util/status.svg)](https://ci.presslabs.net/presslabs/controller-util)
6-
[![GoDoc](https://godoc.org/github.com/presslabs/controller-util?status.svg)](https://godoc.org/github.com/presslabs/controller-util)
6+
1. Allow building locally the same way the project is build on CI
7+
2. Provide a sane test, build, publish flow
8+
3. Provide stable toolchain for building (eg. pinned tool versions)
9+
4. Enables caching for speeding up builds.
710

8-
Utility code for writing kubernetes controllers using kubebuilder and controller-runtime
11+
## Quickstart
12+
13+
To include `build/` to your project run:
14+
15+
```sh
16+
git subtree add --squash -P build https://github.com/presslabs/build.git master
17+
18+
cat <<EOF > Makefile
19+
# Project Setup
20+
PROJECT_NAME := mysql-operator
21+
PROJECT_REPO := github.com/presslabs/mysql-operator
22+
23+
include build/makelib/common.mk
24+
```
25+
26+
### Pull new changes
27+
28+
```sh
29+
git subtree pull --squash -P build https://github.com/presslabs/build.git master
30+
```
31+
32+
### Push back changes
33+
34+
An [workaround](https://github.com/rust-lang/rust-clippy/issues/5565#issuecomment-623489754) on how
35+
to bypass the segfault of git subtree command on repose with more commits.
36+
37+
```sh
38+
ulimit -s 60000 # workaround to fix segfault
39+
40+
git subtree push -P build/ git@github.com:presslabs/build.git <a branch name>
41+
```
42+
43+
## Development workflow
44+
45+
The image publishing will work as follows:
46+
47+
On a feature branch (e.g. `feat-*`):
48+
* Drone build runs without image publishing
49+
* Can't trigger a promotion (it will fail)
50+
51+
On a release branch (e.i. `release-*` or `master`):
52+
* Drone build will publish images using git-semver using the following tags: `$(git-semver)`, `$(git-semver)-$ARCH`
53+
* Manually can promote to the following channels (`$CHANNEL`): `stable`, `beta`, `alpha`, `master`
54+
* *On promote*: the images are published with the following tags: `$CHANNEL`, `$CHANNEL-$(git-semver)`, `$(git-semver)`, `$(git-semver)-$ARCH`
55+
* *On promote* and parameter `PUBLISH_TAG` is set: a new git tag will be created and images will be published under the following tags: `$CHANNEL`, `$CHANNEL-$PUBLISH_TAG`, `$PUBLISH_TAG` (if channel is `stable`).
56+
57+
On git tag event the CI will not run.
58+
59+
## Usage
60+
61+
```
62+
Usage: make [make-options] <target> [options]
63+
64+
Common Targets:
65+
build Build source code and other artifacts for host platform.
66+
build.all Build source code and other artifacts for all platforms.
67+
build.tools Install the required build tools.
68+
clean Remove all files created during the build.
69+
distclean Remove all files created during the build including cached tools.
70+
generate Run code generation tools.
71+
fmt Run code auto-formatting tools.
72+
lint Run lint and code analysis tools.
73+
test Runs unit tests.
74+
e2e Runs end-to-end integration tests.
75+
translate Collect translation strings and post-process the .pot/.po files.
76+
help Show this help info.
77+
```
78+
79+
## Acknowledgement
80+
81+
This work is based on https://github.com/bitpoke/build
82+
This work is based on https://github.com/upbound/build.
File renamed without changes.

0 commit comments

Comments
 (0)