-
Notifications
You must be signed in to change notification settings - Fork 618
feat(scripts): add test:e2e:legacy:preview #6538
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6643ed6
feat(scripts): add test:e2e:legacy:preview
trivikr 06dacde
chore(scripts): use string commands for getting scope
trivikr 49e686d
fix(scripts): explicitly replace '-' to '' in getPackageTags
trivikr aba0caf
fix(scripts): explcitly mention 'with e2e-legacy test cases' in msg
trivikr cc02ac9
chore(scripts): use process.exit on cucumber close event with availab…
trivikr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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"; | ||
|
||
const __dirname = getDirName(); | ||
|
||
const execOptions = { ...process, cwd: __dirname, encoding: "utf-8" }; | ||
const commitMessage = execSync(`git show -s --format=%s`, execOptions); | ||
const prefix = commitMessage.split(":")[0]; | ||
const scope = prefix.substring(prefix.indexOf("(") + 1, prefix.indexOf(")")); | ||
console.info(`Updated scope: ${scope}`); | ||
|
||
if (!scope) { | ||
console.info(`Couldn't find scope in commit message '${commitMessage}'`); | ||
process.exit(1); | ||
} | ||
|
||
const allTags = getAllTags(); | ||
const changedPackageTags = getPackageTags([`@aws-sdk/${scope}`]); | ||
const tagsToTest = changedPackageTags.filter((tag) => allTags.includes(tag)); | ||
runTestForTags(tagsToTest); |
This file contains hidden or 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 e2e-legacy 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 execOptions = { ...process, cwd: ROOT, encoding: "utf-8", shell: true }; | ||
const cucumber = spawn(command, args, execOptions); | ||
cucumber.stdout.pipe(process.stdout); | ||
cucumber.stderr.pipe(process.stderr); | ||
cucumber.on("close", (code) => { | ||
process.exit(code); | ||
}); | ||
}; |
This file contains hidden or 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); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.