Skip to content

build: also track e2e test coverage #473

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 12 commits into from
May 22, 2023
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!.*
coverage
coverage*
lib
node_modules
pnpm-lock.yaml
10 changes: 9 additions & 1 deletion .github/workflows/hydrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare
- run: pnpm run build
- run: pnpm run setup:test
- run: pnpm run hydrate:test
- name: Codecov
uses: codecov/codecov-action@v3
with:
files: coverage-hydrate/lcov.info
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
path: coverage-hydrate

name: Test Hydrate Script

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare
- run: pnpm run build
- run: pnpm run setup:test

name: Test Setup Script
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ jobs:
- run: pnpm run test --coverage
- name: Codecov
uses: codecov/codecov-action@v3
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
name: code-coverage-report
path: coverage

name: Test

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
coverage/
coverage*/
lib/
node_modules/
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage/
coverage*/
lib/
pnpm-lock.yaml

Expand Down
1 change: 1 addition & 0 deletions knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"script/*e2e.js"
],
"ignoreBinaries": ["dedupe", "gh"],
"ignoreDependencies": ["c8"],
"project": ["src/**/*.ts!", "script/**/*.js"]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@typescript-eslint/parser": "^5.59.5",
"@vitest/coverage-istanbul": "^0.31.0",
"all-contributors-cli": "^6.25.1",
"c8": "^7.13.0",
"console-fail-test": "^0.2.3",
"cspell": "^6.31.1",
"eslint": "^8.40.0",
Expand Down
68 changes: 68 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 32 additions & 14 deletions script/hydrate-test-e2e.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import chalk from "chalk";
import { $ } from "execa";

await $({
stdio: "inherit",
})`c8 -o ./coverage-hydrate -r html -r lcov node ./lib/hydrate/index.js`;
Copy link
Owner Author

Choose a reason for hiding this comment

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

This, ah, should have been added already...


const { stdout: gitStatus } = await $`git status`;
console.log(`Stdout from running \`git status\`:\n${gitStatus}`);

Expand All @@ -19,6 +23,15 @@ const filesExpectedToBeChanged = new Set([
"knip.jsonc",
"package.json",
"pnpm-lock.yaml",
".eslintignore",
".eslintrc.cjs",
".github/DEVELOPMENT.md",
".github/workflows/release.yml",
".github/workflows/test.yml",
".gitignore",
".prettierignore",
".release-it.json",
"cspell.json",
]);

const unstagedModifiedFiles = gitStatus
Expand All @@ -27,24 +40,29 @@ const unstagedModifiedFiles = gitStatus
.map((match) => match.split(/\s+/g)[1])
.filter((filePath) => !filesExpectedToBeChanged.has(filePath));

console.log("Unexpected modified files are:", unstagedModifiedFiles);

if (unstagedModifiedFiles.length) {
const gitDiffCommand = `git diff HEAD -- ${unstagedModifiedFiles.join(" ")}`;
console.log(
`Stdout from running \`git diff\`:${(await $`git diff HEAD`).stdout}`
`Stdout from running \`${gitDiffCommand}\`:\n${
(await $(gitDiffCommand)).stdout
}`
);
console.error(
chalk.red(
[
"",
"Oh no! Running the hydrate script modified some files:",
...unstagedModifiedFiles.map((filePath) => ` - ${filePath}`),
"",
"That likely indicates changes made to the repository without",
"corresponding updates to templates in src/hydrate/creation.",
"",
"Please search for those file(s)' name(s) under src/hydrate for",
"the corresponding template and update those as well.",
].join("\n")
)
[
"",
"Oh no! Running the hydrate script modified some files:",
...unstagedModifiedFiles.map((filePath) => ` - ${filePath}`),
"",
"That likely indicates changes made to the repository without",
"corresponding updates to templates in src/hydrate/creation.",
"",
"Please search for those file(s)' name(s) under src/hydrate for",
"the corresponding template and update those as well.",
]
.map((line) => chalk.red(line))
.join("\n")
);
process.exitCode = 1;
}
6 changes: 3 additions & 3 deletions script/setup-test-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const owner = "RNR1";
const title = "New Title Test";
const repository = "new-repository-test";

const result =
await $`pnpm run setup --description ${description} --owner ${owner} --title ${title} --repository ${repository} --skip-api --skip-restore`;
console.log("Result from pnpm run setup:", result);
await $({
stdio: "inherit",
})`node ./lib/setup/index.js --description ${description} --owner ${owner} --title ${title} --repository ${repository} --skip-api --skip-restore`;

const newPackageJson = JSON.parse(
(await fs.readFile("./package.json")).toString()
Expand Down
2 changes: 1 addition & 1 deletion src/hydrate/creation/rootFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
skipLibCheck: true,
sourceMap: true,
strict: true,
target: "ES2021",
target: "ES2022",
},
include: ["src"],
}),
Expand Down
2 changes: 2 additions & 0 deletions src/hydrate/finalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe("finalize", () => {
"@types/eslint",
"@typescript-eslint/eslint-plugin",
"@typescript-eslint/parser",
"all-contributors-cli",
"cspell",
"eslint",
"eslint-config-prettier",
Expand Down Expand Up @@ -66,6 +67,7 @@ describe("finalize", () => {
"@types/eslint",
"@typescript-eslint/eslint-plugin",
"@typescript-eslint/parser",
"all-contributors-cli",
"cspell",
"eslint",
"eslint-config-prettier",
Expand Down
4 changes: 3 additions & 1 deletion src/hydrate/finalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export async function finalize({ releases, unitTests }: FinalizeOptions) {
"@types/eslint",
"@typescript-eslint/eslint-plugin",
"@typescript-eslint/parser",
"all-contributors-cli",
"cspell",
"eslint",
"eslint-config-prettier",
Expand Down Expand Up @@ -56,7 +57,8 @@ export async function finalize({ releases, unitTests }: FinalizeOptions) {

for (const command of [
`pnpm add ${devDependencies.join(" ")} -D`,
`all-contributors generate`,
`npx all-contributors generate`,
`pnpm uninstall all-contributors-cli -D`,
"pnpm run format:write",
]) {
console.log(chalk.gray(`$ ${command}`));
Expand Down
Loading