diff --git a/linters/yamlfmt/plugin.yaml b/linters/yamlfmt/plugin.yaml index 06d62da32..a91e9a1cb 100644 --- a/linters/yamlfmt/plugin.yaml +++ b/linters/yamlfmt/plugin.yaml @@ -25,7 +25,7 @@ lint: - name: format output: rewrite run: yamlfmt ${target} - run_from: ${parent} + run_from: workspace success_codes: [0, 1] cache_results: true formatter: true @@ -38,6 +38,11 @@ lint: - .yamlfmt.yml - yamlfmt.yaml - yamlfmt.yml + - .trunk/configs/.yamlfmt + - .trunk/configs/.yamlfmt.yaml + - .trunk/configs/.yamlfmt.yml + - .trunk/configs/yamlfmt.yaml + - .trunk/configs/yamlfmt.yml suggest_if: config_present version_command: parse_regex: ${semver} diff --git a/linters/yamlfmt/test_data/config.in.yaml b/linters/yamlfmt/test_data/config.in.yaml new file mode 100644 index 000000000..fe4172472 --- /dev/null +++ b/linters/yamlfmt/test_data/config.in.yaml @@ -0,0 +1,3 @@ +description: >- + Builds and pushes a Docker image to a container registry. + Requires authentication to be handled by the calling workflow. diff --git a/linters/yamlfmt/test_data/yamlfmt_v0.20.0_config.fmt.shot b/linters/yamlfmt/test_data/yamlfmt_v0.20.0_config.fmt.shot new file mode 100644 index 000000000..90c11a2aa --- /dev/null +++ b/linters/yamlfmt/test_data/yamlfmt_v0.20.0_config.fmt.shot @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing formatter yamlfmt test config 1`] = ` +"description: >- + Builds and pushes a Docker image to a container registry. + Requires authentication to be handled by the calling workflow. +" +`; diff --git a/linters/yamlfmt/yamlfmt.test.ts b/linters/yamlfmt/yamlfmt.test.ts index 405a4d1af..f1ea362b7 100644 --- a/linters/yamlfmt/yamlfmt.test.ts +++ b/linters/yamlfmt/yamlfmt.test.ts @@ -1,9 +1,25 @@ import { linterCheckTest, linterFmtTest } from "tests"; +import { TrunkLintDriver } from "tests/driver"; import { osTimeoutMultiplier } from "tests/utils"; // This install is quite slow on some Linux machines. jest.setTimeout(600000 * osTimeoutMultiplier); +const writeTrunkConfig = (driver: TrunkLintDriver) => { + const config = `formatter: + type: basic + scan_folded_as_literal: true + retain_line_breaks: true +`; + driver.writeFile(".trunk/configs/.yamlfmt.yml", config); +}; + linterCheckTest({ linterName: "yamlfmt", namedTestPrefixes: ["empty"] }); linterFmtTest({ linterName: "yamlfmt", namedTestPrefixes: ["basic"] }); + +linterFmtTest({ + linterName: "yamlfmt", + namedTestPrefixes: ["config"], + preCheck: writeTrunkConfig, +});