Skip to content

Commit

Permalink
chore: move e2e migration scripts into ci.yml (#1733)
Browse files Browse the repository at this point in the history
## PR Checklist

- [x] Addresses an existing open issue: fixes #1711
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

💖
  • Loading branch information
JoshuaKGoldberg authored Dec 3, 2024
1 parent 2cec803 commit 1094f0f
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ That end-to-end test executes `script/create-test-e2e.ts`, which:
2. Asserts that commands such as `build` and `lint` each pass

The `pnpm run test:create` script is run in CI to ensure that templating changes are in sync with the template's actual files.
See `.github/workflows/test-create.yml`.
See `.github/workflows/ci.yml`'s `test_creation_script` job.

### The Initialization Script

Expand Down Expand Up @@ -184,7 +184,7 @@ That end-to-end test executes `script/initialize-test-e2e.ts`, which:
5. Runs initialization a second time, capturing test coverage

The `pnpm run test:initialize` script is run in CI to ensure that templating changes are in sync with the template's actual files.
See `.github/workflows/test-initialize.yml`.
See `.github/workflows/ci.yml`'s `test_initialization_script` job.

### The Migration Script

Expand Down Expand Up @@ -228,7 +228,7 @@ That end-to-end test executes `script/migrate-test-e2e.ts`, which:
3. Checks that the local repository's files were changed correctly (e.g. removed initialization-only files)

The `pnpm run test:migrate` script is run in CI to ensure that templating changes are in sync with the template's actual files.
See `.github/workflows/test-migrate.yml`.
See `.github/workflows/ci.yml`'s `test_migration_script` job.

> Tip: if the migration test is failing in CI and you don't see any errors, try [downloading the full logs](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/using-workflow-run-logs#downloading-logs).
Expand Down
42 changes: 41 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,49 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run test --coverage
- uses: codecov/codecov-action@v3
- if: always()
uses: codecov/codecov-action@v3
with:
flags: unit
test_creation_script:
name: Test Creation Script
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: ./.github/actions/prepare
- run: pnpm run build
- run: pnpm run test:create
- if: always()
uses: codecov/codecov-action@v3
with:
files: coverage-create/lcov.info
flags: create
test_initialization_script:
name: Test Initialization Script
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: ./.github/actions/prepare
- run: pnpm run build
- run: pnpm run test:initialize
- if: always()
uses: codecov/codecov-action@v3
with:
files: coverage-initialize/lcov.info
flags: initialize
test_migration_script:
name: Test Migration Script
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: ./.github/actions/prepare
- run: pnpm run build
- run: pnpm run test:migrate
- if: always()
uses: codecov/codecov-action@v3
with:
files: coverage-migrate/lcov.info
flags: migrate
type_check:
name: Type Check
runs-on: ubuntu-latest
Expand Down
43 changes: 41 additions & 2 deletions script/__snapshots__/migrate-test-e2e.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,50 @@ exports[`expected file changes > .github/workflows/ci.yml 1`] = `
name: Build
runs-on: ubuntu-latest
@@ ... @@ jobs:
- uses: ./.github/actions/prepare
- run: pnpm run test --coverage
- uses: codecov/codecov-action@v3
- if: always()
uses: codecov/codecov-action@v3
- with:
- flags: unit
- test_creation_script:
- name: Test Creation Script
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- - uses: ./.github/actions/prepare
- - run: pnpm run build
- - run: pnpm run test:create
- - if: always()
- uses: codecov/codecov-action@v3
- with:
- files: coverage-create/lcov.info
- flags: create
- test_initialization_script:
- name: Test Initialization Script
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- - uses: ./.github/actions/prepare
- - run: pnpm run build
- - run: pnpm run test:initialize
- - if: always()
- uses: codecov/codecov-action@v3
- with:
- files: coverage-initialize/lcov.info
- flags: initialize
- test_migration_script:
- name: Test Migration Script
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- - uses: ./.github/actions/prepare
- - run: pnpm run build
- - run: pnpm run test:migrate
- - if: always()
- uses: codecov/codecov-action@v3
- with:
- files: coverage-migrate/lcov.info
- flags: migrate
type_check:
name: Type Check
runs-on: ubuntu-latest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export interface MultiWorkflowJobOptions {
steps: MultiWorkflowJobStep[];
}

export type MultiWorkflowJobStep = { run: string } | { uses: string };
export type MultiWorkflowJobStep = { if?: string } & (
| { run: string }
| { uses: string }
);

export function createMultiWorkflowFile({
jobs,
Expand Down
3 changes: 2 additions & 1 deletion src/steps/writing/creation/dotGitHub/createWorkflows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ describe("createWorkflows", () => {
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run test --coverage
- uses: codecov/codecov-action@v3
- if: always()
uses: codecov/codecov-action@v3
type_check:
name: Type Check
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion src/steps/writing/creation/dotGitHub/createWorkflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function createWorkflows(options: Options) {
name: "Test",
steps: [
{ run: "pnpm run test --coverage" },
{ uses: "codecov/codecov-action@v3" },
{ if: "always()", uses: "codecov/codecov-action@v3" },
],
},
]),
Expand Down

0 comments on commit 1094f0f

Please sign in to comment.