Merge pull request #2528 from mrueg/metrics-best-practices #3603
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: continuous-integration | |
on: | |
push: | |
branches: | |
- main | |
- release* | |
tags: | |
- v1.* | |
- v2.* | |
pull_request: | |
branches: | |
- main | |
- release* | |
permissions: | |
contents: read | |
env: | |
E2E_SETUP_KIND: yes | |
E2E_SETUP_KUBECTL: yes | |
SUDO: sudo | |
GO_VERSION: "^1.23" | |
GOLANGCI_LINT_VERSION: "v1.61.0" | |
jobs: | |
ci-go-lint: | |
name: ci-go-lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Setup environment | |
run: | | |
make install-tools | |
- name: Lint | |
run: | | |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${{ env.GOLANGCI_LINT_VERSION }} | |
make lint | |
ci-validate-manifests: | |
name: ci-validate-manifests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Setup environment | |
run: | | |
make install-tools | |
- name: Validate generated manifests | |
run: | | |
make validate-manifests | |
ci-validate-go-modules: | |
name: ci-validate-go-modules | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Setup environment | |
run: | | |
make install-tools | |
- name: Validate go modules | |
run: | | |
make validate-modules | |
ci-validate-docs: | |
name: ci-validate-docs | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Setup environment | |
run: | | |
make install-tools | |
- name: Check that all metrics are documented and templates have no delta | |
run: | | |
make doccheck | |
ci-unit-tests: | |
name: ci-unit-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Setup environment | |
run: | | |
make install-tools | |
- name: Unit tests | |
run: | | |
make test-unit | |
ci-rule-tests: | |
name: ci-rule-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Setup promtool | |
run: | | |
make install-promtool | |
- name: Rule tests | |
run: | | |
PROMTOOL_CLI=./promtool make test-rules | |
ci-benchmark-tests: | |
name: ci-benchmark-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Setup environment | |
run: | | |
make install-tools | |
- name: Benchmark tests | |
run: | | |
BENCHSTAT_OUTPUT_FILE=result.txt make test-benchmark-compare | |
- run: | | |
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" | |
cat result.txt >> "$GITHUB_STEP_SUMMARY" | |
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" | |
cat <<EOL >> "$GITHUB_STEP_SUMMARY" | |
<hr /> | |
The table shows the median and 95% confidence interval (CI) summaries for each benchmark comparing the HEAD and the BASE, and an A/B comparison under "vs base". The last column shows the statistical p-value with ten runs (n=10). | |
The last row has the Geometric Mean (geomean) for the given rows in the table. | |
Refer to <a href="https://pkg.go.dev/golang.org/x/perf/cmd/benchstat">benchstat's documentation</a> for more help. | |
EOL | |
ci-build-kube-state-metrics: | |
name: ci-build-kube-state-metrics | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Setup environment | |
run: | | |
make install-tools | |
- name: Build | |
run: | | |
make build | |
ci-e2e-tests: | |
name: ci-e2e-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Setup environment | |
run: | | |
make install-tools | |
- name: End-to-end tests | |
run: | | |
make e2e |