Skip to content

Commit b6e1991

Browse files
authored
ci: dedicated UT jobs for CA and VPA (#8669)
* ci: dedicated UT jobs for CA and VPA * changes to ca and vpa to trigger tests * missing ;; * rename test configs to Cluster Autoscaler and Vertical Pod Autoscaler
1 parent d4c3829 commit b6e1991

File tree

7 files changed

+115
-55
lines changed

7 files changed

+115
-55
lines changed

.github/workflows/ca-test.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Cluster Autoscaler
2+
3+
on:
4+
push:
5+
paths:
6+
- 'cluster-autoscaler/**'
7+
pull_request:
8+
paths:
9+
- 'cluster-autoscaler/**'
10+
11+
env:
12+
GOPATH: ${{ github.workspace }}/go
13+
14+
permissions:
15+
contents: read
16+
checks: write
17+
18+
jobs:
19+
test:
20+
name: Run unit tests
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/[email protected]
24+
with:
25+
path: ${{ env.GOPATH }}/src/k8s.io/autoscaler
26+
27+
- name: Set up Go
28+
uses: actions/[email protected]
29+
with:
30+
go-version: '1.24.0'
31+
cache-dependency-path: |
32+
${{ env.GOPATH}}/src/k8s.io/autoscaler/cluster-autoscaler/go.sum
33+
34+
- name: Apt-get
35+
run: sudo apt-get install libseccomp-dev -qq
36+
37+
- name: Test
38+
working-directory: ${{ env.GOPATH }}/src/k8s.io/autoscaler
39+
run: hack/for-go-proj.sh cluster-autoscaler
40+
env:
41+
GO111MODULE: auto
42+
PROJECT_NAMES: ""

.github/workflows/ci.yaml renamed to .github/workflows/verify.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests
1+
name: Verify Go
22

33
on:
44
- push
@@ -12,7 +12,7 @@ permissions:
1212
checks: write
1313

1414
jobs:
15-
test-and-verify:
15+
verify:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/[email protected]
@@ -42,9 +42,3 @@ jobs:
4242
run: hack/verify-all.sh -v
4343
env:
4444
GO111MODULE: auto
45-
46-
- name: Test
47-
working-directory: ${{ env.GOPATH }}/src/k8s.io/autoscaler
48-
run: hack/for-go-proj.sh test
49-
env:
50-
GO111MODULE: auto

.github/workflows/vpa-golangci-lint.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Lint
1+
name: Vertical Pod Autoscaler
22

33
on:
44
push:
@@ -15,8 +15,8 @@ permissions:
1515
contents: read
1616

1717
jobs:
18-
golangci:
19-
name: golangci-lint - VPA
18+
lint:
19+
name: Run golangci-lint
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v5

.github/workflows/vpa-test.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Vertical Pod Autoscaler
2+
3+
on:
4+
push:
5+
paths:
6+
- 'vertical-pod-autoscaler/**'
7+
pull_request:
8+
paths:
9+
- 'vertical-pod-autoscaler/**'
10+
11+
env:
12+
GOPATH: ${{ github.workspace }}/go
13+
14+
permissions:
15+
contents: read
16+
checks: write
17+
18+
jobs:
19+
test:
20+
name: Run unit tests
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/[email protected]
24+
with:
25+
path: ${{ env.GOPATH }}/src/k8s.io/autoscaler
26+
27+
- name: Set up Go
28+
uses: actions/[email protected]
29+
with:
30+
go-version: '1.24.0'
31+
cache-dependency-path: |
32+
${{ env.GOPATH}}/src/k8s.io/autoscaler/vertical-pod-autoscaler/go.sum
33+
${{ env.GOPATH}}/src/k8s.io/autoscaler/vertical-pod-autoscaler/e2e/go.sum
34+
35+
- name: Apt-get
36+
run: sudo apt-get install libseccomp-dev -qq
37+
38+
- name: Test
39+
working-directory: ${{ env.GOPATH }}/src/k8s.io/autoscaler
40+
run: hack/for-go-proj.sh vertical-pod-autoscaler
41+
env:
42+
GO111MODULE: auto
43+
PROJECT_NAMES: ""

cluster-autoscaler/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Introduction
55

66
Cluster Autoscaler is a tool that automatically adjusts the size of the Kubernetes cluster when one of the following conditions is true:
7-
* there are pods that failed to run in the cluster due to insufficient
7+
* there are pods that failed to be scheduled in the cluster due to insufficient
88
resources.
99
* there are nodes in the cluster that have been underutilized for an extended period of time and their pods can be placed on other existing nodes.
1010

hack/for-go-proj.sh

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,58 +19,39 @@ set -o pipefail
1919
set -o nounset
2020

2121
CONTRIB_ROOT="$(dirname ${BASH_SOURCE})/.."
22-
PROJECT_NAMES=(addon-resizer vertical-pod-autoscaler)
2322

2423
if [[ $# -ne 1 ]]; then
25-
echo "missing subcommand: [build|install|test]"
24+
echo "missing subcommand: [cluster-autoscaler|vertical-pod-autoscaler|addon-resizer]"
2625
exit 1
2726
fi
2827

29-
CMD="${1}"
30-
31-
case "${CMD}" in
32-
"build")
28+
PROJECT="${1}"
29+
30+
case "${PROJECT}" in
31+
"cluster-autoscaler")
32+
pushd ${CONTRIB_ROOT}/cluster-autoscaler/
33+
# TODO: #8127 - Use default analyzers set by `go test` to include `printf` analyzer.
34+
# Default analyzers that go test runs according to https://github.com/golang/go/blob/52624e533fe52329da5ba6ebb9c37712048168e0/src/cmd/go/internal/test/test.go#L649
35+
# This doesn't include the `printf` analyzer until cluster-autoscaler libraries are updated.
36+
ANALYZERS="atomic,bool,buildtags,directive,errorsas,ifaceassert,nilfunc,slog,stringintconv,tests"
37+
go test -count=1 ./... -vet="${ANALYZERS}"
38+
popd
3339
;;
34-
"install")
40+
"vertical-pod-autoscaler")
41+
pushd ${CONTRIB_ROOT}/vertical-pod-autoscaler
42+
go test -count=1 -race $(go list ./... | grep -v /vendor/ | grep -v vertical-pod-autoscaler/e2e | grep -v cluster-autoscaler/apis)
43+
popd
44+
pushd ${CONTRIB_ROOT}/vertical-pod-autoscaler/e2e
45+
go test -run=None ./...
46+
popd
3547
;;
36-
"test")
48+
"addon-resizer")
49+
pushd ${CONTRIB_ROOT}/addon-resizer
50+
godep go test -race $(go list ./... | grep -v /vendor/ | grep -v vertical-pod-autoscaler/e2e)
51+
popd
3752
;;
3853
*)
3954
echo "invalid subcommand: ${CMD}"
4055
exit 1
4156
;;
4257
esac
43-
44-
for project_name in ${PROJECT_NAMES[*]}; do
45-
(
46-
export GO111MODULE=auto
47-
project=${CONTRIB_ROOT}/${project_name}
48-
echo "${CMD}ing ${project}"
49-
cd "${project}"
50-
case "${CMD}" in
51-
"test")
52-
if [[ -n $(find . -name "Godeps.json") ]]; then
53-
godep go test -race $(go list ./... | grep -v /vendor/ | grep -v vertical-pod-autoscaler/e2e)
54-
else
55-
go test -count=1 -race $(go list ./... | grep -v /vendor/ | grep -v vertical-pod-autoscaler/e2e | grep -v cluster-autoscaler/apis)
56-
fi
57-
;;
58-
*)
59-
godep go "${CMD}" ./...
60-
;;
61-
esac
62-
)
63-
done;
64-
65-
if [ "${CMD}" = "build" ] || [ "${CMD}" == "test" ]; then
66-
pushd ${CONTRIB_ROOT}/vertical-pod-autoscaler/e2e
67-
go test -run=None ./...
68-
popd
69-
pushd ${CONTRIB_ROOT}/cluster-autoscaler/
70-
# TODO: #8127 - Use default analyzers set by `go test` to include `printf` analyzer.
71-
# Default analyzers that go test runs according to https://github.com/golang/go/blob/52624e533fe52329da5ba6ebb9c37712048168e0/src/cmd/go/internal/test/test.go#L649
72-
# This doesn't include the `printf` analyzer until cluster-autoscaler libraries are updated.
73-
ANALYZERS="atomic,bool,buildtags,directive,errorsas,ifaceassert,nilfunc,slog,stringintconv,tests"
74-
go test -count=1 ./... -vet="${ANALYZERS}"
75-
popd
76-
fi

vertical-pod-autoscaler/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
Vertical Pod Autoscaler (VPA) frees users from the necessity of setting
1515
up-to-date resource requests for the containers in their pods. When
1616
configured, it will set the requests automatically based on usage and thus
17-
allow proper scheduling onto nodes so that appropriate resource amount is
17+
allow proper scheduling onto nodes so that appropriate resource overhead is
1818
available for each pod. It will also maintain ratios between requests and
1919
limits that were specified in initial containers configuration.
2020

0 commit comments

Comments
 (0)