Skip to content

Commit a21e0ab

Browse files
committed
chore: add improved dx and docs
- add modern improved development docs - tidy development files
1 parent 834a19d commit a21e0ab

9 files changed

+269
-105
lines changed

README.org

Lines changed: 9 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,22 @@
1-
* verify-conformance-release
1+
* verify-conformance
2+
3+
#+begin_quote
4+
a GitHub bot for verifying conformance submissions on github.com/cncf/k8s-conformance
5+
#+end_quote
26

37
The behaviour of the bot is described here, in [[https://cucumber.io/docs/gherkin/][Gherkin]]. Each scenario is a requirement a PR must meet to qualify for conformance.
48

59
Note: the line immediately beneath the scenario is the comment posted to the PR if the requirement is not met.
610

711
See the feature scenarios, [[./kodata/features/verify-conformance-release.feature][in ./kodata/features]].
812

9-
* Build locally
10-
#+begin_src tmate :window prow-config
11-
ko build --local -B --tags latest .
12-
#+end_src
13+
* Developing
1314

14-
* Set up local dev
15-
Log into GitHub regularly
16-
#+begin_src tmate :window prow-config
17-
unset GITHUB_TOKEN
18-
gh auth login
19-
#+end_src
20-
21-
Update the oauth secret
22-
#+begin_src shell
23-
kubectl -n prow create secret generic prow-github-oauth \
24-
--from-literal=oauth=$(yq e '."github.com".oauth_token' -P - < ~/.config/gh/hosts.yml) \
25-
--dry-run=client -o yaml \
26-
| kubectl apply -f -
27-
#+end_src
15+
build a container with
2816

29-
#+RESULTS:
30-
#+begin_example
31-
secret/prow-github-oauth configured
32-
#+end_example
33-
34-
Install the config
35-
#+begin_src shell
36-
kubectl -n prow create cm vcr-config --from-file=vcr.yaml=./hack/vcr.yaml --dry-run=client -o yaml | \
37-
kubectl -n prow apply -f -
38-
#+end_src
39-
40-
#+RESULTS:
41-
#+begin_example
42-
configmap/vcr-config created
43-
#+end_example
44-
45-
Install the plugin
4617
#+begin_src tmate :window prow-config
47-
ko apply --local -B -f ./hack/verify-conformance-release-deployment-dev-temp.yaml -- -n prow
18+
ko build --local --base-import-paths .
4819
#+end_src
4920

50-
#+RESULTS:
51-
#+begin_example
52-
deployment.apps/verify-conformance-release created
53-
#+end_example
54-
55-
Read the logs
56-
#+begin_src tmate :window prow-config
57-
kubectl -n prow logs -l app=verify-conformance-release --tail=50 -f
58-
#+end_src
59-
60-
Restart it
61-
#+begin_src tmate :window prow-config
62-
kubectl -n prow rollout restart deployment verify-conformance-release
63-
#+end_src
64-
65-
#+RESULTS:
66-
#+begin_example
67-
deployment.apps/verify-conformance-release restarted
68-
#+end_example
69-
70-
Uninstall the plugin
71-
#+begin_src shell
72-
kubectl -n prow delete -f ./hack/verify-conformance-release-deployment-dev-temp.yaml
73-
#+end_src
74-
75-
#+RESULTS:
76-
#+begin_example
77-
deployment.apps "verify-conformance-release" deleted
78-
#+end_example
79-
80-
* Run trial-implementation
81-
#+begin_src tmate :window trial-implementation
82-
cd ./cmd/trial-implementation
83-
go run .
84-
#+end_src
85-
86-
* Running the plugin locally
87-
88-
When run locally the plugin interacts with GitHub but by default does not make any changes
89-
if you want to apply changes to the PR inspected then you can pass in the flag, dry-run=false
21+
for more, read [[./docs/development.org][the development docs]].
9022

91-
#+BEGIN_SRC shell
92-
./verify-conformance-release --hmac-secret-file=/home/ii/.secret-hook --github-token-path=/home/ii/.secret-oauth --plugin-config=./hack/vcr.yaml
93-
#+END_SRC

docs/building.md

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

docs/development.org

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#+title: Development
2+
3+
#+begin_quote
4+
Set up a local environment for development
5+
#+end_quote
6+
7+
* Notes
8+
9+
- currently pushes to a public container registry
10+
- the bot will log in and make comments are your GitHub user or whatever user the token belongs to
11+
12+
* Environment
13+
14+
install tools
15+
16+
- [[https://podman.io][podman]] or [[https://docker.com][docker]]
17+
- [[https://ko.build][ko]]
18+
- [[https://kind.sigs.k8s.io][kind]]
19+
- [[https://kustomize.io][kustomize]]
20+
- [[https://kubernetes.io/docs/tasks/tools/#kubectl][kubectl]]
21+
- [[https://go.dev][go]]
22+
- [[https://cli.github.com/][gh]]
23+
24+
#+begin_src shell :results silent
25+
brew install podman ko kind kustomize kubectl go gh
26+
#+end_src
27+
28+
log in to GitHub with ~gh~
29+
30+
#+begin_src shell: results silent
31+
gh auth login -s write:packages
32+
#+end_src
33+
34+
log into ghcr.io
35+
36+
#+begin_src shell :results silent
37+
gh auth token | ko login ghcr.io --username "$(gh api user --jq .login)" --password-stdin
38+
#+end_src
39+
40+
create a cluster
41+
42+
#+begin_src shell :results silent
43+
kind create cluster
44+
#+end_src
45+
46+
build image
47+
48+
#+begin_src shell :results silent
49+
export KO_DOCKER_REPO=ghcr.io/cncf-infra/verify-conformance
50+
IMAGE="$(ko build --base-import-paths .)"
51+
#+end_src
52+
(*NOTE*: feel free to swap out registry above)
53+
54+
configure components
55+
56+
#+begin_src shell :results silent
57+
cd ./hack/local-dev/
58+
kustomize edit set image ko://cncf.io/infra/verify-conformance-release="$IMAGE"
59+
#+end_src
60+
(*NOTE*: avoid committing this change)
61+
62+
write secrets (*example*)
63+
64+
#+begin_src shell :results silent
65+
mkdir -p ./tmp/
66+
echo "$(openssl rand -base64 15)" > ./tmp/hmac
67+
gh auth token > ./tmp/token
68+
#+end_src
69+
(*NOTE*: avoid committing these values)
70+
71+
apply
72+
73+
#+begin_src shell :results silent
74+
kustomize build . | kubectl apply -f -
75+
#+end_src
76+
77+
observe resources
78+
79+
#+begin_src shell :results silent
80+
kubectl -n prow get all
81+
#+end_src
82+
83+
teardown
84+
85+
#+begin_src shell :results silent
86+
kind delete cluster
87+
#+end_src
88+
89+
* Tips
90+
91+
read the logs
92+
93+
#+begin_src shell :results silent
94+
kubectl -n prow logs -l app=verify-conformance-release --tail=50 -f
95+
#+end_src
96+
97+
restart it
98+
99+
#+begin_src shell :results silent
100+
kubectl -n prow rollout restart deployment verify-conformance-release
101+
#+end_src
102+
103+
compile test
104+
105+
#+begin_src shell
106+
go build -o bin/ .
107+
#+end_src

hack/local-dev/ghproxy.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
kind: PersistentVolumeClaim
3+
apiVersion: v1
4+
metadata:
5+
namespace: prow
6+
labels:
7+
app: ghproxy
8+
name: ghproxy
9+
spec:
10+
accessModes:
11+
- ReadWriteOnce
12+
resources:
13+
requests:
14+
storage: 100Gi
15+
---
16+
apiVersion: apps/v1
17+
kind: Deployment
18+
metadata:
19+
namespace: prow
20+
name: ghproxy
21+
labels:
22+
app: ghproxy
23+
spec:
24+
selector:
25+
matchLabels:
26+
app: ghproxy
27+
replicas: 1
28+
template:
29+
metadata:
30+
labels:
31+
app: ghproxy
32+
spec:
33+
containers:
34+
- name: ghproxy
35+
image: gcr.io/k8s-prow/ghproxy:v20240515-dd5d0eeaa
36+
args:
37+
- --cache-dir=/cache
38+
- --cache-sizeGB=99
39+
- --push-gateway=pushgateway
40+
- --serve-metrics=true
41+
ports:
42+
- name: main
43+
containerPort: 8888
44+
- name: metrics
45+
containerPort: 9090
46+
volumeMounts:
47+
- name: cache
48+
mountPath: /cache
49+
volumes:
50+
- name: cache
51+
persistentVolumeClaim:
52+
claimName: ghproxy
53+
---
54+
apiVersion: v1
55+
kind: Service
56+
metadata:
57+
labels:
58+
app: ghproxy
59+
namespace: prow
60+
name: ghproxy
61+
spec:
62+
ports:
63+
- name: main
64+
port: 80
65+
protocol: TCP
66+
targetPort: 8888
67+
- name: metrics
68+
port: 9090
69+
selector:
70+
app: ghproxy
71+
type: ClusterIP

hack/local-dev/kustomization.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- ./namespace.yaml
5+
- ../../config/default
6+
- ./ghproxy.yaml
7+
patches:
8+
- path: ./verify-conformance-patch.yaml
9+
namespace: prow
10+
generatorOptions:
11+
disableNameSuffixHash: true
12+
configMapGenerator:
13+
- behavior: replace
14+
files:
15+
- ./vcr.yaml
16+
name: vcr-config
17+
namespace: prow
18+
- files:
19+
- ./plugins.yaml
20+
name: plugins
21+
namespace: prow
22+
secretGenerator:
23+
- files:
24+
- token=./tmp/token
25+
name: github-token
26+
namespace: prow
27+
- files:
28+
- hmac=./tmp/hmac
29+
name: hmac-token
30+
namespace: prow
31+
images:
32+
- digest: sha256:7db60baff20817a23d3c141fb4984ccfd84cda7eabadb81400fabeaae251a05e
33+
name: ko://cncf.io/infra/verify-conformance-release
34+
newName: ghcr.io/cncf-infra/verify-conformance/verify-conformance-release

hack/local-dev/namespace.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: prow

hack/local-dev/plugins.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins:
2+
cncf-infra:
3+
plugins:
4+
- approve
5+
- assign
6+
- blunderbuss
7+
- cat
8+
- dog
9+
- help
10+
- heart
11+
- hold
12+
- label
13+
- lgtm
14+
- trigger
15+
- verify-owners
16+
- wip
17+
- yuks

hack/local-dev/vcr.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
external_plugins:
2+
cncf-infra/k8s-conformance:
3+
- name: verify-conformance-release
4+
events:
5+
- issue_comment
6+
- pull_request
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: verify-conformance-release
6+
namespace: prow
7+
spec:
8+
template:
9+
spec:
10+
containers:
11+
- name: verify-conformance-release
12+
args:
13+
- --github-endpoint=http://ghproxy
14+
- --github-endpoint=https://api.github.com
15+
- --dry-run=false
16+
- --hmac-secret-file=/etc/webhook/hmac
17+
- --plugin-config=/plugin/vcr.yaml
18+
- --update-period=5m
19+
- --github-token-path=/etc/github/token
20+
env:

0 commit comments

Comments
 (0)