Skip to content

Commit 76fa980

Browse files
feat: metrics generation workflow (#1481)
* Scripts to check new Go version Signed-off-by: Sachin Sahu <[email protected]> * Changes to test workflow Signed-off-by: Sachin Sahu <[email protected]> * Update workflow to run based on Go release cycle Signed-off-by: Sachin Sahu <[email protected]> * Revert deleted files for testing workflow Signed-off-by: Sachin Sahu <[email protected]> * Revert deleted file for testing workflow Signed-off-by: Sachin Sahu <[email protected]> * Fix linting issue Signed-off-by: Sachin Sahu <[email protected]> * Update cron schedule to per month Signed-off-by: Sachin Sahu <[email protected]> * Update bash file Signed-off-by: Sachin Sahu <[email protected]> * Keep latest 3 Go versions in supported_go_versions Signed-off-by: Sachin Sahu <[email protected]> --------- Signed-off-by: Sachin Sahu <[email protected]> Signed-off-by: Sachin Sahu <[email protected]>
1 parent e3bea8a commit 76fa980

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Generate Metric files for new Go version
3+
4+
on:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: '0 0 1 * *'
8+
9+
jobs:
10+
update-go-versions:
11+
name: Update Go Versions and Generate Tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Execute bash script
19+
run: bash update-go-version.bash
20+
21+
# If there are no changes (i.e. no diff exists with the checked-out base branch),
22+
# no pull request will be created and the action exits silently.
23+
- name: Create a Pull Request
24+
if: github.event_name != 'pull_request'
25+
uses: peter-evans/create-pull-request@v6
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
commit-message: "Update Go Collector metrics for new Go version"
29+
title: "chore: Update metrics for new Go version"
30+
branch: update-metrics-for-new-go-version
31+
base: main
32+
draft: false
33+
delete-branch: true

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ test-short: deps common-test-short
2222

2323
.PHONY: generate-go-collector-test-files
2424
file := supported_go_versions.txt
25-
# take top 3 versions
26-
VERSIONS := $(shell cat ${file} | head -n 3)
25+
VERSIONS := $(shell cat ${file})
2726
generate-go-collector-test-files:
2827
for GO_VERSION in $(VERSIONS); do \
2928
docker run \

update-go-version.bash

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/env bash
2+
3+
set -e
4+
5+
get_latest_versions() {
6+
curl -s https://go.dev/VERSION?m=text | sed -E -n 's/go([0-9]+\.[0-9]+|\.[0-9]+).*/\1/p'
7+
}
8+
9+
current_version=$(cat supported_go_versions.txt | head -n 1)
10+
latest_version=$(get_latest_versions)
11+
12+
# Check for new version of Go, and generate go collector test files
13+
# Add new Go version to supported_go_versions.txt, and remove the oldest version
14+
if [[ ! $current_version =~ $latest_version ]]; then
15+
echo "New Go version available: $latest_version"
16+
echo "Updating supported_go_versions.txt and generating Go Collector test files"
17+
sed -i "1i $latest_version" supported_go_versions.txt
18+
sed -i '$d' supported_go_versions.txt
19+
make generate-go-collector-test-files
20+
else
21+
echo "No new Go version detected. Current Go version is: $current_version"
22+
fi
23+

0 commit comments

Comments
 (0)