Skip to content

Commit

Permalink
fix: adjust path finding for schemas in codebuild (#12771)
Browse files Browse the repository at this point in the history
* fix: adjust path finding for schemas in codebuild

* fix: adjust path finding for schemas in codebuild. adding windows condition

* fix: adjust path finding for schemas in codebuild. adding windows condition

* fix: adjust path finding for schemas in codebuild. copying windows function

* fix: adjust path finding for schemas in codebuild. copying windows function

* fix: adjust path finding for schemas in codebuild. copying windows function
  • Loading branch information
goldbez committed Jun 9, 2023
1 parent 7177889 commit fb24fe7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .circleci/scan_artifacts_codebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const hasMatchingContentInFolder = (patterns: string[], folder: string, e
try {
execa.sync('grep', ['-r', `--exclude-dir=${excludeFolder}`, ...patternParam, folder]);
return true;
} catch (e) {
} catch (e: any) {
// When there is no match exit code is set to 1
if (e.exitCode === 1) {
return false;
Expand Down
5 changes: 5 additions & 0 deletions codebuild_specs/run_e2e_tests_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ phases:
- bash ./codebuild_specs/scripts-windows/load-e2e-cache.sh
- bash ./codebuild_specs/scripts-windows/rename-packaged-cli.sh
- bash ./codebuild_specs/scripts-windows/run-e2e-windows.sh
artifacts:
files:
- '$E2E_TEST_COVERAGE_DIR/*'
- amplify-e2e-reports/*
base-directory: packages/amplify-e2e-tests/
6 changes: 6 additions & 0 deletions packages/amplify-e2e-core/src/categories/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ import { multiSelect, singleSelect } from '../utils/selectors';
import { selectRuntime, selectTemplate } from './lambda-function';
import { modifiedApi } from './resources/modified-api-index';

const isWindowsPlatform = (): boolean => !!process?.platform?.startsWith('win');

export function getSchemaPath(schemaName: string): string {
// This condition is to account for a difference in the use of __dirname and paths in CodeBuild Windows jobs
if (process.env.CODEBUILD_SRC_DIR && isWindowsPlatform()) {
return path.join(process.env.CODEBUILD_SRC_DIR, 'packages', 'amplify-e2e-tests', 'schemas', schemaName);
}
return path.join(__dirname, '..', '..', '..', 'amplify-e2e-tests', 'schemas', schemaName);
}

Expand Down
6 changes: 5 additions & 1 deletion packages/amplify-e2e-core/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,12 @@ export const getFunctionSrcNode = (root: string, functionName: string, fileName
return fs.readFileSync(indexPath).toString();
};

const isWindowsPlatform = (): boolean => !!process?.platform?.startsWith('win');

const getTestFileNamePath = (fileName: string): string =>
path.join(__dirname, '..', '..', '..', 'amplify-e2e-tests', 'functions', fileName);
process.env.CODEBUILD_SRC_DIR && isWindowsPlatform()
? path.join(process.env.CODEBUILD_SRC_DIR, 'packages', 'amplify-e2e-tests', 'functions', fileName) // This condition is to account for a difference in the use of __dirname and paths in CodeBuild Windows jobs
: path.join(__dirname, '..', '..', '..', 'amplify-e2e-tests', 'functions', fileName);
const getPathToFunction = (root: string, funcName: string): string => path.join(root, 'amplify', 'backend', 'function', funcName);
const getPathToLayer = (root: string, layerProjectName: LayerDirectoryType): string =>
path.join(root, 'amplify', 'backend', 'function', getLayerDirectoryName(layerProjectName));
Expand Down

0 comments on commit fb24fe7

Please sign in to comment.