Skip to content

Commit 177aa24

Browse files
committed
refactor: restructure makefile
1 parent 4949fee commit 177aa24

File tree

6 files changed

+33
-66
lines changed

6 files changed

+33
-66
lines changed

.github/workflows/ci-base.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ jobs:
5959
go-version: "~1.24"
6060
cache: ${{ env.caching_enabled }}
6161

62-
- name: Tidy go.mod files
62+
- name: Download dependencies
6363
run: go mod tidy
6464

65-
- name: Ensure goreleaser up to date
65+
- name: Run checks
6666
run: make check
6767

6868
- name: Generate sources cache key
@@ -89,7 +89,7 @@ jobs:
8989

9090
- name: Generate sources
9191
if: steps.cache-sources.outputs.cache-hit != 'true'
92-
run: make ci DISTRIBUTIONS=${{ inputs.distribution }}
92+
run: make ci DISTRIBUTION=${{ inputs.distribution }}
9393

9494
- name: Skip source generation (cached)
9595
if: steps.cache-sources.outputs.cache-hit == 'true'

.github/workflows/ci-nightly-fips.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
run: go mod tidy
6969

7070
- name: Verify build
71-
run: make ci DISTRIBUTIONS=${{ matrix.distribution }}
71+
run: make ci DISTRIBUTION=${{ matrix.distribution }}
7272

7373
- name: Login to Docker
7474
uses: docker/login-action@v3

.github/workflows/ci-nightly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
run: go mod tidy
6767

6868
- name: Verify build
69-
run: make ci DISTRIBUTIONS=${{ matrix.distribution }}
69+
run: make ci DISTRIBUTION=${{ matrix.distribution }}
7070

7171
- name: Login to Docker
7272
uses: docker/login-action@v3

.github/workflows/release-draft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
run: go mod tidy
5757

5858
- name: Verify build
59-
run: make ci DISTRIBUTIONS=${{ matrix.distribution }}
59+
run: make ci DISTRIBUTION=${{ matrix.distribution }}
6060

6161
- name: Login to Docker
6262
uses: docker/login-action@v3

Makefile

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,34 @@ TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(shell echo $(TOOLS_
1616
GO_LICENCE_DETECTOR := $(TOOLS_BIN_DIR)/go-licence-detector
1717
GO_LICENCE_DETECTOR_CONFIG := $(SRC_ROOT)/internal/assets/license/rules.json
1818

19-
DISTRIBUTIONS ?= "nrdot-collector-host,nrdot-collector-k8s,nrdot-collector"
19+
DISTRIBUTION ?= nrdot-collector-host
2020

21-
ci: check build build-fips version-check licenses-check
22-
check: ensure-goreleaser-up-to-date
21+
.PHONY: ci
22+
ci: pre-compile-check generate-sources-$(DISTRIBUTION) generate-sources-$(DISTRIBUTION)-fips post-compile-check
2323

24-
build: go ocb
25-
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER}
24+
.PHONY: pre-compile-check
25+
pre-compile-check: ensure-goreleaser-up-to-date version-check
2626

27-
build-fips: go ocb
28-
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER} -f true
27+
.PHONY: post-compile-check
28+
post-compile-check: licenses-check
2929

30-
generate: generate-sources generate-goreleaser
30+
.PHONY: generate-sources-$(DISTRIBUTION)
31+
generate-sources-$(DISTRIBUTION): go ocb
32+
@./scripts/build.sh -d "${DISTRIBUTION}" -b ${OTELCOL_BUILDER}
3133

32-
generate-goreleaser: go
33-
@./scripts/generate-goreleaser.sh -d "${DISTRIBUTIONS}" -g ${GO}
34-
35-
generate-sources: go ocb
36-
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER}
34+
.PHONY: generate-sources-$(DISTRIBUTION)-fips
35+
generate-sources-$(DISTRIBUTION)-fips: go ocb
36+
@./scripts/build.sh -d "${DISTRIBUTION}" -b ${OTELCOL_BUILDER} -f true
3737

38-
goreleaser-verify: goreleaser
39-
@${GORELEASER} release --snapshot --clean
38+
.PHONY: generate-goreleaser
39+
generate-goreleaser: go
40+
@./scripts/generate-goreleaser.sh -d "${DISTRIBUTION}" -g ${GO}
4041

42+
.PHONY: ensure-goreleaser-up-to-date
4143
ensure-goreleaser-up-to-date: generate-goreleaser
42-
@git diff -s --exit-code distributions/*/.goreleaser.yaml || (echo "Check failed: The goreleaser templates have changed but the .goreleaser.yamls haven't. Run 'make generate-goreleaser' and update your PR." && exit 1)
44+
@git diff -s --exit-code distributions/*/.goreleaser*.yaml || (echo "Check failed: The goreleaser templates have changed but the .goreleaser.yamls haven't. Run 'make generate-goreleaser' and update your PR." && exit 1)
4345

46+
.PHONY: validate-components
4447
validate-components:
4548
@./scripts/validate-components.sh
4649

@@ -149,16 +152,20 @@ FILENAME?=$(shell git branch --show-current)
149152
NOTICE_OUTPUT?=THIRD_PARTY_NOTICES.md
150153

151154
.PHONY: licenses
152-
licenses: go generate-sources $(GO_LICENCE_DETECTOR)
153-
@./scripts/licenses.sh -d "${DISTRIBUTIONS}" -b ${GO_LICENCE_DETECTOR} -n ${NOTICE_OUTPUT} -g ${GO}
155+
licenses: go $(GO_LICENCE_DETECTOR)
156+
@{ if [ ! -d "distributions/$(DISTRIBUTION)/_build" ]; then $(MAKE) generate-sources-$(DISTRIBUTION); fi }
157+
@./scripts/licenses.sh -d "${DISTRIBUTION}" -b ${GO_LICENCE_DETECTOR} -n ${NOTICE_OUTPUT} -g ${GO}
154158

155159
.PHONY: licenses-check
156160
licenses-check: licenses
157161
@git diff --name-only | grep -q $(NOTICE_OUTPUT) \
158162
&& { \
159-
echo "Third party notices out of date, please run \"make licenses\" and commit the changes in this PR.";\
163+
echo "📜 Third party notices out of date, please run \"make licenses\" and commit the changes in this PR.";\
160164
echo "Diff of $(NOTICE_OUTPUT):";\
161165
git --no-pager diff HEAD -- */$(NOTICE_OUTPUT);\
162166
exit 1;\
163167
} \
164-
|| exit 0
168+
|| { \
169+
echo "📜 Third party notices up to date";\
170+
exit 0;\
171+
}

distributions/nrdot-collector-host/.goreleaser-nightly-fips.yaml

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,6 @@ builds:
3535
env:
3636
- CC=aarch64-linux-gnu-gcc
3737
- CXX=aarch64-linux-gnu-g++
38-
nfpms:
39-
- file_name_template: '{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{- if not (eq (filter .ConventionalFileName "\\.rpm$") "") }}{{- replace .Arch "amd64" "x86_64" }}{{- else }}{{- .Arch }}{{- end }}{{- with .Arm }}v{{ . }}{{- end }}{{- with .Mips }}_{{ . }}{{- end }}{{- if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{- end }}'
40-
package_name: nrdot-collector-host-fips
41-
contents:
42-
- src: nrdot-collector-host-fips.service
43-
dst: /lib/systemd/system/nrdot-collector-host-fips.service
44-
- src: nrdot-collector-host-fips.conf
45-
dst: /etc/nrdot-collector-host-fips/nrdot-collector-host-fips.conf
46-
type: config|noreplace
47-
- src: config.yaml
48-
dst: /etc/nrdot-collector-host-fips/config.yaml
49-
type: config
50-
scripts:
51-
preinstall: preinstall.sh
52-
postinstall: postinstall.sh
53-
preremove: preremove.sh
54-
rpm:
55-
signature:
56-
key_file: '{{ .Env.GPG_KEY_PATH }}'
57-
deb:
58-
signature:
59-
key_file: '{{ .Env.GPG_KEY_PATH }}'
60-
overrides:
61-
rpm:
62-
dependencies:
63-
- /bin/sh
64-
id: nrdot-collector-host-fips
65-
ids:
66-
- nrdot-collector-host-fips
67-
formats:
68-
- deb
69-
- rpm
70-
maintainer: New Relic <[email protected]>
71-
description: NRDOT Collector - nrdot-collector-host-fips
72-
license: Apache 2.0
7338
snapshot:
7439
version_template: '{{ incpatch .Version }}-SNAPSHOT-{{.ShortCommit}}'
7540
checksum:
@@ -124,11 +89,6 @@ docker_manifests:
12489
image_templates:
12590
- '{{ .Env.REGISTRY }}/nrdot-collector-host:nightly-fips-amd64'
12691
- '{{ .Env.REGISTRY }}/nrdot-collector-host:nightly-fips-arm64'
127-
blobs:
128-
- bucket: nr-releases
129-
provider: s3
130-
region: us-east-1
131-
directory: nrdot-collector-releases/nrdot-collector-host-fips/nightly
13292
changelog:
13393
disable: "true"
13494
signs:

0 commit comments

Comments
 (0)