diff --git a/.trunk/configs/.isort.cfg b/.trunk/configs/.isort.cfg new file mode 100644 index 000000000..b9fb3f3e8 --- /dev/null +++ b/.trunk/configs/.isort.cfg @@ -0,0 +1,2 @@ +[settings] +profile=black diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml new file mode 100644 index 000000000..b40ee9d7a --- /dev/null +++ b/.trunk/configs/.markdownlint.yaml @@ -0,0 +1,2 @@ +# Prettier friendly markdownlint config (all formatting rules disabled) +extends: markdownlint/style/prettier diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc new file mode 100644 index 000000000..8c7b1ada8 --- /dev/null +++ b/.trunk/configs/.shellcheckrc @@ -0,0 +1,7 @@ +enable=all +source-path=SCRIPTDIR +disable=SC2154 + +# If you're having issues with shellcheck following source, disable the errors via: +# disable=SC1090 +# disable=SC1091 diff --git a/.trunk/configs/.yamllint.yaml b/.trunk/configs/.yamllint.yaml new file mode 100644 index 000000000..184e251f8 --- /dev/null +++ b/.trunk/configs/.yamllint.yaml @@ -0,0 +1,7 @@ +rules: + quoted-strings: + required: only-when-needed + extra-allowed: ["{|}"] + key-duplicates: {} + octal-values: + forbid-implicit-octal: true diff --git a/.trunk/configs/ruff.toml b/.trunk/configs/ruff.toml new file mode 100644 index 000000000..f5a235cf9 --- /dev/null +++ b/.trunk/configs/ruff.toml @@ -0,0 +1,5 @@ +# Generic, formatter-friendly config. +select = ["B", "D3", "E", "F"] + +# Never enforce `E501` (line length violations). This should be handled by formatters. +ignore = ["E501"] diff --git a/linters/buf/plugin.yaml b/linters/buf/plugin.yaml index 813a3d97b..2fab8a6f3 100644 --- a/linters/buf/plugin.yaml +++ b/linters/buf/plugin.yaml @@ -1,36 +1,9 @@ version: 0.1 lint: - # TODO(Tyler): This should be its own tool if we can avoid the eponymous pitfall - downloads: - - name: buf - version: 1.0.0-rc11 - executable: true - downloads: - # macos arm64 was introduced after this version. - - os: macos - version: <0.42.0 - url: https://github.com/bufbuild/buf/releases/download/v${version}/buf-Darwin-x86_64 - - os: - linux: Linux - cpu: - x86_64: x86_64 - arm_64: aarch64 - url: https://github.com/bufbuild/buf/releases/download/v${version}/buf-${os}-${cpu} - - os: - macos: Darwin - cpu: - x86_64: x86_64 - arm_64: arm64 - url: https://github.com/bufbuild/buf/releases/download/v${version}/buf-${os}-${cpu} - - os: windows - cpu: - x86_64: x86_64 - arm_64: arm64 - url: https://github.com/bufbuild/buf/releases/download/v${version}/buf-Windows-${cpu}.exe definitions: - name: buf-format files: [proto] - download: buf + tools: [buf] suggest_if: never description: Formatter for Protobuf commands: @@ -55,14 +28,14 @@ lint: - buf.lock - buf.gen.yaml - buf.work.yaml - known_good_version: 1.17.0 # format subcommand was added in 1.2.0 + known_good_version: 1.55.1 # format subcommand was added in 1.2.0 version_command: parse_regex: ${semver} run: buf --version - name: buf-lint files: [proto] - download: buf + tools: [buf] description: Accelerate Protobuf development with Buf commands: - name: lint @@ -83,14 +56,14 @@ lint: - buf.gen.yaml - buf.work.yaml issue_url_format: https://docs.buf.build/lint/rules#{} - known_good_version: 1.17.0 # newer version is needed to support Windows fully + known_good_version: 1.55.1 # newer version is needed to support Windows fully version_command: parse_regex: ${semver} run: buf --version - name: buf-breaking files: [proto] - download: buf + tools: [buf] suggest_if: never description: Check for breaking Protobuf API changes commands: @@ -118,7 +91,7 @@ lint: - buf.gen.yaml - buf.work.yaml issue_url_format: https://docs.buf.build/breaking/rules#{} - known_good_version: 1.5.0 + known_good_version: 1.55.1 version_command: parse_regex: ${semver} run: buf --version diff --git a/linters/buf/test_data/buf_breaking_v1.32.0_dupFile.check.shot b/linters/buf/test_data/buf_breaking_v1.32.0_dupFile.check.shot deleted file mode 100644 index 0a106332a..000000000 --- a/linters/buf/test_data/buf_breaking_v1.32.0_dupFile.check.shot +++ /dev/null @@ -1,55 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP -// trunk-upgrade-validation:RELEASE - -exports[`Testing linter buf-breaking test dupFile 1`] = ` -{ - "issues": [ - { - "code": "COMPILE", - "column": "13", - "file": "test_data/buf_breaking.in.proto", - "issueUrl": "https://docs.buf.build/breaking/rules#compile", - "level": "LEVEL_HIGH", - "line": "7", - "linter": "buf-breaking", - "message": "symbol "trunk.HelloWorld" already defined at test_data/buf_breaking.in.proto:7:13", - "targetType": "proto", - }, - { - "code": "COMPILE", - "column": "13", - "file": "test_data/buf_breaking.in.proto", - "issueUrl": "https://docs.buf.build/breaking/rules#compile", - "level": "LEVEL_HIGH", - "line": "8", - "linter": "buf-breaking", - "message": "symbol "trunk.HelloWorld.hello" already defined at test_data/buf_breaking.in.proto:8:13", - "targetType": "proto", - }, - { - "code": "COMPILE", - "column": "13", - "file": "test_data/buf_breaking.in.proto", - "issueUrl": "https://docs.buf.build/breaking/rules#compile", - "level": "LEVEL_HIGH", - "line": "9", - "linter": "buf-breaking", - "message": "symbol "trunk.HelloWorld.world" already defined at test_data/buf_breaking.in.proto:9:13", - "targetType": "proto", - }, - ], - "lintActions": [ - { - "command": "lint", - "fileGroupName": "proto", - "linter": "buf-breaking", - "paths": [ - ".", - ], - "verb": "TRUNK_VERB_CHECK", - }, - ], - "taskFailures": [], - "unformattedFiles": [], -} -`; diff --git a/linters/buf/test_data/buf_breaking_v1.5.0_basic.check.shot b/linters/buf/test_data/buf_breaking_v1.5.0_basic.check.shot deleted file mode 100644 index 2cc9d57a9..000000000 --- a/linters/buf/test_data/buf_breaking_v1.5.0_basic.check.shot +++ /dev/null @@ -1,43 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Testing linter buf-breaking test basic 1`] = ` -{ - "issues": [ - { - "code": "FIELD_NO_DELETE", - "column": "5", - "file": "test_data/buf_breaking.in.proto", - "issueUrl": "https://docs.buf.build/breaking/rules#field_no_delete", - "level": "LEVEL_HIGH", - "line": "7", - "linter": "buf-breaking", - "message": "Previously present field "2" with name "world" on message "HelloWorld" was deleted.", - "targetType": "proto", - }, - { - "code": "FIELD_SAME_TYPE", - "column": "7", - "file": "test_data/buf_breaking.in.proto", - "issueUrl": "https://docs.buf.build/breaking/rules#field_same_type", - "level": "LEVEL_HIGH", - "line": "8", - "linter": "buf-breaking", - "message": "Field "1" on message "HelloWorld" changed type from "string" to "int32".", - "targetType": "proto", - }, - ], - "lintActions": [ - { - "command": "lint", - "fileGroupName": "proto", - "linter": "buf-breaking", - "paths": [ - ".", - ], - "verb": "TRUNK_VERB_CHECK", - }, - ], - "taskFailures": [], - "unformattedFiles": [], -} -`; diff --git a/linters/buf/test_data/buf_breaking_v1.5.0_dupFile.check.shot b/linters/buf/test_data/buf_breaking_v1.5.0_dupFile.check.shot deleted file mode 100644 index 7fd5c0f6c..000000000 --- a/linters/buf/test_data/buf_breaking_v1.5.0_dupFile.check.shot +++ /dev/null @@ -1,54 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Testing linter buf-breaking test dupFile 1`] = ` -{ - "issues": [ - { - "code": "COMPILE", - "column": "5", - "file": "test_data/buf_breaking.in.proto", - "issueUrl": "https://docs.buf.build/breaking/rules#compile", - "level": "LEVEL_HIGH", - "line": "7", - "linter": "buf-breaking", - "message": "duplicate symbol trunk.HelloWorld: already defined as message in "test_data/buf_breaking.in.proto"", - "targetType": "proto", - }, - { - "code": "COMPILE", - "column": "7", - "file": "test_data/buf_breaking.in.proto", - "issueUrl": "https://docs.buf.build/breaking/rules#compile", - "level": "LEVEL_HIGH", - "line": "8", - "linter": "buf-breaking", - "message": "duplicate symbol trunk.HelloWorld.hello: already defined as field in "test_data/buf_breaking.in.proto"", - "targetType": "proto", - }, - { - "code": "COMPILE", - "column": "7", - "file": "test_data/buf_breaking.in.proto", - "issueUrl": "https://docs.buf.build/breaking/rules#compile", - "level": "LEVEL_HIGH", - "line": "9", - "linter": "buf-breaking", - "message": "duplicate symbol trunk.HelloWorld.world: already defined as field in "test_data/buf_breaking.in.proto"", - "targetType": "proto", - }, - ], - "lintActions": [ - { - "command": "lint", - "fileGroupName": "proto", - "linter": "buf-breaking", - "paths": [ - ".", - ], - "verb": "TRUNK_VERB_CHECK", - }, - ], - "taskFailures": [], - "unformattedFiles": [], -} -`; diff --git a/linters/buf/test_data/buf_breaking_v1.32.0_basic.check.shot b/linters/buf/test_data/buf_breaking_v1.55.1_basic.check.shot similarity index 97% rename from linters/buf/test_data/buf_breaking_v1.32.0_basic.check.shot rename to linters/buf/test_data/buf_breaking_v1.55.1_basic.check.shot index 91b5e3bc0..9a331ebd6 100644 --- a/linters/buf/test_data/buf_breaking_v1.32.0_basic.check.shot +++ b/linters/buf/test_data/buf_breaking_v1.55.1_basic.check.shot @@ -1,5 +1,4 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -// trunk-upgrade-validation:RELEASE exports[`Testing linter buf-breaking test basic 1`] = ` { diff --git a/linters/buf/test_data/buf_breaking_v1.9.0_dupFile.check.shot b/linters/buf/test_data/buf_breaking_v1.55.1_dupFile.check.shot similarity index 100% rename from linters/buf/test_data/buf_breaking_v1.9.0_dupFile.check.shot rename to linters/buf/test_data/buf_breaking_v1.55.1_dupFile.check.shot diff --git a/linters/buf/test_data/buf_breaking_v1.9.0_basic.check.shot b/linters/buf/test_data/buf_breaking_v1.9.0_basic.check.shot deleted file mode 100644 index 2cc9d57a9..000000000 --- a/linters/buf/test_data/buf_breaking_v1.9.0_basic.check.shot +++ /dev/null @@ -1,43 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Testing linter buf-breaking test basic 1`] = ` -{ - "issues": [ - { - "code": "FIELD_NO_DELETE", - "column": "5", - "file": "test_data/buf_breaking.in.proto", - "issueUrl": "https://docs.buf.build/breaking/rules#field_no_delete", - "level": "LEVEL_HIGH", - "line": "7", - "linter": "buf-breaking", - "message": "Previously present field "2" with name "world" on message "HelloWorld" was deleted.", - "targetType": "proto", - }, - { - "code": "FIELD_SAME_TYPE", - "column": "7", - "file": "test_data/buf_breaking.in.proto", - "issueUrl": "https://docs.buf.build/breaking/rules#field_same_type", - "level": "LEVEL_HIGH", - "line": "8", - "linter": "buf-breaking", - "message": "Field "1" on message "HelloWorld" changed type from "string" to "int32".", - "targetType": "proto", - }, - ], - "lintActions": [ - { - "command": "lint", - "fileGroupName": "proto", - "linter": "buf-breaking", - "paths": [ - ".", - ], - "verb": "TRUNK_VERB_CHECK", - }, - ], - "taskFailures": [], - "unformattedFiles": [], -} -`; diff --git a/linters/buf/test_data/buf_format_v1.32.0_buf_lint.fmt.shot b/linters/buf/test_data/buf_format_v1.32.0_buf_lint.fmt.shot deleted file mode 100644 index 1e403d81f..000000000 --- a/linters/buf/test_data/buf_format_v1.32.0_buf_lint.fmt.shot +++ /dev/null @@ -1,14 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP -// trunk-upgrade-validation:RELEASE - -exports[`Testing formatter buf-format test buf_lint 1`] = ` -"syntax = "proto3"; - -package trunk; - -enum GoodEnum { - lower_case_UNSPECIFIED = 0; - GOOD_ENUM_VALUE_1 = 1; -} -" -`; diff --git a/linters/buf/test_data/buf_format_v1.17.0_buf_lint.fmt.shot b/linters/buf/test_data/buf_format_v1.55.1_buf_lint.fmt.shot similarity index 100% rename from linters/buf/test_data/buf_format_v1.17.0_buf_lint.fmt.shot rename to linters/buf/test_data/buf_format_v1.55.1_buf_lint.fmt.shot diff --git a/linters/buf/test_data/buf_lint_v1.32.0_buf_lint.check.shot b/linters/buf/test_data/buf_lint_v1.32.0_buf_lint.check.shot deleted file mode 100644 index a9b747ee0..000000000 --- a/linters/buf/test_data/buf_lint_v1.32.0_buf_lint.check.shot +++ /dev/null @@ -1,92 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP -// trunk-upgrade-validation:RELEASE - -exports[`Testing linter buf-lint test buf_lint 1`] = ` -{ - "issues": [ - { - "code": "FILE_LOWER_SNAKE_CASE", - "column": "1", - "file": "test_data/buf_lint.in.proto", - "issueClass": "ISSUE_CLASS_EXISTING", - "issueUrl": "https://docs.buf.build/lint/rules#file_lower_snake_case", - "level": "LEVEL_HIGH", - "line": "1", - "linter": "buf-lint", - "message": "Filename "buf_lint.in.proto" should be lower_snake_case.proto, such as "buf_lint_in.proto".", - "targetType": "proto", - }, - { - "code": "PACKAGE_DIRECTORY_MATCH", - "column": "1", - "file": "test_data/buf_lint.in.proto", - "issueClass": "ISSUE_CLASS_EXISTING", - "issueUrl": "https://docs.buf.build/lint/rules#package_directory_match", - "level": "LEVEL_HIGH", - "line": "4", - "linter": "buf-lint", - "message": "Files with package "trunk" must be within a directory "trunk" relative to root but were in directory "test_data".", - "targetType": "proto", - }, - { - "code": "PACKAGE_VERSION_SUFFIX", - "column": "1", - "file": "test_data/buf_lint.in.proto", - "issueClass": "ISSUE_CLASS_EXISTING", - "issueUrl": "https://docs.buf.build/lint/rules#package_version_suffix", - "level": "LEVEL_HIGH", - "line": "4", - "linter": "buf-lint", - "message": "Package name "trunk" should be suffixed with a correctly formed version, such as "trunk.v1".", - "targetType": "proto", - }, - { - "code": "ENUM_VALUE_PREFIX", - "column": "3", - "file": "test_data/buf_lint.in.proto", - "issueClass": "ISSUE_CLASS_EXISTING", - "issueUrl": "https://docs.buf.build/lint/rules#enum_value_prefix", - "level": "LEVEL_HIGH", - "line": "7", - "linter": "buf-lint", - "message": "Enum value name "lower_case_UNSPECIFIED" should be prefixed with "GOOD_ENUM_".", - "targetType": "proto", - }, - { - "code": "ENUM_VALUE_UPPER_SNAKE_CASE", - "column": "3", - "file": "test_data/buf_lint.in.proto", - "issueClass": "ISSUE_CLASS_EXISTING", - "issueUrl": "https://docs.buf.build/lint/rules#enum_value_upper_snake_case", - "level": "LEVEL_HIGH", - "line": "7", - "linter": "buf-lint", - "message": "Enum value name "lower_case_UNSPECIFIED" should be UPPER_SNAKE_CASE, such as "LOWER_CASE_UNSPECIFIED".", - "targetType": "proto", - }, - ], - "lintActions": [ - { - "command": "lint", - "fileGroupName": "proto", - "linter": "buf-lint", - "paths": [ - "test_data/buf_lint.in.proto", - ], - "verb": "TRUNK_VERB_CHECK", - }, - { - "command": "lint", - "fileGroupName": "proto", - "linter": "buf-lint", - "paths": [ - "test_data/buf_lint.in.proto", - ], - "upstream": true, - "verb": "TRUNK_VERB_CHECK", - }, - ], - "taskFailures": [], - "unformattedFiles": [], -} -`; diff --git a/linters/buf/test_data/buf_lint_v1.17.0_buf_lint.check.shot b/linters/buf/test_data/buf_lint_v1.55.1_buf_lint.check.shot similarity index 100% rename from linters/buf/test_data/buf_lint_v1.17.0_buf_lint.check.shot rename to linters/buf/test_data/buf_lint_v1.55.1_buf_lint.check.shot diff --git a/tools/buf/buf.test.ts b/tools/buf/buf.test.ts new file mode 100644 index 000000000..6521cce70 --- /dev/null +++ b/tools/buf/buf.test.ts @@ -0,0 +1,12 @@ +import { makeToolTestConfig, toolTest } from "tests"; + +toolTest({ + toolName: "buf", + toolVersion: "1.55.1", + testConfigs: [ + makeToolTestConfig({ + command: ["buf", "--version"], + expectedOut: "1.55.1", + }), + ], +}); diff --git a/tools/buf/plugin.yaml b/tools/buf/plugin.yaml new file mode 100644 index 000000000..d79539e35 --- /dev/null +++ b/tools/buf/plugin.yaml @@ -0,0 +1,35 @@ +version: 0.1 +downloads: + - name: buf + version: 1.55.1 + executable: true + downloads: + # macos arm64 was introduced after this version. + - os: macos + version: <0.42.0 + url: https://github.com/bufbuild/buf/releases/download/v${version}/buf-Darwin-x86_64 + - os: + linux: Linux + cpu: + x86_64: x86_64 + arm_64: aarch64 + url: https://github.com/bufbuild/buf/releases/download/v${version}/buf-${os}-${cpu} + - os: + macos: Darwin + cpu: + x86_64: x86_64 + arm_64: arm64 + url: https://github.com/bufbuild/buf/releases/download/v${version}/buf-${os}-${cpu} + - os: windows + cpu: + x86_64: x86_64 + arm_64: arm64 + url: https://github.com/bufbuild/buf/releases/download/v${version}/buf-Windows-${cpu}.exe +tools: + definitions: + - name: buf + download: buf + known_good_version: 1.55.1 + shims: + - name: buf + target: buf