Check added to ensure added/modified files have tests
Sometimes developers forget to write tests, which neglects the code quality.
It's fine, we only need a gentle reminder. This GitHub Action is checking that every added/modified code file also has a test.
Example: if foo.ts
file is added/modified - foo.test.ts
is also expected.
That should encourage developers to submit changes along with tests.
The GH action is made as simple as possible, so that it may lack some setup flexibility.
For example, if you want to target multiple file extensions, you will need to add separate actions per extension.
Required The code file path prefix to check. Example: src/
Required The code file path suffix (aka extension) to check. Example: .ts
Required The test file path prefix to check. Example: tests/
Required The test file path suffix to check. Example: .test.ts
The message in case test was not found. Example: :file does not have a corresponding :test test file
Access token to authenticate on behalf of the GitHub App
Repository name, in case you need to override it.
Repository owner, in case you need to override it.
Pull request number to check, in case you need to override it.
Option 1: Directory structure when having separate folders for source and tests:
|-- src/
| |-- item.ts
| `-- util/
| `-- helper.ts
`-- test/
|-- item.test.ts
`-- util/
`-- helper.test.ts
Workflow:
uses: mrded/gh-tests-existence-check@main
with:
target-file-path-prefix: src/
target-file-path-suffix: .ts
test-file-path-prefix: test/
test-file-path-suffix: .test.ts
Option 2: Directory structure when having both types of files in the same directory:
`-- src/
|-- item.ts
|-- item.test.ts
`-- util/
|-- helper.ts
`-- helper.test.ts
Workflow:
uses: mrded/gh-tests-existence-check@main
with:
target-file-path-prefix: src/
target-file-path-suffix: .ts
test-file-path-prefix: src/
test-file-path-suffix: .test.ts