Skip to content

Commit 2703c91

Browse files
authored
Merge pull request #15 from maks-rafalko/feature/readme
Update readme with the usage information
2 parents 9bb470f + 112251f commit 2703c91

File tree

1 file changed

+43
-58
lines changed

1 file changed

+43
-58
lines changed

README.md

Lines changed: 43 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,76 @@
1-
<p align="center">
2-
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a>
3-
</p>
1+
# Tests Checker Action
42

5-
# Create a JavaScript Action using TypeScript
3+
This GitHub Action requires writing the tests in Pull Requests, by requesting changes and posting a comment if tests are missing.
64

7-
Use this template to bootstrap the creation of a TypeScript action.:rocket:
5+
To install it, copy and paste the following snippet into your `.github/workflows/*.yml` file.
86

9-
This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance.
7+
```yaml
8+
- name: Require tests if source code is changed
9+
uses: infection/tests-checker-action@v1
10+
with:
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
```
13+
14+
<img width="990" alt="tests-checker" src="https://user-images.githubusercontent.com/3725595/45590526-b7f3fa00-b942-11e8-972d-143c0b367017.png">
1015
11-
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
16+
## Settings
1217
13-
## Create an action from this template
18+
Default values are:
1419
15-
Click the `Use this Template` and provide the new repo details for your action
20+
```yaml
21+
comment: 'Could you please add tests to make sure this change works as expected?',
22+
fileExtensions: '.php,.ts,.js,.c,.cs,.cpp,.rb,.java'
23+
testDir: 'tests'
24+
testPattern: ''
25+
```
26+
where
1627
17-
## Code in Main
28+
* `comment` - a text that bot will post when it won't find tests in the PR
29+
* `fileExtensions` - extensions of the files that should be treated as a `source code`. Bot will do nothing if you just updating `README.md` because usually no tests are required to cover such change.
30+
* `testDir` - folder, where tests are located. Make sure to set it correctly, otherwise bot will not be able to understand whether the test file was added or not.
31+
* `testPattern` - a shell glob pattern that should match test files. For example, you can set it to `testPattern: *_test.go` and Bot will be able to understand, that added test has this pattern instead of located in `testDir`. `testDir` and `testPattern` are alternatives, however can be used together.
32+
33+
Both `testDir` and `testPattern` may be specified in a custom configuration, both settings will be used to locate test files.
34+
If you want to change any of the settings, just add `.github/tests_checker.yml`:
35+
36+
How to override? You can configure the action by overriding any of the settings listed below
37+
38+
```yaml
39+
- name: Require tests if source code is changed
40+
uses: infection/tests-checker-action@v1
41+
with:
42+
fileExtensions: '.ts,.js'
43+
testDir: '__tests__'
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
```
46+
47+
## Developing and contributing
1848

1949
> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance.
2050

2151
Install the dependencies
52+
2253
```bash
2354
$ npm install
2455
```
2556

2657
Build the typescript and package it for distribution
58+
2759
```bash
2860
$ npm run build && npm run package
2961
```
3062

3163
Run the tests :heavy_check_mark:
64+
3265
```bash
3366
$ npm test
3467
3568
PASS ./index.test.js
36-
✓ throws invalid number (3ms)
37-
wait 500 ms (504ms)
3869
✓ test runs (95ms)
3970
4071
...
4172
```
4273

43-
## Change action.yml
44-
45-
The action.yml defines the inputs and output for your action.
46-
47-
Update the action.yml with your name, description, inputs and outputs for your action.
48-
49-
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
50-
51-
## Change the Code
52-
53-
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
54-
55-
```javascript
56-
import * as core from '@actions/core';
57-
...
58-
59-
async function run() {
60-
try {
61-
...
62-
}
63-
catch (error) {
64-
core.setFailed(error.message);
65-
}
66-
}
67-
68-
run()
69-
```
70-
71-
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
72-
7374
## Publish to a distribution branch
7475

7576
Actions are run from GitHub repos so we will checkin the packed dist folder.
@@ -87,19 +88,3 @@ Note: We recommend using the `--license` option for ncc, which will create a lic
8788
Your action is now published! :rocket:
8889

8990
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
90-
91-
## Validate
92-
93-
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml))
94-
95-
```yaml
96-
uses: ./
97-
with:
98-
milliseconds: 1000
99-
```
100-
101-
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket:
102-
103-
## Usage:
104-
105-
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action

0 commit comments

Comments
 (0)