Skip to content

Commit 16281ca

Browse files
committed
set go from the dockerfile and apply best practices
Signed-off-by: Carlos Panato <[email protected]>
1 parent ac1e74a commit 16281ca

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

.github/workflows/go-test.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,33 @@ name: Go Tests (sourcetool)
55

66
on:
77
pull_request:
8+
branches:
9+
- main
10+
11+
permissions: {}
812

913
jobs:
1014
test:
15+
runs-on: ubuntu-latest
16+
1117
permissions:
1218
contents: read
13-
runs-on: ubuntu-latest
19+
1420
steps:
1521
- name: Checkout code
1622
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1723
with:
1824
persist-credentials: false
1925

26+
- name: Extract version of Go to use
27+
run: echo "GOVERSION=$(awk -F'[:@]' '/FROM golang/{print $2; exit}' Dockerfile)" >> $GITHUB_ENV
28+
2029
- name: Set up Go
2130
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
2231
with:
23-
go-version-file: go.mod
32+
go-version: ${{ env.GOVERSION }}
2433
check-latest: true
34+
cache: false
2535

2636
- name: Setup Buf
2737
uses: bufbuild/buf-setup-action@a47c93e0b1648d5651a065437926377d060baa99 # v1.50.0
@@ -31,7 +41,7 @@ jobs:
3141

3242
- name: Run Go tests
3343
run: |
34-
go test ./...
44+
go test -v ./...
3545
3646
- name: Check generated fakes
3747
run: |

.github/workflows/golangci-lint.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,28 @@ on:
99
branches:
1010
- main
1111

12-
permissions:
13-
contents: read
12+
permissions: {}
1413

1514
jobs:
1615
golangci:
1716
name: lint
1817
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: read
21+
1922
steps:
2023
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2124
with:
2225
persist-credentials: false
2326

27+
- name: Extract version of Go to use
28+
run: echo "GOVERSION=$(awk -F'[:@]' '/FROM golang/{print $2; exit}' Dockerfile)" >> $GITHUB_ENV
29+
2430
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
2531
with:
26-
go-version-file: go.mod
32+
go-version: ${{ env.GOVERSION }}
33+
check-latest: true
2734
cache: false
2835

2936
- run: |
@@ -32,5 +39,4 @@ jobs:
3239
- name: Run golangci-lint
3340
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
3441
with:
35-
version: v2.1
36-
42+
version: v2.4

.github/workflows/release.yaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ on:
77
push:
88
tags:
99
- 'v*'
10-
permissions:
11-
contents: read
12-
10+
11+
permissions: {}
12+
1313
jobs:
1414
release:
1515
runs-on: ubuntu-latest
@@ -18,9 +18,9 @@ jobs:
1818
id-token: write # To sign attestations
1919
attestations: write # To push build provenance to attestations store
2020
contents: write # To create the release
21-
21+
2222
steps:
23-
23+
2424
- name: Setup bnd
2525
uses: carabiner-dev/actions/install/bnd@HEAD
2626

@@ -30,9 +30,13 @@ jobs:
3030
persist-credentials: false
3131
fetch-depth: 1
3232

33+
- name: Extract version of Go to use
34+
run: echo "GOVERSION=$(awk -F'[:@]' '/FROM golang/{print $2; exit}' Dockerfile)" >> $GITHUB_ENV
35+
3336
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
3437
with:
35-
go-version-file: go.mod
38+
go-version: ${{ env.GOVERSION }}
39+
check-latest: true
3640
cache: false
3741

3842
- name: Install tejolote
@@ -43,7 +47,7 @@ jobs:
4347
- name: Set tag output
4448
id: tag
4549
run: echo "tag_name=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT"
46-
50+
4751
- name: Run GoReleaser
4852
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
4953
id: goreleaser
@@ -67,5 +71,4 @@ jobs:
6771
bnd pack attestations/ > sourcetool.intoto.jsonl
6872
gh release upload ${{ steps.tag.outputs.tag_name }} sourcetool.intoto.jsonl
6973
# Remove this once GitHub like the tejolote build predicate
70-
# bnd push github ${{github.repository}} attestations/sourcetool-${{ steps.tag.outputs.tag_name }}.provenance.json
71-
74+
# bnd push github ${{github.repository}} attestations/sourcetool-${{ steps.tag.outputs.tag_name }}.provenance.json

0 commit comments

Comments
 (0)