Unittests #2821
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
name: Unittests | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
schedule: | |
- cron: '0 4 * * *' | |
jobs: | |
# Special job which automatically cancels old runs for the same branch, prevents runs for the | |
# same file set which has already passed, etc. | |
pre_job: | |
if: github.ref_name != '_release_build' && vars.UNIT_TESTS_DISABLED != 'true' | |
name: Skip Duplicate Jobs Pre Job | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write # Needed for skip-duplicate-jobs job | |
contents: read | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@12aca0a884f6137d619d6a8a09fcc3406ced5281 # v4.0.0 | |
with: | |
cancel_others: 'true' | |
github_token: ${{ github.token }} | |
unittests: | |
name: Unittests - Python ${{ matrix.python-version }} - ${{ matrix.platform }} | |
runs-on: ${{ matrix.os }} | |
needs: pre_job | |
# NOTE: We always want to run job on master branch | |
if: (success() || failure()) && (${{ needs.pre_job.outputs.should_skip != 'true' || github.ref_name == 'master' }}) | |
timeout-minutes: 10 | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
os: | |
- ubuntu-20.04 | |
platform: | |
- ubuntu | |
include: | |
- os: windows-2022 | |
platform: windows | |
python-version: "3.10" | |
- os: macos-12 | |
platform: macos | |
python-version: "3.10" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
id: setup-python | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' # caching pip dependencies | |
cache-dependency-path: | | |
dev-requirements-new.txt | |
benchmarks/micro/requirements-compression-algorithms.txt | |
- name: Install tox | |
env: | |
TOX_VERSION: 3.20.1 | |
TOX_GH_ACTIONS_VERSION: 2.9.1 | |
run: | | |
python -m pip install --upgrade pip | |
pip install "tox==$TOX_VERSION" "tox-gh-actions==$TOX_GH_ACTIONS_VERSION" | |
- name: Run Unit Tests | |
run: tox | |
env: | |
PLATFORM: ${{ matrix.platform }} | |
KIND: unittests | |
- name: Upload pytest test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pytest-results-${{ matrix.python-version }}-${{ matrix.platform }} | |
path: | | |
test-results/junit*.xml | |
.coverage | |
if: ${{ success() || failure() }} | |
- name: Notify Slack on Failure | |
if: ${{ failure() && github.ref_name == 'master' }} | |
uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f # v2.0.0 | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
with: | |
status: ${{ job.status }} | |
steps: ${{ toJson(steps) }} | |
channel: '#eng-dataset-cloud-tech' | |
monitor-smoketests: | |
name: Monitor Smoketests - Python ${{ matrix.python-version }} | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 10 | |
needs: pre_job | |
# NOTE: We always want to run job on master branch | |
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref_name == 'master' }} | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- "3.8" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
id: setup-python | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' # caching pip dependencies | |
- name: Install tox | |
env: | |
TOX_VERSION: 3.20.1 | |
TOX_GH_ACTIONS_VERSION: 2.9.1 | |
run: | | |
python -m pip install --upgrade pip | |
pip install "tox==$TOX_VERSION" "tox-gh-actions==$TOX_GH_ACTIONS_VERSION" | |
- name: Run Monitor Smoketests | |
run: | | |
rm -rf artifacts test-results .coverage | |
mkdir -p artifacts test-results | |
tox -e agent_monitors_ubuntu -- --artifacts-path artifacts -n 2 --junitxml=test-results/junit-1.xml | |
env: | |
SCALYR_API_KEY: ${{ secrets.CT_SCALYR_TOKEN_PROD_US_CLOUDTECH_TESTING_WRITE }} | |
READ_API_KEY: ${{ secrets.CT_SCALYR_TOKEN_PROD_US_CLOUDTECH_TESTING_READ }} | |
SCALYR_SERVER: https://agent.scalyr.com | |
AGENT_HOST_NAME: monitors-test-${{ github.run_number }} | |
- name: Upload pytest test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pytest-results-${{ matrix.python-version }}-monitor-smoketests | |
path: | | |
.coverage | |
test-results/junit*.xml | |
artifacts | |
if: ${{ success() || failure() }} | |
- name: Notify Slack on Failure | |
if: ${{ failure() && github.ref_name == 'master' }} | |
uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f # v2.0.0 | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
with: | |
status: ${{ job.status }} | |
steps: ${{ toJson(steps) }} | |
channel: '#eng-dataset-cloud-tech' | |
# Runs agent from it source and performs some basic sanity checks. | |
agent-source-tests: | |
name: Python ${{ matrix.python-version }} ${{ matrix.platform }} Agent Source End to End Test | |
runs-on: ${{ matrix.os }} | |
needs: pre_job | |
# NOTE: We always want to run job on master branch | |
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref_name == 'master' }} | |
container: ${{ matrix.container }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
os: | |
- ubuntu-20.04 | |
platform: | |
- ubuntu | |
include: | |
- os: macos-12 | |
platform: macos | |
python-version: "3.10" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
id: setup-python | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' # caching pip dependencies | |
cache-dependency-path: | | |
dev-requirements-new.txt | |
benchmarks/micro/requirements-compression-algorithms.txt | |
- name: Install tox | |
env: | |
TOX_VERSION: 3.20.1 | |
TOX_GH_ACTIONS_VERSION: 2.9.1 | |
run: | | |
python -m pip install --upgrade pip | |
pip install "tox==$TOX_VERSION" "tox-gh-actions==$TOX_GH_ACTIONS_VERSION" | |
- name: Run End to End Tests | |
run: tox | |
env: | |
SCALYR_API_KEY: ${{ secrets.CT_SCALYR_TOKEN_PROD_US_CLOUDTECH_TESTING_WRITE }} | |
READ_API_KEY: ${{ secrets.CT_SCALYR_TOKEN_PROD_US_CLOUDTECH_TESTING_READ }} | |
TEST_SESSION_SUFFIX: ${{ matrix.python-version }}-${{ matrix.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
KIND: end2end | |
- name: Upload pytest test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pytest-results-${{ matrix.python-version }}-${{ matrix.variant }} | |
path: | | |
test-results/junit*.xml | |
if: ${{ success() || failure() }} | |
publish-test-results: | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write # Needed for publish test results job | |
pull-requests: write # Needed for publish test results job | |
if: success() || failure() | |
needs: | |
- pre_job | |
- unittests | |
- monitor-smoketests | |
steps: | |
- name: Download test results | |
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3 | |
with: | |
path: reports | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action@283dea176069279a9076e77b548668a8e4f0c31b # pin@v2 | |
with: | |
junit_files: "reports/**/junit*.xml" |