Skip to content
Closed
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
7 changes: 6 additions & 1 deletion linters/yamlfmt/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down
3 changes: 3 additions & 0 deletions linters/yamlfmt/test_data/config.in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: >-
Builds and pushes a Docker image to a container registry.
Requires authentication to be handled by the calling workflow.
8 changes: 8 additions & 0 deletions linters/yamlfmt/test_data/yamlfmt_v0.20.0_config.fmt.shot
Original file line number Diff line number Diff line change
@@ -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.
"
`;
16 changes: 16 additions & 0 deletions linters/yamlfmt/yamlfmt.test.ts
Original file line number Diff line number Diff line change
@@ -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,
});