mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Merge pull request #6020 from koba1t/chore/parallelizing_tests
CI: parallelizing tests
This commit is contained in:
112
.github/workflows/go.yml
vendored
112
.github/workflows/go.yml
vendored
@@ -2,14 +2,15 @@ name: Go
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
## TODO: conditional-changes checker is not working
|
||||||
conditional-changes:
|
conditional-changes:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
@@ -27,7 +28,7 @@ jobs:
|
|||||||
|
|
||||||
check-modules:
|
check-modules:
|
||||||
name: check-synced-go-modules
|
name: check-synced-go-modules
|
||||||
needs: conditional-changes
|
# needs: conditional-changes
|
||||||
# if: needs.conditional-changes.outputs.doc == 'false'
|
# if: needs.conditional-changes.outputs.doc == 'false'
|
||||||
runs-on: [ubuntu-latest]
|
runs-on: [ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
@@ -39,6 +40,9 @@ jobs:
|
|||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version-file: go.work
|
go-version-file: go.work
|
||||||
|
cache: true
|
||||||
|
cache-dependency-path: |
|
||||||
|
**/go.sum
|
||||||
id: go
|
id: go
|
||||||
- name: sync go modules
|
- name: sync go modules
|
||||||
run: make workspace-sync
|
run: make workspace-sync
|
||||||
@@ -47,7 +51,7 @@ jobs:
|
|||||||
|
|
||||||
lint:
|
lint:
|
||||||
name: Lint
|
name: Lint
|
||||||
needs: conditional-changes
|
# needs: conditional-changes
|
||||||
# if: needs.conditional-changes.outputs.doc == 'false'
|
# if: needs.conditional-changes.outputs.doc == 'false'
|
||||||
runs-on: [ubuntu-latest]
|
runs-on: [ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
@@ -59,15 +63,19 @@ jobs:
|
|||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version-file: go.work
|
go-version-file: go.work
|
||||||
|
cache: true
|
||||||
|
cache-dependency-path: |
|
||||||
|
**/go.sum
|
||||||
id: go
|
id: go
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: make lint
|
run: make lint
|
||||||
- name: Verify boilerplate
|
- name: Verify boilerplate
|
||||||
run: make check-license
|
run: make check-license
|
||||||
|
|
||||||
test-linux:
|
## Test all modules without plugins and released modules
|
||||||
|
test-non-released-modules:
|
||||||
name: Test Linux
|
name: Test Linux
|
||||||
needs: conditional-changes
|
# needs: conditional-changes
|
||||||
# if: needs.conditional-changes.outputs.doc == 'false'
|
# if: needs.conditional-changes.outputs.doc == 'false'
|
||||||
runs-on: [ubuntu-latest]
|
runs-on: [ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
@@ -77,17 +85,46 @@ jobs:
|
|||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version-file: go.work
|
go-version-file: go.work
|
||||||
|
cache: true
|
||||||
|
cache-dependency-path: |
|
||||||
|
**/go.sum
|
||||||
id: go
|
id: go
|
||||||
- name: Test all modules
|
- name: Test all modules without plugins and released modules
|
||||||
run: make test-unit-non-plugin
|
run: make test-unit-non-plugin-and-non-released
|
||||||
env:
|
env:
|
||||||
KUSTOMIZE_DOCKER_E2E: true
|
KUSTOMIZE_DOCKER_E2E: true
|
||||||
|
|
||||||
test-macos:
|
test-modules:
|
||||||
name: Test MacOS
|
name: Test ${{ matrix.os }} - ${{ matrix.module }}
|
||||||
needs: conditional-changes
|
# needs: conditional-changes
|
||||||
# if: needs.conditional-changes.outputs.doc == 'false'
|
# if: needs.conditional-changes.outputs.doc == 'false'
|
||||||
runs-on: [macos-latest]
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
module:
|
||||||
|
- kyaml
|
||||||
|
- cmd/config
|
||||||
|
- api
|
||||||
|
- kustomize
|
||||||
|
include:
|
||||||
|
- module: kyaml
|
||||||
|
test-cmd: go test -race -v -cover ./...
|
||||||
|
- module: cmd/config
|
||||||
|
test-cmd: go test -v -cover ./...
|
||||||
|
- module: api
|
||||||
|
test-cmd: go test -v -cover ./... -ldflags "-X sigs.k8s.io/kustomize/api/provenance.buildDate=2023-01-31T23:38:41Z -X sigs.k8s.io/kustomize/api/provenance.version=(test)"
|
||||||
|
- module: kustomize
|
||||||
|
test-cmd: go test -v -cover ./...
|
||||||
|
- os: ubuntu-latest
|
||||||
|
docker-e2e: true
|
||||||
|
- os: macos-latest
|
||||||
|
docker-e2e: false
|
||||||
|
- os: windows-latest
|
||||||
|
docker-e2e: false
|
||||||
|
env:
|
||||||
|
KUSTOMIZE_DOCKER_E2E: ${{ matrix.docker-e2e }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
@@ -95,36 +132,27 @@ jobs:
|
|||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version-file: go.work
|
go-version-file: go.work
|
||||||
|
cache: true
|
||||||
|
cache-dependency-path: |
|
||||||
|
**/go.sum
|
||||||
id: go
|
id: go
|
||||||
- name: Test all modules
|
- name: Test ${{ matrix.module }}
|
||||||
run: make test-unit-non-plugin
|
run: ${{ matrix.test-cmd }}
|
||||||
env:
|
# TODO (#4001): replace specific modules above with this once Windows tests are passing.
|
||||||
KUSTOMIZE_DOCKER_E2E: false # docker not installed on mac
|
if: ${{ !(matrix.os == 'windows-latest' && (matrix.module == 'api' || matrix.module == 'kustomize')) }}
|
||||||
|
working-directory: ./${{ matrix.module }}
|
||||||
|
|
||||||
test-windows:
|
# Aggregation matrix tests from test-modules for branch protection rules
|
||||||
name: Test Windows
|
test-modules-summary:
|
||||||
needs: conditional-changes
|
name: Test Summary
|
||||||
# if: needs.conditional-changes.outputs.doc == 'false'
|
runs-on: ubuntu-latest
|
||||||
runs-on: [windows-latest]
|
needs: test-modules
|
||||||
|
if: always()
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code into the Go module directory
|
- name: Check test results
|
||||||
uses: actions/checkout@v6
|
run: |
|
||||||
- name: Set up Go 1.x
|
if [[ "${{ needs.test-modules.result }}" != "success" ]]; then
|
||||||
uses: actions/setup-go@v6
|
echo "Some tests failed or were cancelled"
|
||||||
with:
|
exit 1
|
||||||
go-version-file: go.work
|
fi
|
||||||
id: go
|
echo "All tests passed successfully"
|
||||||
- name: Test kyaml
|
|
||||||
run: go test -cover ./...
|
|
||||||
working-directory: ./kyaml
|
|
||||||
- name: Test cmd/config
|
|
||||||
run: go test -cover ./...
|
|
||||||
working-directory: ./cmd/config
|
|
||||||
env:
|
|
||||||
KUSTOMIZE_DOCKER_E2E: false # docker on windows not working well yet
|
|
||||||
|
|
||||||
# TODO (#4001): replace specific modules above with this once Windows tests are passing.
|
|
||||||
#- name: Test all modules
|
|
||||||
# run: make test-unit-non-plugin
|
|
||||||
# env:
|
|
||||||
# KUSTOMIZE_DOCKER_E2E: false # docker on windows not working well yet
|
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -136,11 +136,15 @@ test-unit-all: \
|
|||||||
test-unit-non-plugin \
|
test-unit-non-plugin \
|
||||||
test-unit-kustomize-plugins
|
test-unit-kustomize-plugins
|
||||||
|
|
||||||
# This target is used by our Github Actions CI to run unit tests for all non-plugin modules in multiple GOOS environments.
|
|
||||||
.PHONY: test-unit-non-plugin
|
.PHONY: test-unit-non-plugin
|
||||||
test-unit-non-plugin:
|
test-unit-non-plugin:
|
||||||
./hack/for-each-module.sh "make test" "./plugin/*" 20
|
./hack/for-each-module.sh "make test" "./plugin/*" 20
|
||||||
|
|
||||||
|
# This target is used by our Github Actions CI to run unit tests for all non-plugin and non-released modules in multiple GOOS environments.
|
||||||
|
.PHONY: test-unit-non-plugin-and-non-released
|
||||||
|
test-unit-non-plugin-and-non-released:
|
||||||
|
./hack/for-each-module.sh "make test" "./plugin/*|./kyaml/go.mod|./cmd/config/go.mod|./api/go.mod|./kustomize/go.mod" 16
|
||||||
|
|
||||||
.PHONY: build-non-plugin-all
|
.PHONY: build-non-plugin-all
|
||||||
build-non-plugin-all:
|
build-non-plugin-all:
|
||||||
./hack/for-each-module.sh "make build" "./plugin/*" 20
|
./hack/for-each-module.sh "make build" "./plugin/*" 20
|
||||||
@@ -183,7 +187,7 @@ test-examples-kustomize-against-latest-release: $(MYGOBIN)/mdrip
|
|||||||
workspace-sync:
|
workspace-sync:
|
||||||
go work sync
|
go work sync
|
||||||
./hack/doGoMod.sh tidy
|
./hack/doGoMod.sh tidy
|
||||||
|
|
||||||
# --- Cleanup targets ---
|
# --- Cleanup targets ---
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: clean-kustomize-external-go-plugin uninstall-tools
|
clean: clean-kustomize-external-go-plugin uninstall-tools
|
||||||
|
|||||||
@@ -22,8 +22,18 @@ seen=()
|
|||||||
KUSTOMIZE_ROOT=$(pwd)
|
KUSTOMIZE_ROOT=$(pwd)
|
||||||
export KUSTOMIZE_ROOT
|
export KUSTOMIZE_ROOT
|
||||||
|
|
||||||
|
# Build find command with multiple -not -path options
|
||||||
|
find_cmd="find . -name go.mod -not -path \"./site/*\""
|
||||||
|
if [[ -n "$skip_pattern" ]]; then
|
||||||
|
# Split skip_pattern by | and add -not -path for each
|
||||||
|
IFS='|' read -ra PATTERNS <<< "$skip_pattern"
|
||||||
|
for pattern in "${PATTERNS[@]}"; do
|
||||||
|
find_cmd+=" -not -path \"$pattern\""
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# verify all modules pass validation
|
# verify all modules pass validation
|
||||||
for i in $(find . -name go.mod -not -path "./site/*" -not -path "$skip_pattern"); do
|
for i in $(eval "$find_cmd"); do
|
||||||
pushd .
|
pushd .
|
||||||
cd $(dirname "$i");
|
cd $(dirname "$i");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user