Skip to content

Commit

Permalink
Merge 40b0d7d into c34587a
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyAfik committed Dec 21, 2023
2 parents c34587a + 40b0d7d commit 26f3df3
Show file tree
Hide file tree
Showing 21 changed files with 4,972 additions and 33 deletions.
42 changes: 42 additions & 0 deletions .github/actions/setup_environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Setup environment for demisto-sdk'
description: 'Setup environment for every demisto-sdk workflow job'
author: 'Demisto-SDK'

inputs:
python-version:
required: true
type: string
description: "The python version"
node-version:
required: false
type: string
default: "16"
description: "The node version to install"


runs:
using: 'composite'
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Setup Poetry
run: |
sudo curl -sSL https://install.python-poetry.org | python3 -
poetry --version
poetry check --lock
poetry install -E generate-unit-tests
shell: bash

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}

- name: Install npm
run: |
npm install
echo $(echo '{"node_version": "'$(node --version)'","npm_list":'$(npm list --json)'}') > node_versions_info.json
shell: bash
55 changes: 55 additions & 0 deletions .github/actions/test_summary_upload/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'Test Summary Upload'
description: 'Prints out a summary for all the tests of the demisto-sdk'
author: 'Demisto-SDK'

inputs:
python-version:
required: true
type: string
description: "The python version"
artifacts_folder_name:
required: false
type: string
description: "The folder name to save artifacts"
group:
required: false
type: string
default: "All-Tests"
description: "The group of the pytest-split"
summary-display-options:
required: false
type: string
description: "The test-summary display options"
default: fsEX # show all failed and skipped tests


runs:
using: 'composite'
steps:
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifacts_folder_name }}-artifacts-python(${{ inputs.python-version }})-group(${{ inputs.group }})
path: |
${{ inputs.artifacts_folder_name }}
node_versions_info.json
.coverage
- name: Print Summary of pytest results in workflow summary
if: always()
uses: pmeier/pytest-results-action@main
with:
path: ${{ inputs.artifacts_folder_name }}/junit.xml
summary: true
display-options: ${{ inputs.summary-display-options }}
fail-on-empty: true
- name: Check if ${{ inputs.artifacts_folder_name }} have passed
shell: bash
if: always()
run: |
if [[ "$PYTEST_EXIT_CODE" -ne 0 ]]; then
echo "There are ${{ inputs.artifacts_folder_name }} that failed, pytest finished with exit code $PYTEST_EXIT_CODE, to see the ${{ inputs.artifacts_folder_name }} summary refer to https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}"
else
echo "All ${{ inputs.artifacts_folder_name }} have passed, congratulations!"
fi
exit $PYTEST_EXIT_CODE
149 changes: 149 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: CI - On Push

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=$!
mkdir unit-tests
poetry run pytest -v . --ignore={demisto_sdk/commands/init/templates,demisto_sdk/tests/integration_tests,demisto_sdk/commands/content_graph,tests_end_to_end} --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
64 changes: 64 additions & 0 deletions .github/workflows/update-test-durations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Update .test-durations file

on:
# schedule:
# - cron: "0 8 * * 0" # Run every two weeks on Sunday at 8 AM UTC
push:
branches:
- master
pull_request:
branches:
- "**"


jobs:
update-test-durations:
name: Update .test-durations file
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10" ]
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=$!
mkdir unit-tests
poetry run pytest . --ignore={demisto_sdk/commands/init/templates,demisto_sdk/tests/integration_tests,demisto_sdk/commands/content_graph,tests_end_to_end} --store-durations --junitxml=unit-tests/junit.xml || pytest_exit_code=$
echo "PYTEST_EXIT_CODE=$pytest_exit_code" >> $GITHUB_ENV
kill $node_pid
- name: Update .test-durations
run: |
git status
git add .test_durations
git status
git commit -m "Update .test-durations" || true
git push origin HEAD:refs/heads/update-test-durations
- name: Create Draft PR
run: |
gh pr create --base master --head update-test-durations --title "Update .test-durations" --body "This PR updates the .test-durations file." --draft --reviewer GuyAfik
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- 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
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ repos:
- cachetools==5.3.0 ; python_version >= "3.8" and python_version < "3.11"
- certifi==2022.12.7 ; python_version >= "3.8" and python_version < "3.11"
- cffi==1.15.1 ; python_version >= "3.8" and python_version < "3.11"
- cfgv==3.3.1 ; python_version >= "3.8" and python_version < "3.11"
- chardet==5.1.0 ; python_version >= "3.8" and python_version < "3.11"
- charset-normalizer==3.1.0 ; python_version >= "3.8" and python_version < "3.11"
- click==8.1.3 ; python_version >= "3.8" and python_version < "3.11"
Expand All @@ -51,9 +52,11 @@ repos:
- demisto-py==3.2.10 ; python_version >= "3.8" and python_version < "3.11"
- dictdiffer==0.9.0 ; python_version >= "3.8" and python_version < "3.11"
- dictor==0.1.11 ; python_version >= "3.8" and python_version < "3.11"
- distlib==0.3.6 ; python_version >= "3.8" and python_version < "3.11"
- docker==5.0.3 ; python_version >= "3.8" and python_version < "3.11"
- docopt==0.6.2 ; python_version >= "3.8" and python_version < "3.11"
- exceptiongroup==1.1.1 ; python_version >= "3.8" and python_version < "3.11"
- filelock==3.12.0 ; python_version >= "3.8" and python_version < "3.11"
- flatten-dict==0.4.2 ; python_version >= "3.8" and python_version < "3.11"
- freezegun==1.2.2 ; python_version >= "3.8" and python_version < "3.11"
- future==0.18.3 ; python_version >= "3.8" and python_version < "3.11"
Expand All @@ -74,6 +77,7 @@ repos:
- grpcio-status==1.48.2 ; python_version >= "3.8" and python_version < "3.11"
- grpcio==1.59.2 ; python_version >= "3.8" and python_version < "3.11"
- humanfriendly==10.0 ; python_version >= "3.8" and python_version < "3.11"
- identify==2.5.24 ; python_version >= "3.8" and python_version < "3.11"
- idna==3.4 ; python_version >= "3.8" and python_version < "3.11"
- imagesize==1.4.1 ; python_version >= "3.8" and python_version < "3.11"
- importlib-resources==5.12.0 ; python_version >= "3.8" and python_version < "3.11"
Expand All @@ -93,6 +97,7 @@ repos:
- neo4j==5.14.1 ; python_version >= "3.8" and python_version < "3.11"
- networkx==2.8.8 ; python_version >= "3.8" and python_version < "3.11"
- nltk==3.8.1 ; python_version >= "3.8" and python_version < "3.11"
- nodeenv==1.7.0 ; python_version >= "3.8" and python_version < "3.11"
- ordered-set==4.1.0 ; python_version >= "3.8" and python_version < "3.11"
- orjson==3.8.11 ; python_version >= "3.8" and python_version < "3.11"
- packaging==23.1 ; python_version >= "3.8" and python_version < "3.11"
Expand All @@ -102,6 +107,7 @@ repos:
- pkgutil-resolve-name==1.3.10 ; python_version >= "3.8" and python_version < "3.9"
- platformdirs==3.5.0 ; python_version >= "3.8" and python_version < "3.11"
- pluggy==1.0.0 ; python_version >= "3.8" and python_version < "3.11"
- pre-commit==3.5.0 ; python_version >= "3.8" and python_version < "3.11"
- prettytable==3.7.0 ; python_version >= "3.8" and python_version < "3.11"
- proto-plus==1.22.3 ; python_version >= "3.8" and python_version < "3.11"
- protobuf==3.19.6 ; python_version >= "3.8" and python_version < "3.11"
Expand Down Expand Up @@ -176,6 +182,7 @@ repos:
- tzlocal==4.3 ; python_version >= "3.8" and python_version < "3.11"
- ujson==5.7.0 ; python_version >= "3.8" and python_version < "3.11"
- urllib3==1.26.15 ; python_version >= "3.8" and python_version < "3.11"
- virtualenv==20.23.0 ; python_version >= "3.8" and python_version < "3.11"
- vulture==2.7 ; python_version >= "3.8" and python_version < "3.11"
- wcmatch==8.4.1 ; python_version >= "3.8" and python_version < "3.11"
- wcwidth==0.2.6 ; python_version >= "3.8" and python_version < "3.11"
Expand Down

0 comments on commit 26f3df3

Please sign in to comment.