Skip to content

Add unit+integration+graph tests Github action #163

Add unit+integration+graph tests Github action

Add unit+integration+graph tests Github action #163

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
branches:
- "**"
concurrency:
group: tests-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
unit-tests:
name: Unit Tests / Python ${{ matrix.python-version }} (${{ matrix.group }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
group: [ 1, 2, 3, 4, 5 ]
fail-fast: false
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Python ${{ matrix.python-version }} (${{ matrix.group }}) - Setup Environment
uses: ./.github/actions/setup_environment
with:
python-version: ${{ matrix.python-version }}
- name: Run Unit Tests
run: |
source "$(poetry env info --path)/bin/activate"
# Due to race conditions in the tests bringing up and down the node server, have the server available
# For all the tests.
node demisto_sdk/commands/common/markdown_server/mdx-parse-server.js &
node_pid=$!
# poetry run pytest --ignore={demisto_sdk/commands/init/templates,demisto_sdk/tests/integration_tests,demisto_sdk/commands/content_graph} --store-durations --junitxml=test-results/junit.xml || pytest_exit_code=$
# mv .test_durations test-results/test_durations
mkdir unit-tests
poetry run pytest -v --ignore={demisto_sdk/commands/init/templates,demisto_sdk/tests/integration_tests,demisto_sdk/commands/content_graph} --cov=demisto_sdk --cov-report=html:unit-tests/coverage --junitxml=unit-tests/junit.xml --splits 5 --group ${{ matrix.group }} || pytest_exit_code=$?
echo "PYTEST_EXIT_CODE=$pytest_exit_code" >> $GITHUB_ENV
kill $node_pid
- name: Python ${{ matrix.python-version }} (${{ matrix.group }}) - Test Summary Upload
uses: ./.github/actions/test_summary_upload
with:
python-version: ${{ matrix.python-version }}
artifacts_folder_name: unit-tests
group: ${{ matrix.group }}
integration-tests:
name: Integration Tests / Python ${{ matrix.python-version }} (All-Tests)
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
fail-fast: false
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Python ${{ matrix.python-version }} - Setup Environment
uses: ./.github/actions/setup_environment
with:
python-version: ${{ matrix.python-version }}
- name: Run Integration Tests
run: |
source "$(poetry env info --path)/bin/activate"
mkdir integration-tests
poetry run pytest -v demisto_sdk/tests/integration_tests --cov=demisto_sdk --cov-report=html:integration-tests/coverage --junitxml=integration-tests/junit.xml || pytest_exit_code=$?
echo "PYTEST_EXIT_CODE=$pytest_exit_code" >> $GITHUB_ENV
exit $pytest_exit_code
- name: Python ${{ matrix.python-version }} - Test Summary Upload
uses: ./.github/actions/test_summary_upload
with:
python-version: ${{ matrix.python-version }}
artifacts_folder_name: integration-tests
graph-tests:
name: Graph Tests / Python ${{ matrix.python-version }} (All-Tests)
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
fail-fast: false
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Python ${{ matrix.python-version }} - Setup Environment
uses: ./.github/actions/setup_environment
with:
python-version: ${{ matrix.python-version }}
- name: Run Graph Tests
run: |
source "$(poetry env info --path)/bin/activate"
mkdir graph-tests
poetry run pytest -v demisto_sdk/commands/content_graph --cov=demisto_sdk --cov-report=html:graph-tests/coverage --junitxml=graph-tests/junit.xml || pytest_exit_code=$?
echo "PYTEST_EXIT_CODE=$pytest_exit_code" >> $GITHUB_ENV
- name: Python ${{ matrix.python-version }} - Test Summary Upload
uses: ./.github/actions/test_summary_upload
with:
python-version: ${{ matrix.python-version }}
artifacts_folder_name: graph-tests
coverage:
needs: [unit-tests, integration-tests, graph-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Run coverage
run: |
pip install coverage
coverage combine **/.coverage
coverage report
coverage xml
- name: Coveralls
uses: coverallsapp/github-action@v2