Skip to content

Commit ec50522

Browse files
authored
Merge pull request #5016 from camilamacedo86/fix-unit-test-ci
🌱 (fix): Remove duplication to avoid flakes in the ci and keep it more optimise
2 parents bce265c + ba98038 commit ec50522

File tree

6 files changed

+90
-67
lines changed

6 files changed

+90
-67
lines changed

.github/workflows/coverage.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
paths-ignore: ['**/*.md']
6+
pull_request:
7+
paths-ignore: ['**/*.md']
8+
9+
jobs:
10+
coverage:
11+
runs-on: ubuntu-latest
12+
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository)
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v5
16+
17+
- name: Setup Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version-file: go.mod
21+
22+
- name: Remove pre-installed kustomize
23+
run: sudo rm -f /usr/local/bin/kustomize
24+
25+
- name: Run tests with coverage
26+
run: make test-coverage
27+
28+
- name: Upload coverage to Coveralls
29+
uses: shogo82148/actions-goveralls@v1
30+
with:
31+
path-to-profile: coverage-all.out
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Cross-Platform Tests
2+
3+
# Trigger the workflow on pull requests and direct pushes to any branch
4+
on:
5+
push:
6+
paths-ignore:
7+
- '**/*.md'
8+
pull_request:
9+
paths-ignore:
10+
- '**/*.md'
11+
12+
jobs:
13+
test:
14+
name: ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os:
19+
- ubuntu-latest
20+
- macos-latest
21+
# Pull requests from the same repository won't trigger this checks as they were already triggered by the push
22+
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository)
23+
steps:
24+
- name: Clone the code
25+
uses: actions/checkout@v5
26+
- name: Setup Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version-file: go.mod
30+
# This step is needed as the following one tries to remove
31+
# kustomize for each test but has no permission to do so
32+
- name: Remove pre-installed kustomize
33+
run: sudo rm -f /usr/local/bin/kustomize
34+
35+
- name: Unit Tests
36+
run: make test-unit
37+
38+
- name: Run Testdata
39+
run: make test-testdata
40+
41+
- name: Run Integration Tests
42+
run: make test-integration
43+

.github/workflows/lint.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ jobs:
3434
- uses: actions/checkout@v5
3535
- name: Run yamllint make target
3636
run: make yamllint
37+
38+
license:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v5
42+
- name: Run license check
43+
run: make test-license

.github/workflows/test-e2e-book.yml renamed to .github/workflows/test-book.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ jobs:
4747
- name: Create kind cluster
4848
run: kind create cluster
4949

50+
- name: Running make test for ${{ matrix.folder }}
51+
working-directory: ${{ matrix.folder }}
52+
run: make test
53+
5054
- name: Running make test-e2e for ${{ matrix.folder }}
5155
working-directory: ${{ matrix.folder }}
5256
run: make test-e2e

.github/workflows/unit-tests.yml

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

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ go-apidiff:
144144
##@ Tests
145145

146146
.PHONY: test
147-
test: test-unit test-integration test-testdata test-book test-license ## Run the unit and integration tests (used in the CI)
147+
test: test-unit test-integration test-features test-testdata test-book test-license ## Run the unit and integration tests (used in the CI)
148148

149149
.PHONY: test-unit
150150
TEST_PKGS := ./pkg/... ./test/e2e/utils/...
@@ -156,10 +156,13 @@ test-coverage: ## Run unit tests creating the output to report coverage
156156
- rm -rf *.out # Remove all coverage files if exists
157157
go test -race -failfast -tags=integration -coverprofile=coverage-all.out -coverpkg="./pkg/cli/...,./pkg/config/...,./pkg/internal/...,./pkg/machinery/...,./pkg/model/...,./pkg/plugin/...,./pkg/plugins/golang" $(TEST_PKGS)
158158

159+
.PHONY: test-features
160+
test-features: ## Run the integration tests
161+
./test/features.sh
162+
159163
.PHONY: test-integration
160164
test-integration: ## Run the integration tests
161165
./test/integration.sh
162-
./test/features.sh
163166

164167
.PHONY: check-testdata
165168
check-testdata: ## Run the script to ensure that the testdata is updated

0 commit comments

Comments
 (0)