From d6e3033651a7a8cc2d5a282c3c978b2e99487b34 Mon Sep 17 00:00:00 2001 From: joe miller Date: Fri, 16 Aug 2024 21:59:34 +0000 Subject: [PATCH 1/4] update tmp filename --- hooks/post-command | 2 +- hooks/pre-command | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/post-command b/hooks/post-command index c6284f5..c59371b 100755 --- a/hooks/post-command +++ b/hooks/post-command @@ -7,4 +7,4 @@ set -eou pipefail docker stop -t1 dstat echo "+++ Telemetry +++" -cat /tmp/dstat-experiment.txt +cat /tmp/telemetry.txt diff --git a/hooks/pre-command b/hooks/pre-command index 0550b04..f7c647c 100755 --- a/hooks/pre-command +++ b/hooks/pre-command @@ -16,6 +16,6 @@ docker run \ -v /tmp:/tmp \ --entrypoint="/bin/bash" \ ghcr.io/planetscale/telemetry-buildkite-plugin:latest \ - -c "dstat -t -c -m -n --disk-tps --disk --color --noupdate 10 > /tmp/dstat-experiment.txt" + -c "dstat -t -c -m -n --disk-tps --disk --color --noupdate 10 > /tmp/telemetry.txt" docker ps -a From fa127eb65a56d4f29cb3f539bcb1a116886920b9 Mon Sep 17 00:00:00 2001 From: joe miller Date: Fri, 16 Aug 2024 23:11:41 +0000 Subject: [PATCH 2/4] ci(gha): initial release workflow --- .github/release.yaml | 11 +++++++ .github/workflows/release.yaml | 60 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 .github/release.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/release.yaml b/.github/release.yaml new file mode 100644 index 0000000..402d3cd --- /dev/null +++ b/.github/release.yaml @@ -0,0 +1,11 @@ +changelog: + categories: + - title: 🏕 Changes + labels: + - "*" + exclude: + labels: + - dependencies + - title: 👒 Dependencies + labels: + - dependencies diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..7e19129 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,60 @@ +name: Update README.md and create release +on: + push: + branches: + - main + paths-ignore: + - README.md + - .buildkite/** + - .github/** + - docker-compose.yml + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: login to ghcr.io + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + with: + fetch-depth: 0 + + - name: Update README.md + run: | + curl -sL https://git.io/autotag-install | sh -s -- -b "${RUNNER_TEMP}/bin" + set -x + version=$(${RUNNER_TEMP}/bin/autotag -n) + sed -i'' -Ee "s/telemetry#v(.*):/telemetry#v${version}:/" README.md + + - name: Commit README.md + uses: planetscale/ghcommit-action@c7915d6c18d5ce4eb42b0eff3f10a29fe0766e4c # v0.1.44 + with: + commit_message: "🤖 Update README.md" + repo: ${{ github.repository }} + branch: ${{ github.head_ref || github.ref_name }} + file_pattern: README.md + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Release + run: | + set -eou pipefail + set -x + + git reset --hard && git clean -ffdx && git pull + version=$(${RUNNER_TEMP}/bin/autotag -n) + gh release create "v${version}" --target main --title "v${version}" --generate-notes + + docker build -t ghcr.io/planetscale/telemetry:v${version} . + docker push ghcr.io/planetscale/telemetry:v${version} + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 7802d49e75b5a2871f179d71c7103145cf183687 Mon Sep 17 00:00:00 2001 From: joe miller Date: Fri, 16 Aug 2024 23:11:52 +0000 Subject: [PATCH 3/4] proper tmpdir --- Dockerfile | 2 +- README.md | 2 +- hooks/post-command | 6 ++++-- hooks/pre-command | 5 ++--- plugin.yml | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 86f55c6..065ccd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,4 @@ RUN apt-get -qy update && apt-get install -qy \ RUN cd /var/lib/pcp/pmns && ./Rebuild -ENTRYPOINT ["/usr/bin/dstat"] +ENTRYPOINT ["/bin/sh", "-c"] diff --git a/README.md b/README.md index 6b8df9e..c6266d5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Buildkite Job Telemetry Collector +# Buildkite Job Telemetry Reporter TODO diff --git a/hooks/post-command b/hooks/post-command index c59371b..e39b467 100755 --- a/hooks/post-command +++ b/hooks/post-command @@ -6,5 +6,7 @@ set -eou pipefail # TODO: proper tempdir scoped to this invocation docker stop -t1 dstat -echo "+++ Telemetry +++" -cat /tmp/telemetry.txt +echo "+++ :bar_chart: Telemetry:" +cat "$BUILDKITE_TELEMETRY_PLUGIN_OUTFILE" + +rm -rf -- "$BUILDKITE_TELEMETRY_PLUGIN_TMPDIR" diff --git a/hooks/pre-command b/hooks/pre-command index f7c647c..de5a7c9 100755 --- a/hooks/pre-command +++ b/hooks/pre-command @@ -13,9 +13,8 @@ docker run \ --pid host \ --net host \ --userns host \ - -v /tmp:/tmp \ - --entrypoint="/bin/bash" \ + -v "$BUILDKITE_TELEMETRY_PLUGIN_TMPDIR:$BUILDKITE_TELEMETRY_PLUGIN_TMPDIR" \ ghcr.io/planetscale/telemetry-buildkite-plugin:latest \ - -c "dstat -t -c -m -n --disk-tps --disk --color --noupdate 10 > /tmp/telemetry.txt" + "dstat -t -c -m -n --disk-tps --disk --color --noupdate 10 > $BUILDKITE_TELEMETRY_PLUGIN_OUTFILE" docker ps -a diff --git a/plugin.yml b/plugin.yml index e8700f4..7028324 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,4 +1,4 @@ -name: Buildkite job telemetry collector +name: Buildkite Job Telemetry Reporter description: Collect telemetry data from Buildkite jobs and display results at the end of the build. author: https://github.com/planetscale requirements: From a68b19b4b2a494e93afa613689ea3279f1a9a4a2 Mon Sep 17 00:00:00 2001 From: joe miller Date: Fri, 16 Aug 2024 23:13:59 +0000 Subject: [PATCH 4/4] ci(gha): remove setup-go from licensing workflow --- .github/workflows/licensing.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/licensing.yaml b/.github/workflows/licensing.yaml index 5cba507..9f7a077 100644 --- a/.github/workflows/licensing.yaml +++ b/.github/workflows/licensing.yaml @@ -18,9 +18,5 @@ jobs: with: fetch-depth: 0 - - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 - with: - go-version-file: go.mod - - run: sudo gem install license_finder - run: license_finder