-
Notifications
You must be signed in to change notification settings - Fork 816
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit de98654.
- Loading branch information
Showing
18 changed files
with
110 additions
and
1,727 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
packages/amplify-e2e-core/src/utils/add-ci-cleanup-tags.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { stateManager } from '@aws-amplify/amplify-cli-core'; | ||
|
||
declare global { | ||
/* eslint-disable @typescript-eslint/no-namespace */ | ||
namespace NodeJS { | ||
interface Global { | ||
getTestName?: () => string; | ||
getHookName?: () => string; | ||
getDescibeBlocks?: () => string[]; | ||
} | ||
} | ||
/* eslint-enable */ | ||
} | ||
|
||
export const addCircleCITags = (projectPath: string): void => { | ||
if (process.env && process.env['CIRCLECI']) { | ||
const tags = stateManager.getProjectTags(projectPath); | ||
|
||
const addTagIfNotExist = (key: string, value: string): void => { | ||
if (!tags.find((t) => t.Key === key)) { | ||
tags.push({ | ||
Key: key, | ||
Value: value, | ||
}); | ||
} | ||
}; | ||
|
||
addTagIfNotExist('circleci', sanitizeTagValue(process.env['CIRCLECI'] || 'N/A')); | ||
addTagIfNotExist('circleci:branch', sanitizeTagValue(process.env['CIRCLE_BRANCH'] || 'N/A')); | ||
addTagIfNotExist('circleci:sha1', sanitizeTagValue(process.env['CIRCLE_SHA1'] || 'N/A')); | ||
addTagIfNotExist('circleci:workflow_id', sanitizeTagValue(process.env['CIRCLE_WORKFLOW_ID'] || 'N/A')); | ||
addTagIfNotExist('circleci:build_id', sanitizeTagValue(process.env['CIRCLE_BUILD_NUM'] || 'N/A')); | ||
addTagIfNotExist('circleci:build_url', sanitizeTagValue(process.env['CIRCLE_BUILD_URL'] || 'N/A')); | ||
addTagIfNotExist('circleci:job', sanitizeTagValue(process.env['CIRCLE_JOB'] || 'N/A')); | ||
addTagIfNotExist('circleci:create_time', new Date().toISOString()); | ||
// exposed by custom CLI test environment | ||
if (global.getTestName) { | ||
addTagIfNotExist('jest:test_name', sanitizeTagValue(global.getTestName().substr(0, 255) || 'N/A')); | ||
} | ||
if (global.getHookName) { | ||
addTagIfNotExist('jest:hook_name', sanitizeTagValue(global.getHookName().substr(0, 255) || 'N/A')); | ||
} | ||
if (global.getDescibeBlocks) { | ||
global.getDescibeBlocks().forEach((blockName, i) => { | ||
addTagIfNotExist(`jest:describe_${i + 1}`, sanitizeTagValue(blockName.substr(0, 255) || 'N/A')); | ||
}); | ||
} | ||
|
||
stateManager.setProjectFileTags(projectPath, tags); | ||
} | ||
}; | ||
|
||
export function sanitizeTagValue(value: string): string { | ||
return value.replace(/[^ a-z0-9_.:/=+\-@]/gi, ''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.