Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger go vet, gofmt, and goimports during the actions workflow. #10

Merged
merged 7 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,29 @@ jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.21', '1.22']

steps:
- uses: actions/checkout@v4

- name: Set up Go
- name: Set up Go ${{matrix.go-version}}
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: ${{matrix.go-version}}

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

- name: Vet
run: go vet -v ./...

- name: Format
run: '[ ! "$(gofmt -s -l .)" ]'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also use goimports which i think is just called with -l .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.


- name: Imports
run: '[ ! "$(go run golang.org/x/tools/cmd/goimports -l .)" ]'
2 changes: 1 addition & 1 deletion internal/verifier/attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestCreateAttestations(t *testing.T) {
BuildEnd: must(time.Parse(time.RFC3339, "2024-01-01T00:00:00Z")),
BuildImages: map[string]string{"gcr.io/foo/bar": "abcd"},
Steps: []*cloudbuild.BuildStep{
&cloudbuild.BuildStep{
{
Name: "gcr.io/foo/bar",
Script: "./bar",
Status: "SUCCESS",
Expand Down
10 changes: 5 additions & 5 deletions pkg/rebuild/rebuild/rebuildremote.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,23 @@ func makeBuild(t Target, dockerfile, imageUploadPath, rebuildUploadPath string,
Options: &cloudbuild.BuildOptions{Logging: "GCS_ONLY"},
ServiceAccount: opts.BuildServiceAccount,
Steps: []*cloudbuild.BuildStep{
&cloudbuild.BuildStep{
{
Name: "gcr.io/cloud-builders/docker",
Script: "cat <<'EOS' | docker buildx build --tag=img -\n" + dockerfile + "\nEOS",
},
&cloudbuild.BuildStep{
{
Name: "gcr.io/cloud-builders/docker",
Args: []string{"run", "--name=container", "img"},
},
&cloudbuild.BuildStep{
{
Name: "gcr.io/cloud-builders/docker",
Args: []string{"cp", "container:" + path.Join("/out", t.Artifact), path.Join("/workspace", t.Artifact)},
},
&cloudbuild.BuildStep{
{
Name: "gcr.io/cloud-builders/docker",
Script: "docker save img | gzip > /workspace/image.tgz",
},
&cloudbuild.BuildStep{
{
Name: "gcr.io/cloud-builders/gsutil",
Script: fmt.Sprintf(
"gsutil cp -P gs://%s/gsutil_writeonly . && ./gsutil_writeonly %s && ./gsutil_writeonly %s",
Expand Down
14 changes: 7 additions & 7 deletions pkg/rebuild/rebuild/rebuildremote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ func TestDoCloudBuild(t *testing.T) {
Id: "build-id",
Status: "QUEUED",
Steps: []*cloudbuild.BuildStep{
&cloudbuild.BuildStep{Name: "gcr.io/foo/bar", Script: "./bar"},
{Name: "gcr.io/foo/bar", Script: "./bar"},
},
}
afterBuild := &cloudbuild.Build{
Id: "build-id",
Status: "SUCCESS",
FinishTime: "2024-05-08T15:23:00Z",
Steps: []*cloudbuild.BuildStep{
&cloudbuild.BuildStep{Name: "gcr.io/foo/bar", Script: "./bar"},
{Name: "gcr.io/foo/bar", Script: "./bar"},
},
Results: &cloudbuild.Results{BuildStepImages: []string{"sha256:abcd"}},
}
Expand Down Expand Up @@ -241,23 +241,23 @@ func TestMakeBuild(t *testing.T) {
Options: &cloudbuild.BuildOptions{Logging: "GCS_ONLY"},
ServiceAccount: "test-service-account",
Steps: []*cloudbuild.BuildStep{
&cloudbuild.BuildStep{
{
Name: "gcr.io/cloud-builders/docker",
Script: "cat <<'EOS' | docker buildx build --tag=img -\nFROM alpine:3.19\nEOS",
},
&cloudbuild.BuildStep{
{
Name: "gcr.io/cloud-builders/docker",
Args: []string{"run", "--name=container", "img"},
},
&cloudbuild.BuildStep{
{
Name: "gcr.io/cloud-builders/docker",
Args: []string{"cp", "container:/out/pkg-version.tgz", "/workspace/pkg-version.tgz"},
},
&cloudbuild.BuildStep{
{
Name: "gcr.io/cloud-builders/docker",
Script: "docker save img | gzip > /workspace/image.tgz",
},
&cloudbuild.BuildStep{
{
Name: "gcr.io/cloud-builders/gsutil",
Script: ("" +
"gsutil cp -P gs://test-bootstrap/gsutil_writeonly . && " +
Expand Down
4 changes: 2 additions & 2 deletions tools/benchmark/generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ func main() {
}
log.Printf("Generating %s...", b.Filename)
todo <- nil
go func() {
go func(b *RebuildBenchmark) {
ps := b.Generator(ctx)
out, err := json.MarshalIndent(ps, "", " ")
if err != nil {
Expand All @@ -734,7 +734,7 @@ func main() {
log.Fatalf("error writing %s: %v", b.Filename, err)
}
done <- nil
}()
}(&b)
}
close(todo)
for range todo {
Expand Down
Loading