Skip to content

Commit

Permalink
fix: allow patch version in go.mod (#1)
Browse files Browse the repository at this point in the history
* fix: allow patch version in go.mod

* test: add test for two old version format
  • Loading branch information
wolf29f authored Sep 12, 2024
1 parent 1dd97e7 commit b759188
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,14 @@ jobs:
modfile: go.mod
- name: Check outputs
run: |
test "${{ steps.selftest.outputs.go_version }}" == "1.20"
test "${{ steps.selftest.outputs.go_version }}" == "1.22.0"
test "${{ steps.selftest.outputs.go_module }}" == "github.com/pawndev/go-modfile-information"
- name: Self test two digits format
id: selftest_two_digits
uses: ./
with:
modfile: tests/two-digits.go.mod
- name: Check outputs
run: |
test "${{ steps.selftest_two_digits.outputs.go_version }}" == "1.21"
test "${{ steps.selftest_two_digits.outputs.go_module }}" == "github.com/pawndev/go-modfile-information"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20 as builder
FROM golang:1.22 as builder

WORKDIR /app
COPY . /app
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ See the [examples](#examples) for how to use it

### Inputs

| Input | Description | Default value |
|-----------------------------|---------------------------------|---------------|
| `modfile` | An example mandatory input | go.mod |
| Input | Description | Default value |
| --------- | -------------------------- | ------------- |
| `modfile` | An example mandatory input | go.mod |

### Outputs

| Output | Description |
|--------------|--------------------------|
| ------------ | ------------------------ |
| `go_version` | Go version of the module |
| `go_module` | Go module name |

Expand Down Expand Up @@ -50,4 +50,6 @@ with:
## Testing locally
Be sure to have [act](https://github.com/nektos/act) locally and available il your `$PATH`.
And then you can `make test` to launch the project locally.
And then you can `make test` to launch the project locally.

Folder `tests` contains another go.mod file with old version format using only major and minor without the patch number `1.21`.
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/pawndev/go-modfile-information

go 1.20
go 1.22.0

toolchain go1.23.0

require (
github.com/sethvargo/go-githubactions v1.1.0
golang.org/x/mod v0.9.0
github.com/sethvargo/go-githubactions v1.3.0
golang.org/x/mod v0.21.0
)

require github.com/sethvargo/go-envconfig v0.8.0 // indirect
11 changes: 4 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/sethvargo/go-envconfig v0.8.0 h1:AcmdAewSFAc7pQ1Ghz+vhZkilUtxX559QlDuLLiSkdI=
github.com/sethvargo/go-envconfig v0.8.0/go.mod h1:Iz1Gy1Sf3T64TQlJSvee81qDhf7YIlt8GMUX6yyNFs0=
github.com/sethvargo/go-githubactions v1.1.0 h1:mg03w+b+/s5SMS298/2G6tHv8P0w0VhUFaqL1THIqzY=
github.com/sethvargo/go-githubactions v1.1.0/go.mod h1:qIboSF7yq2Qnaw2WXDsqCReM0Lo1gU4QXUWmhBC3pxE=
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
github.com/sethvargo/go-githubactions v1.3.0 h1:Kg633LIUV2IrJsqy2MfveiED/Ouo+H2P0itWS0eLh8A=
github.com/sethvargo/go-githubactions v1.3.0/go.mod h1:7/4WeHgYfSz9U5vwuToCK9KPnELVHAhGtRwLREOQV80=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
8 changes: 8 additions & 0 deletions tests/two-digits.go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/pawndev/go-modfile-information

go 1.21

require (
github.com/sethvargo/go-githubactions v1.3.0
golang.org/x/mod v0.21.0
)

0 comments on commit b759188

Please sign in to comment.