Skip to content
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

Setup tests #87

Merged
merged 5 commits into from Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions .config/jest.config.js
@@ -0,0 +1,13 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
rootDir: '..',
testEnvironment: 'node',
testMatch: ['<rootDir>/src/**/*.test.ts'],
transform: {
'^.+\\.ts$': 'ts-jest',
},
verbose: true,
collectCoverage: true,
collectCoverageFrom: ['src/**/*.{js,ts,jsx,tsx}'],
};
7 changes: 7 additions & 0 deletions .github/codecov.yml
@@ -0,0 +1,7 @@
# see https://docs.codecov.com/docs/codecovyml-reference
codecov:
require_ci_to_pass: false
comment:
layout: 'diff, flags'
behavior: default
require_changes: true
82 changes: 58 additions & 24 deletions .github/workflows/ci_cd.yml
Expand Up @@ -4,10 +4,30 @@ on:

jobs:
# runs on branch pushes only
ci:
name: Run Tests
ci_unuit:
name: Run Unit Tests
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Run Unit Tests
run: npm test
- uses: codecov/codecov-action@v3
with:
directory: ./coverage/
verbose: true

ci_integration:
name: Run Integration Tests
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -220,7 +240,39 @@ jobs:
expected: 2
actual: ${{ steps.retry_on_error.outputs.exit_code }}

# timeout tests (takes longer to run so run last)
- name: sad-path (wrong shell for OS)
id: wrong_shell
uses: ./
continue-on-error: true
with:
timeout_minutes: 1
max_attempts: 2
shell: cmd
command: 'dir'
- uses: nick-invision/assert-action@v1
with:
expected: 2
actual: ${{ steps.wrong_shell.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1
with:
expected: failure
actual: ${{ steps.wrong_shell.outcome }}

# timeout tests take longer to run so run in parallel
ci_integration_timeout:
name: Run Integration Timeout Tests
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install dependencies
run: npm ci

- name: sad-path (timeout)
id: sad_path_timeout
uses: ./
Expand Down Expand Up @@ -295,24 +347,6 @@ jobs:
expected: failure
actual: ${{ steps.sad_path_timeout.outcome }}

- name: sad-path (wrong shell for OS)
id: wrong_shell
uses: ./
continue-on-error: true
with:
timeout_minutes: 1
max_attempts: 2
shell: cmd
command: 'dir'
- uses: nick-invision/assert-action@v1
with:
expected: 2
actual: ${{ steps.wrong_shell.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1
with:
expected: failure
actual: ${{ steps.wrong_shell.outcome }}

ci_windows:
name: Run Windows Tests
if: startsWith(github.ref, 'refs/heads')
Expand Down Expand Up @@ -368,9 +402,9 @@ jobs:
# runs on push to master only
cd:
name: Publish Action
needs: ci
needs: [ci_integration, ci_integration_timeout, ci_windows]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down