Skip to content

chore: install git on alpine and re-enable test #3825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2022
Merged
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ jobs:
- run:
name: Installing Node.js + other test dependencies
command: |
apk add --update nodejs npm bash maven
apk add --update nodejs npm bash maven git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: What's the difference between the Alpine image used for testing and a standard Alpine image?
Would Alpine images usually include git out of the box?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For testing we use a standard Alpine image. Alpine is a hardened linux distribution which comes with almost nothing and not even glibc.

- setup_npm:
npm_cache_directory: /home/circleci/.npm
npm_global_sudo: false
Expand Down
52 changes: 22 additions & 30 deletions test/jest/acceptance/iac/file-output.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,36 +85,28 @@ describe('iac test --sarif-file-output', () => {
expect(startLine).not.toEqual(-1);
});

if (
process.env.TEST_SNYK_COMMAND &&
process.env.TEST_SNYK_COMMAND.includes('alpine')
) {
// This test is temporarily skipped on Alpine Linux.
it.skip('returns the correct paths for provided path', async () => {});
} else {
it('returns the correct paths for provided path', async () => {
const sarifOutputFilename = path.join(__dirname, `${uuidv4()}.sarif`);
const { stdout } = await run(
`snyk iac test ./iac/file-output/sg_open_ssh.tf --sarif-file-output=${sarifOutputFilename}`,
);
expect(stdout).toMatch('Organization:');

const outputFileContents = readFileSync(sarifOutputFilename, 'utf-8');
unlinkSync(sarifOutputFilename);
const jsonObj = JSON.parse(outputFileContents);
const actualPhysicalLocation =
jsonObj?.runs?.[0].results[0].locations[0].physicalLocation
.artifactLocation.uri;
const actualProjectRoot =
jsonObj?.runs?.[0].originalUriBaseIds.PROJECTROOT.uri;
expect(actualPhysicalLocation).toEqual(
'test/fixtures/iac/file-output/sg_open_ssh.tf',
);
expect(actualProjectRoot).toEqual(
pathToFileURL(path.join(path.resolve(''), '/')).href,
);
});
}
it('returns the correct paths for provided path', async () => {
const sarifOutputFilename = path.join(__dirname, `${uuidv4()}.sarif`);
const { stdout } = await run(
`snyk iac test ./iac/file-output/sg_open_ssh.tf --sarif-file-output=${sarifOutputFilename}`,
);
expect(stdout).toMatch('Organization:');

const outputFileContents = readFileSync(sarifOutputFilename, 'utf-8');
unlinkSync(sarifOutputFilename);
const jsonObj = JSON.parse(outputFileContents);
const actualPhysicalLocation =
jsonObj?.runs?.[0].results[0].locations[0].physicalLocation
.artifactLocation.uri;
const actualProjectRoot =
jsonObj?.runs?.[0].originalUriBaseIds.PROJECTROOT.uri;
expect(actualPhysicalLocation).toEqual(
'test/fixtures/iac/file-output/sg_open_ssh.tf',
);
expect(actualProjectRoot).toEqual(
pathToFileURL(path.join(path.resolve(''), '/')).href,
);
});

it('does not include file content in analytics logs', async () => {
const { stdout, exitCode } = await run(
Expand Down