Skip to content

Commit

Permalink
Add github label info, generate docs
Browse files Browse the repository at this point in the history
Manual doc generation with verify job to enforce, like k/community/sigs.yaml

- Don't touch existing labels, just adding content
- Add extra fields to labels.yaml
- Modify label_sync to take an --action docs flag
- Use a template to render a labels.md file
- Allow direct linking to labels via anchors
- Add hack/{update,verify}-labels.sh
- Add pull-test-infra-verify-labels job
  • Loading branch information
spiffxp committed Apr 2, 2018
1 parent 84f836d commit 2023f6a
Show file tree
Hide file tree
Showing 12 changed files with 756 additions and 58 deletions.
1 change: 1 addition & 0 deletions hack/update-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ TESTINFRA_ROOT=$(git rev-parse --show-toplevel)
${TESTINFRA_ROOT}/hack/update-bazel.sh
${TESTINFRA_ROOT}/hack/update-gofmt.sh
${TESTINFRA_ROOT}/hack/update-config.sh
${TESTINFRA_ROOT}/hack/update-labels.sh
30 changes: 30 additions & 0 deletions hack/update-labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

TESTINFRA_ROOT=$(git rev-parse --show-toplevel)
LABELS_CONFIG=${LABELS_CONFIG:-"${TESTINFRA_ROOT}/label_sync/labels.yaml"}
LABELS_DOCS_TEMPLATE=${LABELS_DOCS_TEMPLATE:-"${TESTINFRA_ROOT}/label_sync/labels.md.tmpl"}
LABELS_DOCS_OUTPUT=${LABELS_DOCS_OUTPUT:-"${TESTINFRA_ROOT}/label_sync/labels.md"}

bazel run //label_sync -- \
--config=${LABELS_CONFIG} \
--action=docs \
--docs-template=${LABELS_DOCS_TEMPLATE} \
--docs-output=${LABELS_DOCS_OUTPUT}

32 changes: 32 additions & 0 deletions hack/verify-labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

TESTINFRA_ROOT=$(git rev-parse --show-toplevel)

TMP_LABELS_DOCS=$(mktemp)
trap "rm -f $TMP_LABELS_DOCS" EXIT
LABELS_DOCS_OUTPUT="${TMP_LABELS_DOCS}" ${TESTINFRA_ROOT}/hack/update-labels.sh

DIFF=$(diff "${TMP_LABELS_DOCS}" "${TESTINFRA_ROOT}/label_sync/labels.md" || true)
if [ ! -z "$DIFF" ]; then
echo "${DIFF}"
echo ""
echo "labels.yaml was updated without updating labels.md, please run 'hack/update-labels.sh'"
exit 1
fi
9 changes: 9 additions & 0 deletions jobs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12935,6 +12935,15 @@
"sig-testing"
]
},
"pull-test-infra-verify-labels": {
"args": [
"./hack/verify-labels.sh"
],
"scenario": "execute",
"sigOwners": [
"sig-testing"
]
},
"random_job": {
"scenario": "execute",
"sigOwners": [
Expand Down
4 changes: 1 addition & 3 deletions label_sync/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ bazel:
get-cluster-credentials:
gcloud container clusters get-credentials "$(CLUSTER)" --project="$(PROJECT)" --zone="$(ZONE)"

.PHONY: bazel get-cluster-credentials

update-config: get-cluster-credentials
# Oddy the first time requires creating it instead of replacing it...
kubectl create configmap label-config --from-file=labels.yaml=labels.yaml --dry-run -o yaml | kubectl replace configmap label-config -f -
Expand All @@ -44,4 +42,4 @@ label_sync-job: get-cluster-credentials
label_sync-cronjob: get-cluster-credentials
kubectl apply -f cluster/label_sync_cron_job.yaml

.PHONY: label_sync-job label_sync-cronjob bazel
.PHONY: label_sync-job label_sync-cronjob bazel get-cluster-credentials
13 changes: 10 additions & 3 deletions label_sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bazel test //label_sync/...
bazel run //label_sync -- \
--config $(pwd)/labels.yaml \
--token /path/to/github_oauth_token \
--org kubernetes
--orgs kubernetes
# actually you need to pass the --confirm flag too, it will
# run in dry-run mode by default so you avoid doing something
# too hastily, hence why this copy-pasta isn't including it
Expand All @@ -49,17 +49,24 @@ bazel run //label_sync -- \
bazel run //label_sync -- \
--config $(pwd)/labels.yaml \
--token /path/to/github_oauth_token \
--org kubernetes \
--orgs kubernetes \
--skip kubernetes/helm
# see above
# add or migrate labels on the community and steering repos in the kubernetes org
bazel run //label_sync -- \
--config $(pwd)/labels.yaml \
--token /path/to/github_oauth_token \
--org kubernetes \
--orgs kubernetes \
--only kubernetes/community,kubernetes/steering
# see above
# generate docs based on labels.yaml
bazel run //label_sync -- \
--action docs \
--config $(pwd)/labels.yaml \
--docs-template $(pwd)/labels.md.tmpl \
--docs-output $(pwd)/labels.md
```

## Our Deployment
Expand Down
Loading

0 comments on commit 2023f6a

Please sign in to comment.