From afe9a7e3ad9d367efba9202f4e4dd2cf44e3bdc7 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Thu, 27 Jun 2024 14:04:02 +0900 Subject: [PATCH] Refresh CI tooling --- .github/dependabot.yml | 19 ++++++ .github/workflows/ci.yaml | 27 +-------- .github/workflows/release.yaml | 24 +++----- .github/workflows/update-upstream.yaml | 41 ------------- .github/workflows/update.yaml | 15 +++++ .golangci.yml | 43 +++++++++++++ .goreleaser.yaml | 83 +++++++++++++------------- .yamllint.yaml | 4 ++ README.md | 7 ++- build/go.mod | 3 +- build/go.sum | 4 ++ buildtools/wasm/version.txt | 2 +- go-protoc-gen-prost.code-workspace | 32 ++++++++++ go.mod | 2 +- go.sum | 3 +- internal/runner/runner.go | 2 +- testdata/buf.gen.yaml | 24 ++++---- testdata/buf.work.yaml | 2 +- 18 files changed, 193 insertions(+), 144 deletions(-) create mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/update-upstream.yaml create mode 100644 .github/workflows/update.yaml create mode 100644 .golangci.yml create mode 100644 .yamllint.yaml create mode 100644 go-protoc-gen-prost.code-workspace diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5b71152 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: "daily" + groups: + gha: + patterns: + - "*" + + - package-ecosystem: gomod + directory: / + schedule: + interval: daily + groups: + go: + patterns: + - "*" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 198bba9..5b26763 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,28 +10,5 @@ on: jobs: build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: - - macos-13 - - macos-14 - - ubuntu-22.04 - - windows-2022 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-go@v5 - with: - go-version-file: go.work - cache-dependency-path: "**/go.sum" - - - name: run checks - run: go run build check - - - name: build snapshot - if: ${{ startsWith(matrix.os, 'ubuntu-') }} - run: go run build snapshot + uses: wasilibs/actions/.github/workflows/ci.yaml@eeee5d072ee283c12eb68e2c4969012fae3d6dd0 + secrets: inherit diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8808c57..91ca40d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,20 +5,12 @@ on: tags: - v* -jobs: - build: - name: Release - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-go@v5 - with: - go-version-file: go.work - cache-dependency-path: "**/go.sum" +permissions: + id-token: write + attestations: write + contents: write - - run: go run build release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +jobs: + release: + uses: wasilibs/actions/.github/workflows/release.yaml@eeee5d072ee283c12eb68e2c4969012fae3d6dd0 + secrets: inherit diff --git a/.github/workflows/update-upstream.yaml b/.github/workflows/update-upstream.yaml deleted file mode 100644 index 1cac3c5..0000000 --- a/.github/workflows/update-upstream.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: "Update Upstream" - -on: - schedule: - - cron: "5 4 * * *" - workflow_dispatch: - -jobs: - build: - name: Update Upstream - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-go@v5 - with: - go-version-file: go.work - cache-dependency-path: "**/go.sum" - - - run: go run build update - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - run: git diff --exit-code - id: check-diff - continue-on-error: true - - - name: create PR - if: steps.check-diff.outcome == 'failure' - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git checkout -b update-upstream-${{ github.run_id }} - git add . - git commit -m "Update to latest upstream" - git push -u origin -f update-upstream-${{ github.run_id }} - gh pr create --fill --head update-upstream-${{ github.run_id }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update.yaml b/.github/workflows/update.yaml new file mode 100644 index 0000000..6dc6db8 --- /dev/null +++ b/.github/workflows/update.yaml @@ -0,0 +1,15 @@ +name: "Update Upstream" + +on: + schedule: + - cron: "5 4 * * *" + workflow_dispatch: + +permissions: + id-token: write + attestations: write + +jobs: + build: + uses: wasilibs/actions/.github/workflows/update.yaml@eeee5d072ee283c12eb68e2c4969012fae3d6dd0 + secrets: inherit diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..7b89940 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,43 @@ +linters: + enable: + # We opt-in to style linters without the preset since many + # are too strict (e.g., no init functions allowed). + - decorder + - dupword + - gci + - gocritic + - gofumpt + - goprintffuncname + - inamedparam + - mirror + - revive + - stylecheck + - tenv + - unconvert + - usestdlibvars + - wastedassign + presets: + - bugs + - performance + +linters-settings: + gci: + sections: + - standard + - default + - prefix(github.com/wasilibs/go-protoc-gen-builtins) + gosec: + config: + G306: "0644" + +issues: + exclude: + - don't use an underscore in package name + - should not use underscores in package names + exclude-rules: + - path: _test\.go + linters: + - errcheck + - errchkjson + - gosec + - noctx diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b675c8f..f750b6a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,49 +1,50 @@ +project_name: protoc-gen-prost builds: -- main: ./cmd/protoc-gen-prost - id: prost - binary: protoc-gen-prost - env: - - CGO_ENABLED=0 - targets: - - linux_amd64 - - linux_arm64 - - darwin_amd64 - - darwin_arm64 - - windows_amd64 - - windows_arm64 -- main: ./cmd/protoc-gen-prost-crate - id: prost-crate - binary: protoc-gen-prost-crate - env: - - CGO_ENABLED=0 - targets: - - linux_amd64 - - linux_arm64 - - darwin_amd64 - - darwin_arm64 - - windows_amd64 - - windows_arm64 -- main: ./cmd/protoc-gen-prost-serde - id: prost-serde - binary: protoc-gen-prost-serde - env: - - CGO_ENABLED=0 - targets: - - linux_amd64 - - linux_arm64 - - darwin_amd64 - - darwin_arm64 - - windows_amd64 - - windows_arm64 + - main: ./cmd/protoc-gen-prost + id: prost + binary: protoc-gen-prost + env: + - CGO_ENABLED=0 + targets: + - linux_amd64 + - linux_arm64 + - darwin_amd64 + - darwin_arm64 + - windows_amd64 + - windows_arm64 + - main: ./cmd/protoc-gen-prost-crate + id: prost-crate + binary: protoc-gen-prost-crate + env: + - CGO_ENABLED=0 + targets: + - linux_amd64 + - linux_arm64 + - darwin_amd64 + - darwin_arm64 + - windows_amd64 + - windows_arm64 + - main: ./cmd/protoc-gen-prost-serde + id: prost-serde + binary: protoc-gen-prost-serde + env: + - CGO_ENABLED=0 + targets: + - linux_amd64 + - linux_arm64 + - darwin_amd64 + - darwin_arm64 + - windows_amd64 + - windows_arm64 archives: -- format_overrides: - - goos: windows - format: zip + - format_overrides: + - goos: windows + format: zip release: mode: append checksum: - name_template: 'checksums.txt' + name_template: "checksums.txt" snapshot: name_template: "{{ incpatch .Version }}-next" changelog: - skip: true + disable: true diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..68c4b4e --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,4 @@ +rules: + document-start: disable + truthy: + check-keys: false diff --git a/README.md b/README.md index 9703d30..34fde4d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # go-protoc-gen-prost -go-protoc-gen-prost is a distribution of the code generator of [prost][1]. +go-protoc-gen-prost is a distribution of the code generator of [prost][1]. It does not actually reimplement any functionality of prost in Go, instead compiling it to WebAssembly, and executing with the pure Go Wasm runtime [wazero][2]. This means that `go install` or `go run` can be used to execute it, with no need to rely on external @@ -28,7 +28,10 @@ version: v1 plugins: - plugin: prost out: out/rust - path: ["go", "run", "github.com/wasilibs/go-protoc-gen-prost/cmd/protoc-gen-prost@latest"] + path: + - "go" + - "run" + - "github.com/wasilibs/go-protoc-gen-prost/cmd/protoc-gen-prost@latest" ``` This makes it possible to have full protobuf/gRPC generation with no installation of tools, diff --git a/build/go.mod b/build/go.mod index d70b1f7..f7e4309 100644 --- a/build/go.mod +++ b/build/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/goyek/x v0.1.7 - github.com/wasilibs/tools v0.0.0-20240501081123-9453b4e4849b + github.com/wasilibs/tools v0.0.0-20240606073112-95e68538d401 ) require ( @@ -12,6 +12,7 @@ require ( github.com/cli/go-gh/v2 v2.9.0 // indirect github.com/cli/safeexec v1.0.0 // indirect github.com/cli/shurcooL-graphql v0.0.4 // indirect + github.com/curioswitch/go-build v0.0.0-20240606064955-be261ad22091 // indirect github.com/fatih/color v1.16.0 // indirect github.com/google/go-github v17.0.0+incompatible // indirect github.com/google/go-querystring v1.1.0 // indirect diff --git a/build/go.sum b/build/go.sum index 3ea3014..60334fa 100644 --- a/build/go.sum +++ b/build/go.sum @@ -6,6 +6,8 @@ github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI= github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q= github.com/cli/shurcooL-graphql v0.0.4 h1:6MogPnQJLjKkaXPyGqPRXOI2qCsQdqNfUY1QSJu2GuY= github.com/cli/shurcooL-graphql v0.0.4/go.mod h1:3waN4u02FiZivIV+p1y4d0Jo1jc6BViMA73C+sZo2fk= +github.com/curioswitch/go-build v0.0.0-20240606064955-be261ad22091 h1:uQuAhPoaAFpx7eAbKDxZSlfSgTO/nF/Oga07Ks5RZs4= +github.com/curioswitch/go-build v0.0.0-20240606064955-be261ad22091/go.mod h1:1reBtVlh1bRKD/d1OymtuKnXIF1aKn6ncY+dxF9uA7Q= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= @@ -50,6 +52,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/thlib/go-timezone-local v0.0.0-20210907160436-ef149e42d28e h1:BuzhfgfWQbX0dWzYzT1zsORLnHRv3bcRcsaUk0VmXA8= github.com/thlib/go-timezone-local v0.0.0-20210907160436-ef149e42d28e/go.mod h1:/Tnicc6m/lsJE0irFMA0LfIwTBo4QP7A8IfyIv4zZKI= +github.com/wasilibs/tools v0.0.0-20240606073112-95e68538d401 h1:jNgFNGO+i1E6RD+9v99eCIatDv0ZTvZ/aRovsfVgQqY= +github.com/wasilibs/tools v0.0.0-20240606073112-95e68538d401/go.mod h1:756c6OtTEJS3KAetfQ1zDlNv4zTvOFkLPgFoTQmhoUk= golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/buildtools/wasm/version.txt b/buildtools/wasm/version.txt index 232e851..21abcf9 100644 --- a/buildtools/wasm/version.txt +++ b/buildtools/wasm/version.txt @@ -1 +1 @@ -v0.12.6 \ No newline at end of file +v0.12.5 \ No newline at end of file diff --git a/go-protoc-gen-prost.code-workspace b/go-protoc-gen-prost.code-workspace new file mode 100644 index 0000000..e96fbdf --- /dev/null +++ b/go-protoc-gen-prost.code-workspace @@ -0,0 +1,32 @@ +{ + "folders": [ + { + "name": "/", + "path": "." + } + ], + "extensions": { + "recommendations": ["esbenp.prettier-vscode"] + }, + "settings": { + "editor.tabSize": 2, + "[github-actions-workflow]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "go.lintFlags": ["--fix"], + "go.lintOnSave": "package", + "go.lintTool": "golangci-lint", + "gopls": { + "formatting.gofumpt": true + }, + "[markdown]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[yaml]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" + } + } +} diff --git a/go.mod b/go.mod index 663fe37..76214eb 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/wasilibs/go-protoc-gen-prost go 1.22 -require github.com/tetratelabs/wazero v1.7.0 +require github.com/tetratelabs/wazero v1.7.1 diff --git a/go.sum b/go.sum index 5048a45..9cecdd5 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1 @@ -github.com/tetratelabs/wazero v1.7.0 h1:jg5qPydno59wqjpGrHph81lbtHzTrWzwwtD4cD88+hQ= -github.com/tetratelabs/wazero v1.7.0/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= +github.com/tetratelabs/wazero v1.7.1 h1:QtSfd6KLc41DIMpDYlJdoMc6k7QTN246DM2+n2Y/Dx8= diff --git a/internal/runner/runner.go b/internal/runner/runner.go index 63a4651..425c8c1 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -42,7 +42,7 @@ func Run(name string, args []string, wasm []byte, stdin io.Reader, stdout io.Wri _, err := rt.InstantiateWithConfig(ctx, wasm, cfg) if err != nil { - if sErr, ok := err.(*sys.ExitError); ok { + if sErr, ok := err.(*sys.ExitError); ok { //nolint:errorlint return int(sErr.ExitCode()) } log.Fatal(err) diff --git a/testdata/buf.gen.yaml b/testdata/buf.gen.yaml index 0e77148..e6b25c4 100644 --- a/testdata/buf.gen.yaml +++ b/testdata/buf.gen.yaml @@ -1,14 +1,14 @@ version: v1 plugins: -- plugin: prost - out: ../out/buf/rust - path: ["go", "run", "../cmd/protoc-gen-prost"] -- plugin: prost-crate - strategy: all - opt: - - no_features - out: ../out/buf/rust - path: ["go", "run", "../cmd/protoc-gen-prost-crate"] -- plugin: prost-serde - out: ../out/buf/rust - path: ["go", "run", "../cmd/protoc-gen-prost-serde"] + - plugin: prost + out: ../out/buf/rust + path: ["go", "run", "../cmd/protoc-gen-prost"] + - plugin: prost-crate + strategy: all + opt: + - no_features + out: ../out/buf/rust + path: ["go", "run", "../cmd/protoc-gen-prost-crate"] + - plugin: prost-serde + out: ../out/buf/rust + path: ["go", "run", "../cmd/protoc-gen-prost-serde"] diff --git a/testdata/buf.work.yaml b/testdata/buf.work.yaml index 79891ee..4bddfe6 100644 --- a/testdata/buf.work.yaml +++ b/testdata/buf.work.yaml @@ -1,3 +1,3 @@ version: v1 directories: -- protos + - protos