Skip to content

Commit 644602b

Browse files
authored
Script to test all versions of go (#1000)
1 parent 36df8ee commit 644602b

File tree

4 files changed

+675
-0
lines changed

4 files changed

+675
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Go Versions Compatibility Test
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
go_versions:
7+
description: 'Go versions to test (space-separated, e.g., "1.21 1.22 1.23")'
8+
required: false
9+
default: ''
10+
type: string
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Run Go versions compatibility test
26+
run: |
27+
VERSIONS="${{ github.event.inputs.go_versions }}"
28+
./test-go-versions.sh --output ./test-results $VERSIONS
29+
30+
- name: Upload test results
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: go-versions-test-results
34+
path: |
35+
test-results/
36+
retention-days: 30

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ cmd/tomljson/tomljson
55
cmd/tomltestgen/tomltestgen
66
dist
77
tests/
8+
test-results

CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,48 @@ However, given GitHub's new policy to _not_ run Actions on pull requests until a
9292
maintainer clicks on button, it is highly recommended that you run them locally
9393
as you make changes.
9494

95+
### Test across Go versions
96+
97+
The repository includes tooling to test go-toml across multiple Go versions
98+
(1.11 through 1.25) both locally and in GitHub Actions.
99+
100+
#### Local testing with Docker
101+
102+
Prerequisites: Docker installed and running, Bash shell, `rsync` command.
103+
104+
```bash
105+
# Test all Go versions in parallel (default)
106+
./test-go-versions.sh
107+
108+
# Test specific versions
109+
./test-go-versions.sh 1.21 1.22 1.23
110+
111+
# Test sequentially (slower but uses less resources)
112+
./test-go-versions.sh --sequential
113+
114+
# Verbose output with custom results directory
115+
./test-go-versions.sh --verbose --output ./my-results 1.24 1.25
116+
117+
# Show all options
118+
./test-go-versions.sh --help
119+
```
120+
121+
The script creates Docker containers for each Go version and runs the full test
122+
suite. Results are saved to a `test-results/` directory with individual logs and
123+
a comprehensive summary report.
124+
125+
The script only exits with a non-zero status code if either of the two most
126+
recent Go versions fail.
127+
128+
#### GitHub Actions testing (maintainers)
129+
130+
1. Go to the **Actions** tab in the GitHub repository
131+
2. Select **"Go Versions Compatibility Test"** from the workflow list
132+
3. Click **"Run workflow"**
133+
4. Optionally customize:
134+
- **Go versions**: Space-separated list (e.g., `1.21 1.22 1.23`)
135+
- **Execution mode**: Parallel (faster) or sequential (more stable)
136+
95137
### Check coverage
96138

97139
We use `go tool cover` to compute test coverage. Most code editors have a way to

0 commit comments

Comments
 (0)