-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
4,972 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.