Skip to content

Commit a25f198

Browse files
authored
Setup tests (#87)
* test: move timeout tests to their own job to speed things up slightly * test: add comment about timeout tests * test: fix needs in cd job * test: add jest configuration and first test * test: setup codecov to track coverage
1 parent 0f986c4 commit a25f198

File tree

6 files changed

+15393
-7719
lines changed

6 files changed

+15393
-7719
lines changed

.config/jest.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
clearMocks: true,
3+
moduleFileExtensions: ['js', 'ts'],
4+
rootDir: '..',
5+
testEnvironment: 'node',
6+
testMatch: ['<rootDir>/src/**/*.test.ts'],
7+
transform: {
8+
'^.+\\.ts$': 'ts-jest',
9+
},
10+
verbose: true,
11+
collectCoverage: true,
12+
collectCoverageFrom: ['src/**/*.{js,ts,jsx,tsx}'],
13+
};

.github/codecov.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# see https://docs.codecov.com/docs/codecovyml-reference
2+
codecov:
3+
require_ci_to_pass: false
4+
comment:
5+
layout: 'diff, flags'
6+
behavior: default
7+
require_changes: true

.github/workflows/ci_cd.yml

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,30 @@ on:
44

55
jobs:
66
# runs on branch pushes only
7-
ci:
8-
name: Run Tests
7+
ci_unuit:
8+
name: Run Unit Tests
99
if: startsWith(github.ref, 'refs/heads')
10-
runs-on: ubuntu-18.04
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: 16
18+
- name: Install dependencies
19+
run: npm ci
20+
- name: Run Unit Tests
21+
run: npm test
22+
- uses: codecov/codecov-action@v3
23+
with:
24+
directory: ./coverage/
25+
verbose: true
26+
27+
ci_integration:
28+
name: Run Integration Tests
29+
if: startsWith(github.ref, 'refs/heads')
30+
runs-on: ubuntu-latest
1131
steps:
1232
- name: Checkout
1333
uses: actions/checkout@v2
@@ -220,7 +240,39 @@ jobs:
220240
expected: 2
221241
actual: ${{ steps.retry_on_error.outputs.exit_code }}
222242

223-
# timeout tests (takes longer to run so run last)
243+
- name: sad-path (wrong shell for OS)
244+
id: wrong_shell
245+
uses: ./
246+
continue-on-error: true
247+
with:
248+
timeout_minutes: 1
249+
max_attempts: 2
250+
shell: cmd
251+
command: 'dir'
252+
- uses: nick-invision/assert-action@v1
253+
with:
254+
expected: 2
255+
actual: ${{ steps.wrong_shell.outputs.total_attempts }}
256+
- uses: nick-invision/assert-action@v1
257+
with:
258+
expected: failure
259+
actual: ${{ steps.wrong_shell.outcome }}
260+
261+
# timeout tests take longer to run so run in parallel
262+
ci_integration_timeout:
263+
name: Run Integration Timeout Tests
264+
if: startsWith(github.ref, 'refs/heads')
265+
runs-on: ubuntu-latest
266+
steps:
267+
- name: Checkout
268+
uses: actions/checkout@v2
269+
- name: Setup Node.js
270+
uses: actions/setup-node@v1
271+
with:
272+
node-version: 16
273+
- name: Install dependencies
274+
run: npm ci
275+
224276
- name: sad-path (timeout)
225277
id: sad_path_timeout
226278
uses: ./
@@ -295,24 +347,6 @@ jobs:
295347
expected: failure
296348
actual: ${{ steps.sad_path_timeout.outcome }}
297349

298-
- name: sad-path (wrong shell for OS)
299-
id: wrong_shell
300-
uses: ./
301-
continue-on-error: true
302-
with:
303-
timeout_minutes: 1
304-
max_attempts: 2
305-
shell: cmd
306-
command: 'dir'
307-
- uses: nick-invision/assert-action@v1
308-
with:
309-
expected: 2
310-
actual: ${{ steps.wrong_shell.outputs.total_attempts }}
311-
- uses: nick-invision/assert-action@v1
312-
with:
313-
expected: failure
314-
actual: ${{ steps.wrong_shell.outcome }}
315-
316350
ci_windows:
317351
name: Run Windows Tests
318352
if: startsWith(github.ref, 'refs/heads')
@@ -368,9 +402,9 @@ jobs:
368402
# runs on push to master only
369403
cd:
370404
name: Publish Action
371-
needs: ci
405+
needs: [ci_integration, ci_integration_timeout, ci_windows]
372406
if: github.ref == 'refs/heads/master'
373-
runs-on: ubuntu-18.04
407+
runs-on: ubuntu-latest
374408
steps:
375409
- name: Checkout
376410
uses: actions/checkout@v2

0 commit comments

Comments
 (0)