Repository navigation
174 lines (165 loc) · 6.59 KB
/
Copy pathci.yml
File metadata and controls
174 lines (165 loc) · 6.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: CI
on:
push:
branches: [main]
pull_request:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# Gate the Rust jobs on Rust changes, so docs-only changes skip lint and test.
# `main` is protected (PR-only), so validation is the PR's job; on push to main
# only `test` re-runs (for the Codecov base, below). Skip the whole workflow on
# knope's own release-bump commit - it re-pushes to main and would otherwise
# duplicate everything. `head_commit` is null on pull_request events, so this
# guard only ever suppresses that one push.
changes:
name: Detect changes
if: "${{ !startsWith(github.event.head_commit.message, 'chore: prepare release') }}"
runs-on: ubuntu-latest
outputs:
rust: ${{ steps.filter.outputs.rust }}
helm: ${{ steps.filter.outputs.helm }}
steps:
- uses: actions/checkout@v7
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
rust:
- '**/*.rs'
- '**/Cargo.toml'
- 'Cargo.lock'
- 'deny.toml'
- '.github/workflows/ci.yml'
helm:
- 'chart/**'
- '.github/workflows/ci.yml'
lint:
name: Lint
needs: changes
# PR-only: a merge lands the exact tree already linted on the PR.
if: github.event_name == 'pull_request' && needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all --check
- name: Run clippy
run: cargo clippy --all-targets --all-features --locked -- -D warnings
test:
name: Test and coverage
needs: changes
# The one job that also runs on push to main: it re-uploads coverage so
# Codecov's project base (codecov.yml `project: auto`, 0% drop) tracks the
# merged main, not a stale ancestor. The knope commit is already excluded via
# `changes` above (a version bump does not change coverage anyway).
if: needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Test and collect coverage
# Exclude the thin binary shim (src/main.rs: arg parsing, wiring, serve) from
# the coverage number - it is not unit-testable and the logic it wires up is
# covered via the library by the integration tests. Fail if under 80%.
run: |
cargo llvm-cov --all-features --locked --ignore-filename-regex 'src/main\.rs' --lcov --output-path lcov.info
cargo llvm-cov report --ignore-filename-regex 'src/main\.rs' --summary-only --fail-under-lines 80
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v7
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
# Scan the dependency tree for security advisories, disallowed licenses, and
# non-crates.io sources (config in deny.toml).
deny:
name: Dependencies
needs: changes
# PR-only: the dependency tree that merges is the one already scanned.
if: github.event_name == 'pull_request' && needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: taiki-e/install-action@v2
with:
tool: cargo-deny
- name: Check dependencies
run: cargo deny check
helm:
name: Lint and validate Helm chart
needs: changes
# PR-only: a merge lands the exact chart already validated on the PR.
if: github.event_name == 'pull_request' && needs.changes.outputs.helm == 'true'
runs-on: ubuntu-latest
env:
# kubeconform release used to validate rendered manifests against the
# Kubernetes schemas.
KUBECONFORM_VERSION: v0.6.7
steps:
- uses: actions/checkout@v7
- uses: azure/setup-helm@v5
- name: Install kubeconform
shell: bash
run: |
set -euo pipefail
# -f: fail on an HTTP error instead of piping the error page into tar;
# --retry: ride out a transient release-asset hiccup rather than flake.
curl -fsSL --retry 3 --retry-all-errors \
"https://github.com/yannh/kubeconform/releases/download/${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz" \
| tar -xz -C /usr/local/bin kubeconform
- name: Lint, render, and validate the chart
shell: bash
run: |
set -euo pipefail
helm lint chart
# Render under a few value combinations so the conditional templates
# (Ingress, emptyDir, ServiceMonitor, CA trust, auth secrets) are all
# exercised, then validate each render against the Kubernetes schemas.
# -strict rejects unknown fields; -ignore-missing-schemas skips CRDs
# (the ServiceMonitor).
for args in \
"" \
"--set ingress.enabled=true" \
"--set persistence.enabled=false" \
"--set serviceMonitor.enabled=true" \
"--set caTrust.enabled=true,caTrust.configMapName=ca" \
"--set upstreamAuth.existingSecret=up,serveToken.existingSecret=srv"; do
echo "-- helm template chart $args"
helm template release chart $args \
| kubeconform -strict -summary -ignore-missing-schemas
done
# Spelling runs on every PR, including docs. PR-only: a merge lands the same tree.
typos:
name: Typos
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: crate-ci/typos@v1
# Conventional Commits check for pull requests (advisory; direct pushes to main are
# covered by a local commit-msg hook - see CONTRIBUTING.md).
commits:
name: Commit messages
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
# Dependabot commit messages are auto-generated: long changelog and URL
# lines in the body exceed line_length and long dep names exceed
# subject_length, neither of which is configurable. Exempt them (keyed on
# PR author so maintainer re-runs stay stable); the job still runs green.
- if: github.event.pull_request.user.login != 'dependabot[bot]'
uses: crate-ci/committed@v1.1.12