Skip to content

Commit b759188

Browse files
authored
fix: allow patch version in go.mod (#1)
* fix: allow patch version in go.mod * test: add test for two old version format
1 parent 1dd97e7 commit b759188

File tree

6 files changed

+35
-19
lines changed

6 files changed

+35
-19
lines changed

.github/workflows/integration.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@ jobs:
1212
modfile: go.mod
1313
- name: Check outputs
1414
run: |
15-
test "${{ steps.selftest.outputs.go_version }}" == "1.20"
15+
test "${{ steps.selftest.outputs.go_version }}" == "1.22.0"
1616
test "${{ steps.selftest.outputs.go_module }}" == "github.com/pawndev/go-modfile-information"
17+
- name: Self test two digits format
18+
id: selftest_two_digits
19+
uses: ./
20+
with:
21+
modfile: tests/two-digits.go.mod
22+
- name: Check outputs
23+
run: |
24+
test "${{ steps.selftest_two_digits.outputs.go_version }}" == "1.21"
25+
test "${{ steps.selftest_two_digits.outputs.go_module }}" == "github.com/pawndev/go-modfile-information"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.20 as builder
1+
FROM golang:1.22 as builder
22

33
WORKDIR /app
44
COPY . /app

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ See the [examples](#examples) for how to use it
1212

1313
### Inputs
1414

15-
| Input | Description | Default value |
16-
|-----------------------------|---------------------------------|---------------|
17-
| `modfile` | An example mandatory input | go.mod |
15+
| Input | Description | Default value |
16+
| --------- | -------------------------- | ------------- |
17+
| `modfile` | An example mandatory input | go.mod |
1818

1919
### Outputs
2020

2121
| Output | Description |
22-
|--------------|--------------------------|
22+
| ------------ | ------------------------ |
2323
| `go_version` | Go version of the module |
2424
| `go_module` | Go module name |
2525

@@ -50,4 +50,6 @@ with:
5050
## Testing locally
5151
5252
Be sure to have [act](https://github.com/nektos/act) locally and available il your `$PATH`.
53-
And then you can `make test` to launch the project locally.
53+
And then you can `make test` to launch the project locally.
54+
55+
Folder `tests` contains another go.mod file with old version format using only major and minor without the patch number `1.21`.

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module github.com/pawndev/go-modfile-information
22

3-
go 1.20
3+
go 1.22.0
4+
5+
toolchain go1.23.0
46

57
require (
6-
github.com/sethvargo/go-githubactions v1.1.0
7-
golang.org/x/mod v0.9.0
8+
github.com/sethvargo/go-githubactions v1.3.0
9+
golang.org/x/mod v0.21.0
810
)
9-
10-
require github.com/sethvargo/go-envconfig v0.8.0 // indirect

go.sum

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
2-
github.com/sethvargo/go-envconfig v0.8.0 h1:AcmdAewSFAc7pQ1Ghz+vhZkilUtxX559QlDuLLiSkdI=
3-
github.com/sethvargo/go-envconfig v0.8.0/go.mod h1:Iz1Gy1Sf3T64TQlJSvee81qDhf7YIlt8GMUX6yyNFs0=
4-
github.com/sethvargo/go-githubactions v1.1.0 h1:mg03w+b+/s5SMS298/2G6tHv8P0w0VhUFaqL1THIqzY=
5-
github.com/sethvargo/go-githubactions v1.1.0/go.mod h1:qIboSF7yq2Qnaw2WXDsqCReM0Lo1gU4QXUWmhBC3pxE=
6-
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
7-
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
1+
github.com/sethvargo/go-githubactions v1.3.0 h1:Kg633LIUV2IrJsqy2MfveiED/Ouo+H2P0itWS0eLh8A=
2+
github.com/sethvargo/go-githubactions v1.3.0/go.mod h1:7/4WeHgYfSz9U5vwuToCK9KPnELVHAhGtRwLREOQV80=
3+
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
4+
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=

tests/two-digits.go.mod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module github.com/pawndev/go-modfile-information
2+
3+
go 1.21
4+
5+
require (
6+
github.com/sethvargo/go-githubactions v1.3.0
7+
golang.org/x/mod v0.21.0
8+
)

0 commit comments

Comments
 (0)