Improve build process embedded manifests

This commit changes the way the build of manifests is triggered by
making smarter use of the capabilities of Make. The result should be
that the manifests are only regenerated if:

1. There is no `cmd/flux/manifests/` directory.
2. There have been made changes to the YAML files in the `manifests/`
   directory that are newer than the files in `cmd/flux/manifests/`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
pull/1062/head
Hidde Beydals 4 years ago
parent 527886bea0
commit 2b7a0f3fd4

@ -30,7 +30,7 @@ jobs:
uses: fluxcd/pkg//actions/kustomize@main uses: fluxcd/pkg//actions/kustomize@main
- name: Build - name: Build
run: | run: |
make build-manifests make cmd/flux/manifests
go build -o /tmp/flux ./cmd/flux go build -o /tmp/flux ./cmd/flux
- name: Set outputs - name: Set outputs
id: vars id: vars

@ -30,7 +30,7 @@ jobs:
uses: fluxcd/pkg//actions/kustomize@main uses: fluxcd/pkg//actions/kustomize@main
- name: Generate manifests - name: Generate manifests
run: | run: |
make build-manifests make cmd/flux/manifests
./manifests/scripts/bundle.sh ./output manifests.tar.gz ./manifests/scripts/bundle.sh ./output manifests.tar.gz
kustomize build ./manifests/install > ./output/install.yaml kustomize build ./manifests/install > ./output/install.yaml
- name: Run GoReleaser - name: Run GoReleaser

@ -31,7 +31,7 @@ jobs:
uses: fluxcd/pkg//actions/kustomize@main uses: fluxcd/pkg//actions/kustomize@main
- name: Build manifests - name: Build manifests
run: | run: |
make build-manifests make cmd/flux/manifests
- name: Run Snyk to check for vulnerabilities - name: Run Snyk to check for vulnerabilities
uses: snyk/actions/golang@master uses: snyk/actions/golang@master
continue-on-error: true continue-on-error: true

@ -1,4 +1,7 @@
VERSION?=$(shell grep 'VERSION' cmd/flux/main.go | awk '{ print $$4 }' | tr -d '"') VERSION?=$(shell grep 'VERSION' cmd/flux/main.go | awk '{ print $$4 }' | tr -d '"')
EMBEDDED_MANIFESTS_TARGET=cmd/flux/manifests
rwildcard=$(foreach d,$(wildcard $(addsuffix *,$(1))),$(call rwildcard,$(d)/,$(2)) $(filter $(subst *,%,$(2)),$(d)))
all: test build all: test build
@ -11,13 +14,13 @@ fmt:
vet: vet:
go vet ./... go vet ./...
test: build-manifests tidy fmt vet docs test: $(EMBEDDED_MANIFESTS_TARGET) tidy fmt vet docs
go test ./... -coverprofile cover.out go test ./... -coverprofile cover.out
build-manifests: $(EMBEDDED_MANIFESTS_TARGET): $(call rwildcard,manifests/,*.yaml *.json)
./manifests/scripts/bundle.sh ./manifests/scripts/bundle.sh
build: build: $(EMBEDDED_MANIFESTS_TARGET)
CGO_ENABLED=0 go build -o ./bin/flux ./cmd/flux CGO_ENABLED=0 go build -o ./bin/flux ./cmd/flux
install: install:
@ -25,7 +28,7 @@ install:
.PHONY: docs .PHONY: docs
docs: docs:
rm docs/cmd/* rm -rf docs/cmd/*
mkdir -p ./docs/cmd && go run ./cmd/flux/ docgen mkdir -p ./docs/cmd && go run ./cmd/flux/ docgen
install-dev: install-dev:

Loading…
Cancel
Save