Skip to content

Commit 9861e0a

Browse files
authored
[chore] make contrib tests more efficient (#12490)
Instead of having each test group edit modules, tidy and generate, do it once and share the output in each subtest to save 5 minutes per branch.
1 parent 80fd856 commit 9861e0a

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

.github/workflows/contrib-tests.yml

+26-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,26 @@ concurrency:
1717
permissions: read-all
1818

1919
jobs:
20+
contrib-tests-prepare:
21+
runs-on: ubuntu-latest
22+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'Skip Contrib Tests') }}
23+
steps:
24+
- name: Checkout Repo
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
- name: Prepare Contrib Tests
27+
run: |
28+
contrib_path=/tmp/opentelemetry-collector-contrib
29+
git clone --depth=1 https://github.com/open-telemetry/opentelemetry-collector-contrib.git $contrib_path
30+
make CONTRIB_PATH=$contrib_path prepare-contrib
31+
- uses: actions/upload-artifact@v4
32+
with:
33+
name: contrib
34+
path: /tmp/opentelemetry-collector-contrib/
35+
include-hidden-files: true
36+
2037
contrib-tests-matrix:
2138
runs-on: ubuntu-latest
39+
needs: [contrib-tests-prepare]
2240
if: ${{ !contains(github.event.pull_request.labels.*.name, 'Skip Contrib Tests') }}
2341
strategy:
2442
fail-fast: false
@@ -40,16 +58,20 @@ jobs:
4058
steps:
4159
- name: Checkout Repo
4260
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
61+
- name: Download contrib
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: contrib
65+
path: /tmp/contrib
4366
- name: Setup Go
4467
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
4568
with:
4669
go-version: ~1.23.6
4770
cache: false
48-
- name: Run Contrib Tests
71+
- name: Run tests
4972
run: |
50-
contrib_path=/tmp/opentelemetry-collector-contrib
51-
git clone --depth=1 https://github.com/open-telemetry/opentelemetry-collector-contrib.git $contrib_path
52-
make CONTRIB_PATH=$contrib_path SKIP_RESTORE_CONTRIB=true GROUP=${{ matrix.group }} check-contrib
73+
chmod +x /tmp/contrib/.tools/*
74+
make CONTRIB_PATH=/tmp/contrib SKIP_RESTORE_CONTRIB=true GROUP=${{ matrix.group }} check-contrib
5375
5476
contrib_tests:
5577
runs-on: ubuntu-latest

Makefile

+6-4
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,19 @@ gensemconv: $(SEMCONVGEN) $(SEMCONVKIT)
261261

262262
ALL_MOD_PATHS := "" $(ALL_MODULES:.%=%)
263263

264-
# Checks that the HEAD of the contrib repo checked out in CONTRIB_PATH compiles
265-
# against the current version of this repo.
266-
.PHONY: check-contrib
267-
check-contrib:
264+
.PHONY: prepare-contrib
265+
prepare-contrib:
268266
@echo Setting contrib at $(CONTRIB_PATH) to use this core checkout
269267
@$(MAKE) -j2 -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit \
270268
$(addprefix -replace ,$(join $(ALL_MOD_PATHS:%=go.opentelemetry.io/collector%=),$(ALL_MOD_PATHS:%=$(CURDIR)%)))"
271269
@$(MAKE) -j2 -C $(CONTRIB_PATH) gotidy
272270

273271
@$(MAKE) generate-contrib
274272

273+
# Checks that the HEAD of the contrib repo checked out in CONTRIB_PATH compiles
274+
# against the current version of this repo.
275+
.PHONY: check-contrib
276+
check-contrib:
275277
@echo -e "\nRunning tests"
276278
@$(MAKE) -C $(CONTRIB_PATH) gotest
277279

0 commit comments

Comments
 (0)