From 2fcbf624eb8a7a52c241f7f11eebb0232f507be8 Mon Sep 17 00:00:00 2001 From: Chris Clearwater Date: Tue, 12 Nov 2024 13:36:31 -0800 Subject: [PATCH] Fix hadolint on some versions of macOS (#913) --- linters/hadolint/hadolint.test.ts | 12 +- .../hadolint_v2.12.1-beta_CUSTOM.check.shot | 157 ++++++++++++++++++ 2 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 linters/hadolint/test_data/hadolint_v2.12.1-beta_CUSTOM.check.shot diff --git a/linters/hadolint/hadolint.test.ts b/linters/hadolint/hadolint.test.ts index 166239e36..5c1873dcf 100644 --- a/linters/hadolint/hadolint.test.ts +++ b/linters/hadolint/hadolint.test.ts @@ -1,5 +1,15 @@ import { customLinterCheckTest } from "tests"; import { TEST_DATA } from "tests/utils"; +const manualVersionReplacer = (version: string) => { + if (version === "2.12.0") { + // This version may segfault on certain versions on macOS. + // The beta version is identical except with upx compression disabled on the binary. + // See https://github.com/hadolint/hadolint/issues/919#issuecomment-1672031271 + return "2.12.1-beta"; + } + return version; +}; + // We have a number of different files to determine which are valid Dockerfiles, validated by lint actions in the snapshot -customLinterCheckTest({ linterName: "hadolint", args: TEST_DATA }); +customLinterCheckTest({ linterName: "hadolint", args: TEST_DATA, manualVersionReplacer }); diff --git a/linters/hadolint/test_data/hadolint_v2.12.1-beta_CUSTOM.check.shot b/linters/hadolint/test_data/hadolint_v2.12.1-beta_CUSTOM.check.shot new file mode 100644 index 000000000..e5b0d64c0 --- /dev/null +++ b/linters/hadolint/test_data/hadolint_v2.12.1-beta_CUSTOM.check.shot @@ -0,0 +1,157 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing linter hadolint test CUSTOM 1`] = ` +{ + "issues": [ + { + "code": "DL3059", + "column": "1", + "file": "test_data/basic.Dockerfile", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/hadolint/hadolint/wiki/DL3059", + "level": "LEVEL_LOW", + "line": "4", + "linter": "hadolint", + "message": "Multiple consecutive \`RUN\` instructions. Consider consolidation.", + "targetType": "docker", + }, + ], + "lintActions": [ + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/Dockerfile", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/Dockerfile.empty", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/basic.Dockerfile", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/empty.Dockerfile", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/nested/Dockerfile.debug", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/nested/dockerfile", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/nested/prefix.Dockerfile", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/Dockerfile", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/Dockerfile.empty", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/basic.Dockerfile", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/empty.Dockerfile", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/nested/Dockerfile.debug", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/nested/dockerfile", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "docker", + "linter": "hadolint", + "paths": [ + "test_data/nested/prefix.Dockerfile", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + ], + "taskFailures": [], + "unformattedFiles": [], +} +`;