-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scripts): add test:e2e:legacy:preview
- Loading branch information
Showing
8 changed files
with
102 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { join } from "path"; | ||
import { execSync } from "child_process"; | ||
import { getDirName } from "./getDirName.mjs"; | ||
|
||
const __dirname = getDirName(); | ||
const FEATURES_FOLDER = join(__dirname, "..", "..", "features"); | ||
|
||
const execOptions = { | ||
...process, | ||
cwd: __dirname, | ||
encoding: "utf-8", | ||
}; | ||
|
||
export const getAllTags = () => | ||
execSync(`grep -h ^@ ${join(FEATURES_FOLDER, "**", "*.feature")}`, execOptions).split(/[\n ]/g); |
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,4 @@ | ||
import { dirname } from "path"; | ||
import { fileURLToPath } from "url"; | ||
|
||
export const getDirName = () => dirname(fileURLToPath(import.meta.url)); |
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,5 @@ | ||
export const getPackageTags = (packages) => | ||
packages | ||
.map((name) => name.replace("@aws-sdk/client-", "")) | ||
.map((name) => name.replace("-")) | ||
.map((name) => `@${name}`); |
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,25 @@ | ||
#!/usr/bin/env node | ||
|
||
import { execSync } from "child_process"; | ||
import { getDirName } from "./getDirName.mjs"; | ||
import { getAllTags } from "./getAllTags.mjs"; | ||
import { getPackageTags } from "./getPackageTags.mjs"; | ||
import { runTestForTags } from "./runTestForTags.mjs"; | ||
import conventionalCommitsParser from "conventional-commits-parser"; | ||
|
||
const __dirname = getDirName(); | ||
|
||
console.info(`Looking for updated client...`); | ||
const execOptions = { ...process, cwd: __dirname, encoding: "utf-8" }; | ||
const gitCommitMessage = execSync(`git show -s --format=%s`, execOptions); | ||
|
||
const { scope } = conventionalCommitsParser.sync(gitCommitMessage); | ||
if (!scope) { | ||
console.info(`Couldn't find scope in commit message '${gitCommitMessage}'`); | ||
process.exit(1); | ||
} | ||
|
||
const allTags = getAllTags(); | ||
const changedPackageTags = getPackageTags([scope]); | ||
const tagsToTest = changedPackageTags.filter((tag) => allTags.includes(tag)); | ||
runTestForTags(tagsToTest); |
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,26 @@ | ||
import { join, resolve } from "path"; | ||
import { spawn } from "child_process"; | ||
import { getDirName } from "./getDirName.mjs"; | ||
|
||
const __dirname = getDirName(); | ||
const ROOT = resolve(join(__dirname, "..", "..")); | ||
|
||
export const runTestForTags = (tagsToTest) => { | ||
if (tagsToTest.length === 0) { | ||
console.info("No clients with integration test cases have changed."); | ||
return; | ||
} | ||
|
||
// Cucumber requires cwd to contain the test cases. | ||
const command = `${join("node_modules", ".bin", "cucumber-js")}`; | ||
const args = ["--fail-fast", "-t", `"${tagsToTest.join(" or ")}"`]; | ||
console.info(`Running cucumber test: \n${command} ${args.join(" ")}`); | ||
|
||
const cucumber = spawn(command, args, { ...execOptions, cwd: ROOT, shell: true }); | ||
cucumber.stdout.pipe(process.stdout); | ||
cucumber.stderr.pipe(process.stderr); | ||
cucumber.on("close", (code) => { | ||
if (code === 0) process.exit(); | ||
else process.exit(code); | ||
}); | ||
}; |
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,25 @@ | ||
#!/usr/bin/env node | ||
|
||
import { join } from "path"; | ||
import { execSync } from "child_process"; | ||
import { getDirName } from "./getDirName.mjs"; | ||
import { getAllTags } from "./getAllTags.mjs"; | ||
import { getPackageTags } from "./getPackageTags.mjs"; | ||
import { runTestForTags } from "./runTestForTags.mjs"; | ||
|
||
const __dirname = getDirName(); | ||
const ROOT_BIN = join(__dirname, "..", "..", "node_modules", ".bin"); | ||
|
||
console.info(`Looking for changed packages...`); | ||
let changedPackages = []; | ||
try { | ||
const execOptions = { ...process, cwd: __dirname, encoding: "utf-8" }; | ||
changedPackages = execSync(`${join(ROOT_BIN, "lerna")} changed`, execOptions).split("\n"); | ||
} catch (e) { | ||
// Swallow error because Lerna throws if no package changes. | ||
} | ||
|
||
const allTags = getAllTags(); | ||
const changedPackageTags = getPackageTags(changedPackages); | ||
const tagsToTest = changedPackageTags.filter((tag) => allTags.includes(tag)); | ||
runTestForTags(tagsToTest); |