From 599e7c49e9e06e354a77960d827f5065e810fa03 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Tue, 15 Jun 2021 10:17:46 -0700 Subject: [PATCH 1/4] create automated time-to-k8s benchmarks on release --- .github/workflows/time-to-k8s.yml | 20 +++++++++ .gitmodules | 4 +- .../{time-to-k8s => time-to-k8s-repo} | 0 hack/benchmark/time-to-k8s/time-to-k8s.sh | 43 +++++++++++++++---- 4 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/time-to-k8s.yml rename hack/benchmark/time-to-k8s/{time-to-k8s => time-to-k8s-repo} (100%) diff --git a/.github/workflows/time-to-k8s.yml b/.github/workflows/time-to-k8s.yml new file mode 100644 index 0000000000..d3f82b23d4 --- /dev/null +++ b/.github/workflows/time-to-k8s.yml @@ -0,0 +1,20 @@ +name: "time-to-k8s benchmark" +on: + pull_request: + types: [opened] + # release: + # types: [released] +jobs: + benchmark: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Checkout submodules + run: git submodule update --init + - uses: actions/setup-go@v2 + with: + go-version: 1.16.5 + stable: true + - name: Benchmark + run: | + ./hack/benchmark/time-to-k8s/time-to-k8s.sh ${{ secrets.MINIKUBE_BOT_PAT }} diff --git a/.gitmodules b/.gitmodules index 0e99693233..d398a94cf9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "site/themes/docsy"] path = site/themes/docsy url = https://github.com/google/docsy.git -[submodule "hack/benchmark/time-to-k8s/time-to-k8s"] - path = hack/benchmark/time-to-k8s/time-to-k8s +[submodule "hack/benchmark/time-to-k8s/time-to-k8s-repo"] + path = hack/benchmark/time-to-k8s/time-to-k8s-repo url = https://github.com/tstromberg/time-to-k8s.git diff --git a/hack/benchmark/time-to-k8s/time-to-k8s b/hack/benchmark/time-to-k8s/time-to-k8s-repo similarity index 100% rename from hack/benchmark/time-to-k8s/time-to-k8s rename to hack/benchmark/time-to-k8s/time-to-k8s-repo diff --git a/hack/benchmark/time-to-k8s/time-to-k8s.sh b/hack/benchmark/time-to-k8s/time-to-k8s.sh index d999a6afc8..f0ea5aaf85 100755 --- a/hack/benchmark/time-to-k8s/time-to-k8s.sh +++ b/hack/benchmark/time-to-k8s/time-to-k8s.sh @@ -17,7 +17,7 @@ set -e install_kind() { - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.0/kind-linux-amd64 + curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.0/kind-linux-amd64 chmod +x ./kind sudo mv ./kind /usr/local } @@ -31,31 +31,58 @@ install_minikube() { sudo install ./out/minikube /usr/local/bin/minikube } +install_gh() { + export access_token="$1" + + # Make sure gh is installed and configured + ./hack/jenkins/installers/check_install_gh.sh +} + +config_git() { + git config user.name "minikube-bot" + git config user.email "minikube-bot@google.com" +} + +create_branch() { + git checkout -b addTimeToK8s"$1" +} + run_benchmark() { - ( cd ./hack/benchmark/time-to-k8s/time-to-k8s/ && + pwd + ( cd ./hack/benchmark/time-to-k8s/time-to-k8s-repo/ && git submodule update --init && - go run . --config local-kubernetes.yaml --iterations 5 --output output.csv ) + go run . --config local-kubernetes.yaml --iterations 1 --output output.csv ) } generate_chart() { - go run ./hack/benchmark/time-to-k8s/chart.go --csv ./hack/benchmark/time-to-k8s/time-to-k8s/output.csv --output ./site/static/images/benchmarks/timeToK8s/"$1".png + go run ./hack/benchmark/time-to-k8s/chart.go --csv ./hack/benchmark/time-to-k8s/time-to-k8s-repo/output.csv --output ./site/static/images/benchmarks/timeToK8s/"$1".png } create_page() { printf -- "---\ntitle: \"%s Benchmark\"\nlinkTitle: \"%s Benchmark\"\nweight: 1\n---\n\n![time-to-k8s](/images/benchmarks/timeToK8s/%s.png)\n" "$1" "$1" "$1" > ./site/content/en/docs/benchmarks/timeToK8s/"$1".md } -commit_chart() { +commit_changes() { git add ./site/static/images/benchmarks/timeToK8s/"$1".png ./site/content/en/docs/benchmarks/timeToK8s/"$1".md - git commit -m 'update time-to-k8s chart' + git commit -m "add time-to-k8s benchmark for $1" +} + +create_pr() { + git remote add minikube-bot https://minikube-bot:"$2"@github.com/minikube-bot/minikube.git + git push -u minikube-bot addTimeToK8s"$1" + gh pr create --repo kubernetes/minikube --base master --title "Add time-to-k8s benchmark for $1" --body "Updating time-to-k8s benchmark as part of the release process" } install_kind install_k3d install_minikube -VERSION=$(minikube version --short) +install_gh "$1" +config_git +VERSION=$(minikube version --short) +create_branch "$VERSION" run_benchmark generate_chart "$VERSION" create_page "$VERSION" -commit_chart "$VERSION" +commit_changes "$VERSION" +create_pr "$VERSION" "$1" From 262e6c2072a4b2e3b2c158c03210029729a87969 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Tue, 15 Jun 2021 10:23:03 -0700 Subject: [PATCH 2/4] uncomment run on release --- .github/workflows/time-to-k8s.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/time-to-k8s.yml b/.github/workflows/time-to-k8s.yml index d3f82b23d4..991f8b73a0 100644 --- a/.github/workflows/time-to-k8s.yml +++ b/.github/workflows/time-to-k8s.yml @@ -1,9 +1,7 @@ name: "time-to-k8s benchmark" on: - pull_request: - types: [opened] - # release: - # types: [released] + release: + types: [released] jobs: benchmark: runs-on: ubuntu-18.04 From 4480bda5a040fb33b0e2c1d0c20d7f40052df8c0 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Tue, 15 Jun 2021 10:27:02 -0700 Subject: [PATCH 3/4] fixed yaml formatting --- .github/workflows/time-to-k8s.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/time-to-k8s.yml b/.github/workflows/time-to-k8s.yml index 991f8b73a0..0b4103ac71 100644 --- a/.github/workflows/time-to-k8s.yml +++ b/.github/workflows/time-to-k8s.yml @@ -1,7 +1,7 @@ name: "time-to-k8s benchmark" on: - release: - types: [released] + release: + types: [released] jobs: benchmark: runs-on: ubuntu-18.04 From 25c5bec652876db534cd186a5c4c7b7f70f8b50c Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Tue, 15 Jun 2021 10:30:08 -0700 Subject: [PATCH 4/4] change back iterations to 5 --- hack/benchmark/time-to-k8s/time-to-k8s.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/benchmark/time-to-k8s/time-to-k8s.sh b/hack/benchmark/time-to-k8s/time-to-k8s.sh index f0ea5aaf85..a16beea807 100755 --- a/hack/benchmark/time-to-k8s/time-to-k8s.sh +++ b/hack/benchmark/time-to-k8s/time-to-k8s.sh @@ -51,7 +51,7 @@ run_benchmark() { pwd ( cd ./hack/benchmark/time-to-k8s/time-to-k8s-repo/ && git submodule update --init && - go run . --config local-kubernetes.yaml --iterations 1 --output output.csv ) + go run . --config local-kubernetes.yaml --iterations 5 --output output.csv ) } generate_chart() {