Skip to content

Commit

Permalink
Fix hadolint on some versions of macOS (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
det authored Nov 12, 2024
1 parent 29bbc00 commit 2fcbf62
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 1 deletion.
12 changes: 11 additions & 1 deletion linters/hadolint/hadolint.test.ts
Original file line number Diff line number Diff line change
@@ -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 });
157 changes: 157 additions & 0 deletions linters/hadolint/test_data/hadolint_v2.12.1-beta_CUSTOM.check.shot
Original file line number Diff line number Diff line change
@@ -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": [],
}
`;

0 comments on commit 2fcbf62

Please sign in to comment.