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

Add pre-merge GitHub Actions workflow #2

Merged
merged 5 commits into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .github/workflows/pre_merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Pre-Merge Checks

on:
push:
branches:
- develop
- releases/**
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch: # run on request (no need for PR)

# Declare default permissions as read only.
permissions: read-all

jobs:
Code-Quality-Checks:
# This is what will cancel the job concurrency
concurrency:
group: ${{ github.workflow }}-Linting-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.10"
- name: Install tox
run: python -m pip install tox==4.4.6
- name: Code quality checks
run: tox -vv -e pre-commit

Unit-Test:
runs-on: ubuntu-22.04
needs: Code-Quality-Checks
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.10"
tox-env: "py310"
- python-version: "3.11.8"
tox-env: "py311"
name: Unit-Test-${{ matrix.tox-env }}
# This is what will cancel the job concurrency
concurrency:
group: ${{ github.workflow }}-Unit-${{ github.event.pull_request.number || github.ref }}-${{ matrix.tox-env }}
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: python -m pip install tox==4.4.6
- name: Run unit test
run: tox -vv -e pytest-${{ matrix.tox-env }} -- tests/unit --csv=.tox/pytest-${{ matrix.tox-env }}/unit-test.csv
--cov=openvino_xai --cov-report term --cov-report xml:.tox/pytest-${{ matrix.tox-env }}/unit-test-coverage.xml
- name: Upload artifacts
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: unit-test-results-${{ matrix.tox-env }}
path: |
.tox/pytest-${{ matrix.tox-env }}/*.csv
.tox/pytest-${{ matrix.tox-env }}/*.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: .tox/pytest-${{ matrix.tox-env }}/unit-test-coverage.xml
flags: pytest-${{ matrix.tox-env }}

Integration-Test:
runs-on: ubuntu-22.04
needs: Unit-Test
name: Integration-Test
# This is what will cancel the job concurrency
concurrency:
group: ${{ github.workflow }}-Integration-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.10"
- name: Install tox
run: python -m pip install tox==4.4.6
- name: Run Integration Test
run: tox -vv -e pytest-py310 -- tests/integration --csv=.tox/pytest-py310/intg-test.csv
- name: Upload artifacts
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: intg-test-results
path: .tox/pytest-py310/*.csv
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ classifiers = [
dev = [
"pytest",
"pytest-cov",
"pytest-csv",
"pre-commit==3.7.0",
"addict",
]
22 changes: 22 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[tox]
isolated_build = true
skip_missing_interpreters = true

[testenv]
setenv =
TOX_WORK_DIR={toxworkdir}
passenv =
HTTP_PROXY
HTTPS_PROXY

[testenv:pre-commit]
deps =
pre-commit==3.7.0
skip_install = true
commands =
pre-commit run --all-files

[testenv:pytest-{py310, py311}]
extras = dev,dev_timm
commands =
pytest -ra --showlocals {posargs:tests/}