Skip to content

Commit f473335

Browse files
committed
refactor: cleanup CI inconsistencies
1 parent b762f97 commit f473335

File tree

13 files changed

+97
-69
lines changed

13 files changed

+97
-69
lines changed

.github/workflows/ci-base.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ jobs:
7070
go-version: "~1.24"
7171
cache: ${{ env.caching_enabled }}
7272

73-
- name: Tidy go.mod files
73+
- name: Download dependencies
7474
run: go mod tidy
7575

76-
- name: Ensure goreleaser up to date
77-
run: make check
76+
- name: Run checks
77+
run: make pre-sourcegen-check-${{ inputs.distribution }} DISTRO=${{ inputs.distribution }}
7878

7979
- name: Generate sources cache key
8080
id: sources-cache-key
@@ -100,7 +100,7 @@ jobs:
100100

101101
- name: Generate sources
102102
if: steps.cache-sources.outputs.cache-hit != 'true'
103-
run: make ci DISTRIBUTIONS=${{ inputs.distribution }}
103+
run: make ci DISTRO=${{ inputs.distribution }}
104104

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

.github/workflows/ci-nightly.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ name: 🔄 CI | Nightly Tests (Regular & FIPS)
22
on:
33
workflow_dispatch:
44
schedule:
5-
# Scheduled to run in the morning (PT) on every day-of-week from Monday through Friday.
6-
- cron: "0 15 * * 1-5"
5+
# Scheduled to run in the morning (ET) on every day-of-week from Monday through Friday.
6+
- cron: '0 10 * * 1-5'
7+
78
concurrency:
89
group: ci-nightly
910
cancel-in-progress: false

.github/workflows/deploy-and-e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
TF_VAR_distro: ${{ inputs.distro }}
102102
TF_VAR_fips: ${{ inputs.fips }}
103103
TF_VAR_nightly_docker_manifest_sha: ${{ needs.setup.outputs.docker-manifest-sha }}
104-
TF_VAR_k8s_namespace_prefix: ${{ inputs.workspace_prefix }}
104+
TF_VAR_test_env_prefix: ${{ inputs.workspace_prefix }}
105105
steps:
106106
- name: Checkout repository
107107
uses: actions/checkout@v4

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ distributions/**/manifest-fips.yaml
2929
test/**/charts/*.tgz
3030

3131
# tmp directory used in act builds
32-
.tmp
32+
.tmp
33+
.artifacts

Makefile

Lines changed: 70 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,44 @@ 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+
DISTRO ?= nrdot-collector-host
20+
ALL_DISTROS = nrdot-collector-host nrdot-collector-k8s nrdot-collector
2021

21-
ci: check build build-fips version-check licenses-check
22-
check: ensure-goreleaser-up-to-date
22+
.PHONY: ci
23+
ci: pre-sourcegen-check-$(DISTRO) generate-sources-$(DISTRO) generate-sources-$(DISTRO)-fips post-sourcegen-check-$(DISTRO)
2324

24-
build: go ocb
25-
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER}
25+
.PHONY: pre-sourcegen-check-$(DISTRO)
26+
pre-sourcegen-check-$(DISTRO): ensure-goreleaser-up-to-date-$(DISTRO) version-check
2627

27-
build-fips: go ocb
28-
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER} -f true
28+
.PHONY: post-sourcegen-check-$(DISTRO)
29+
post-sourcegen-check-$(DISTRO): licenses-check-$(DISTRO)
2930

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

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

35-
generate-sources: go ocb
36-
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER}
39+
.PHONY: generate-goreleaser
40+
generate-goreleaser:
41+
@for d in $(ALL_DISTROS); do \
42+
make generate-goreleaser-$$d DISTRO=$$d; \
43+
done
3744

38-
goreleaser-verify: goreleaser
39-
@${GORELEASER} release --snapshot --clean
45+
.PHONY: generate-goreleaser-$(DISTRO)
46+
generate-goreleaser-$(DISTRO): go
47+
@./scripts/generate-goreleaser.sh -d "$(DISTRO)" -g ${GO}
4048

41-
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)
49+
.PHONY: ensure-goreleaser-up-to-date-$(DISTRO)
50+
ensure-goreleaser-up-to-date-$(DISTRO): generate-goreleaser-$(DISTRO)
51+
@{ \
52+
git diff -s --exit-code distributions/*/.goreleaser*.yaml || \
53+
(echo "📋 Check failed: The goreleaser templates have changed but the .goreleaser.yamls haven't. Run 'make generate-goreleaser' and update your PR." && exit 1) \
54+
} && echo "📋 Goreleaser files are up to date."
4355

56+
.PHONY: validate-components
4457
validate-components:
4558
@./scripts/validate-components.sh
4659

@@ -148,17 +161,51 @@ $(TOOLS_BIN_NAMES): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod
148161
FILENAME?=$(shell git branch --show-current)
149162
NOTICE_OUTPUT?=THIRD_PARTY_NOTICES.md
150163

151-
.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}
154164

155-
.PHONY: licenses-check
156-
licenses-check: licenses
165+
166+
.PHONY: licenses
167+
licenses:
168+
@for d in $(ALL_DISTROS); do \
169+
make licenses-$$d DISTRO=$$d; \
170+
done
171+
172+
.PHONY: licenses-$(DISTRO)
173+
licenses-$(DISTRO): go $(GO_LICENCE_DETECTOR)
174+
@{ if [ ! -d "distributions/$(DISTRO)/_build" ]; then $(MAKE) generate-sources-$(DISTRO); fi }
175+
@./scripts/licenses.sh -d "$(DISTRO)" -b ${GO_LICENCE_DETECTOR} -n ${NOTICE_OUTPUT} -g ${GO}
176+
177+
.PHONY: licenses-check-$(DISTRO)
178+
licenses-check-$(DISTRO): licenses-$(DISTRO)
157179
@git diff --name-only | grep -q $(NOTICE_OUTPUT) \
158180
&& { \
159-
echo "Third party notices out of date, please run \"make licenses\" and commit the changes in this PR.";\
181+
echo "📜 Third party notices out of date, please run \"make licenses\" and commit the changes in this PR.";\
160182
echo "Diff of $(NOTICE_OUTPUT):";\
161183
git --no-pager diff HEAD -- */$(NOTICE_OUTPUT);\
162184
exit 1;\
163185
} \
164-
|| exit 0
186+
|| { \
187+
echo "📜 Third party notices up to date";\
188+
exit 0;\
189+
}
190+
191+
192+
.PHONY: clean
193+
clean: clean-build clean-dist clean-tools clean-act-tmp
194+
195+
.PHONY: clean-build
196+
clean-build:
197+
@rm -rf distributions/*/_build
198+
@rm -rf distributions/*/_build-fips
199+
200+
.PHONY: clean-dist
201+
clean-dist:
202+
@rm -rf distributions/*/dist
203+
204+
.PHONY: clean-tools
205+
clean-tools:
206+
@rm -rf .tools
207+
208+
.PHONY: clean-act-tmp
209+
clean-act-tmp:
210+
@rm -rf .artifacts
211+
@rm -rf .tmp

scripts/generate-goreleaser.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if [[ -z $distributions ]]; then
1919
exit 1
2020
fi
2121

22-
echo "Generating goreleaser files for distributions: $distributions";
22+
echo "📋 Generating goreleaser files for distributions: $distributions";
2323

2424
for distribution in $(echo "$distributions" | tr "," "\n")
2525
do

test/charts/nr_backend/values.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,4 @@ secrets:
88
nrBackendUrl: PLACEHOLDER
99
nrIngestKey: PLACEHOLDER
1010

11-
collector:
12-
hostname: nrdot-collector-default-hostname
13-
14-
testKey: testKey-default-value
15-
16-
clusterName: default-cluster-name
11+
testKey: testKey-default-value

test/e2e/nightly/nightly_collector_nr_backend_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ import (
1212
)
1313

1414
var ec2Ubuntu22 = spec.NightlySystemUnderTest{
15-
TestKeyPattern: testutil.NewNrQueryHostNamePattern("nightly", testutil.Wildcard, "ec2_ubuntu22_04"),
15+
TestKeyPattern: testutil.NewTestKeyPattern("nightly", testutil.Wildcard, "ec2_ubuntu22_04"),
1616
SkipIf: func(testSpec *spec.TestSpec) bool {
1717
return !testSpec.Nightly.EC2.Enabled
1818
},
1919
}
2020
var ec2Ubuntu24 = spec.NightlySystemUnderTest{
21-
TestKeyPattern: testutil.NewNrQueryHostNamePattern("nightly", testutil.Wildcard, "ec2_ubuntu24_04"),
21+
TestKeyPattern: testutil.NewTestKeyPattern("nightly", testutil.Wildcard, "ec2_ubuntu24_04"),
2222
SkipIf: func(testSpec *spec.TestSpec) bool {
2323
return !testSpec.Nightly.EC2.Enabled
2424
},
2525
}
2626
var k8sNode = spec.NightlySystemUnderTest{
27-
TestKeyPattern: testutil.NewNrQueryHostNamePattern("nightly", testutil.Wildcard, "k8s_node"),
27+
TestKeyPattern: testutil.NewTestKeyPattern("nightly", testutil.Wildcard, "k8s_node"),
2828
}
2929

3030
func TestNightlyCollectorWithNrBackend(t *testing.T) {

test/e2e/util/test/hostname.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const (
1010
hostNameSegmentSeparator = "-"
1111
)
1212

13-
func NewNrQueryHostNamePattern(envName string, deployId string, hostType string) string {
13+
func NewTestKeyPattern(envName string, deployId string, hostType string) string {
1414
distro := envutil.GetDistro()
1515

1616
if envutil.IsFipsMode() {

test/terraform/modules/ec2/main.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
locals {
2-
collector_reported_hostname_prefix = "${var.test_environment}-${var.deploy_id}-${var.collector_distro}"
32
instance_config = [
43
{
5-
hostname_suffix = "ec2_ubuntu22_04-0"
4+
test_key_suffix = "ec2_ubuntu22_04-0"
65
release_verion = "22.04"
76
release_short_name = "jammy"
87
},
98
{
10-
hostname_suffix = "ec2_ubuntu24_04-0"
9+
test_key_suffix = "ec2_ubuntu24_04-0"
1110
release_verion = "24.04"
1211
release_short_name = "noble"
1312
},
@@ -139,7 +138,7 @@ resource "aws_instance" "ubuntu" {
139138
################################################
140139
echo 'Configuring Collector'
141140
echo 'NEW_RELIC_LICENSE_KEY=${var.nr_ingest_key}' >> /etc/${var.collector_distro}/${var.collector_distro}.conf
142-
echo "OTEL_RESOURCE_ATTRIBUTES='testKey=${local.collector_reported_hostname_prefix}-${local.instance_config[count.index].hostname_suffix}'" >> /etc/${var.collector_distro}/${var.collector_distro}.conf
141+
echo "OTEL_RESOURCE_ATTRIBUTES='testKey=${var.test_key_prefix}-${local.instance_config[count.index].test_key_suffix}'" >> /etc/${var.collector_distro}/${var.collector_distro}.conf
143142
systemctl reload-or-restart ${var.collector_distro}.service
144143
EOF
145144
}

0 commit comments

Comments
 (0)