Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5d937cd

Browse files
authored
chore(ci): Use stable names for CI steps (#1914)
Signed-off-by: Kemal Akkoyun <kemal.akkoyun@datadoghq.com>
1 parentc316de0 commit5d937cd

File tree

6 files changed

+55
-25
lines changed

6 files changed

+55
-25
lines changed

‎.github/workflows/update-go-versions.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
-name:Checkout repository
1616
uses:actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8# v5.0.0
1717

18-
-name:Execute bash script
19-
run:bash update-go-version.bash
18+
-name:Update Go version
19+
run:make update-go-version
2020

2121
# If there are no changes (i.e. no diff exists with the checked-out base branch),
2222
# no pull request will be created and the action exits silently.

‎.github/workflows/validate.yml‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,27 @@ jobs:
2222
name:Fetch supported Go versions
2323
runs-on:ubuntu-latest
2424
outputs:
25-
supported_versions:${{ steps.matrix.outputs.supported_versions }}
25+
matrix:${{ steps.versions.outputs.matrix }}
2626
steps:
2727
-name:Checkout code
2828
uses:actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8# v5.0.0
29-
-name:Read supported_go_versions.txt
30-
id:matrix
29+
-name:Get supported Go versions JSON
30+
id:versions
3131
run:|
32-
versions=$(cat supported_go_versions.txt)
33-
matrix="[$(echo "$versions" | sed 's/\(.*\)/"\1"/' | paste -s -d,)]"
34-
echo "supported_versions=$matrix" >> $GITHUB_OUTPUT
32+
echo "matrix=$(cat supported_go_versions.json | jq -c .)" >> "$GITHUB_OUTPUT"
3533
3634
test:
37-
name:Tests (${{ matrix.go_version }})
35+
name:Tests (${{ matrix.label }})
3836
runs-on:ubuntu-latest
3937
needs:supported_versions
4038
# Set fail-fast to false to ensure all Go versions are tested regardless of failures
4139
strategy:
4240
fail-fast:false
4341
matrix:
44-
go_version:${{ fromJSON(needs.supported_versions.outputs.supported_versions) }}
42+
include:${{ fromJSON(needs.supported_versions.outputs.matrix).versions }}
4543
# Define concurrency at the job level for matrix jobs
4644
concurrency:
47-
group:${{ github.workflow }}-test-${{ matrix.go_version }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
45+
group:${{ github.workflow }}-test-${{ matrix.label }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
4846
cancel-in-progress:true
4947

5048
steps:
@@ -54,10 +52,10 @@ jobs:
5452
-name:Check for CRLF line endings
5553
run:make check-crlf
5654

57-
-name:Set up Go ${{ matrix.go_version }}
55+
-name:Set up Go ${{ matrix.version }}
5856
uses:actions/setup-go@v6.0.0
5957
with:
60-
go-version:${{ matrix.go_version }}
58+
go-version:${{ matrix.version }}
6159
check-latest:true
6260
cache-dependency-path:go.sum
6361

@@ -67,5 +65,4 @@ jobs:
6765
CI:true
6866

6967
-name:Run style and unused
70-
if:${{ matrix.go_version == '1.22' }}
7168
run:make style unused

‎Makefile‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ test: deps common-test test-exp
3030
.PHONY: test-short
3131
test-short: deps common-test-short test-exp-short
3232

33+
.PHONY: update-go-version
34+
update-go-version:
35+
@bash update-go-version.bash
36+
$(MAKE) generate-go-collector-test-files
37+
3338
.PHONY: generate-go-collector-test-files
34-
file := supported_go_versions.txt
35-
VERSIONS :=$(shellcat ${file})
39+
file := supported_go_versions.json
40+
VERSIONS :=$(shellgrep -o '"version": "[^"]*"'$(file) | sed 's/"version": "\(.*\)"/\1/')
3641
generate-go-collector-test-files:
3742
forGO_VERSIONin$(VERSIONS);do \
3843
docker run\

‎supported_go_versions.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"versions": [
3+
{
4+
"label":"stable",
5+
"version":"1.25"
6+
},
7+
{
8+
"label":"oldstable",
9+
"version":"1.24"
10+
}
11+
]
12+
}

‎supported_go_versions.txt‎

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

‎update-go-version.bash‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,36 @@ get_latest_versions() {
66
curl -s https://go.dev/VERSION?m=text| sed -E -n's/go([0-9]+\.[0-9]+|\.[0-9]+).*/\1/p'
77
}
88

9-
current_version=$(cat supported_go_versions.txt| head -n 1)
9+
# Extract the current stable version from JSON
10+
current_version=$(grep -A 1'"label": "stable"' supported_go_versions.json| grep'"version"'| sed's/.*"version": "\([^"]*\)".*/\1/')
1011
latest_version=$(get_latest_versions)
1112

1213
# Check for new version of Go, and generate go collector test files
13-
#Add new Go version tosupported_go_versions.txt, and remove the oldest version
14+
#Update supported_go_versions.json: shift stable tooldstable, add new version as stable
1415
if [[!$current_version=~$latest_version ]];then
1516
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
17+
echo"Updating supported_go_versions.json and generating Go Collector test files"
18+
19+
# Get the current stable version (which will become oldstable)
20+
current_stable_version=$(grep -A 1'"label": "stable"' supported_go_versions.json| grep'"version"'| sed's/.*"version": "\([^"]*\)".*/\1/')
21+
22+
# Create new JSON structure with new version as stable, current stable as oldstable
23+
cat> supported_go_versions.json<<EOF
24+
{
25+
"versions": [
26+
{
27+
"label": "stable",
28+
"version": "$latest_version",
29+
"name": "Tests (stable)"
30+
},
31+
{
32+
"label": "oldstable",
33+
"version": "$current_stable_version",
34+
"name": "Tests (oldstable)"
35+
}
36+
]
37+
}
38+
EOF
2039
else
2140
echo"No new Go version detected. Current Go version is:$current_version"
2241
fi
23-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp