Skip to content

Commit 1eb1057

Browse files
author
Songki Choi
authoredJun 3, 2024··
Add pre-merge GitHub Actions workflow (#2)
* Add tox.ini w/ pre-commit & pytest env * Add pre-merge.yml for PR check * Add artifacts upload * Add enable codecov upload
1 parent 842eb21 commit 1eb1057

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed
 

‎.github/workflows/pre_merge.yml

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Pre-Merge Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- releases/**
8+
pull_request:
9+
types:
10+
- opened
11+
- reopened
12+
- synchronize
13+
workflow_dispatch: # run on request (no need for PR)
14+
15+
# Declare default permissions as read only.
16+
permissions: read-all
17+
18+
jobs:
19+
Code-Quality-Checks:
20+
# This is what will cancel the job concurrency
21+
concurrency:
22+
group: ${{ github.workflow }}-Linting-${{ github.event.pull_request.number || github.ref }}
23+
cancel-in-progress: true
24+
runs-on: ubuntu-22.04
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
28+
- name: Set up Python
29+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
30+
with:
31+
python-version: "3.10"
32+
- name: Install tox
33+
run: python -m pip install tox==4.4.6
34+
- name: Code quality checks
35+
run: tox -vv -e pre-commit
36+
37+
Unit-Test:
38+
runs-on: ubuntu-22.04
39+
needs: Code-Quality-Checks
40+
timeout-minutes: 120
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
include:
45+
- python-version: "3.10"
46+
tox-env: "py310"
47+
- python-version: "3.11.8"
48+
tox-env: "py311"
49+
name: Unit-Test-${{ matrix.tox-env }}
50+
# This is what will cancel the job concurrency
51+
concurrency:
52+
group: ${{ github.workflow }}-Unit-${{ github.event.pull_request.number || github.ref }}-${{ matrix.tox-env }}
53+
cancel-in-progress: true
54+
steps:
55+
- name: Checkout repository
56+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
57+
- name: Install Python
58+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
59+
with:
60+
python-version: ${{ matrix.python-version }}
61+
- name: Install tox
62+
run: python -m pip install tox==4.4.6
63+
- name: Run unit test
64+
run: tox -vv -e pytest-${{ matrix.tox-env }} -- tests/unit --csv=.tox/pytest-${{ matrix.tox-env }}/unit-test.csv
65+
--cov=openvino_xai --cov-report term --cov-report xml:.tox/pytest-${{ matrix.tox-env }}/unit-test-coverage.xml
66+
- name: Upload artifacts
67+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
68+
with:
69+
name: unit-test-results-${{ matrix.tox-env }}
70+
path: |
71+
.tox/pytest-${{ matrix.tox-env }}/*.csv
72+
.tox/pytest-${{ matrix.tox-env }}/*.xml
73+
# Use always() to always run this step to publish test results when there are test failures
74+
if: ${{ always() }}
75+
- name: Upload coverage reports to Codecov
76+
uses: codecov/codecov-action@v3
77+
with:
78+
files: .tox/pytest-${{ matrix.tox-env }}/unit-test-coverage.xml
79+
flags: pytest-${{ matrix.tox-env }}
80+
81+
Integration-Test:
82+
runs-on: ubuntu-22.04
83+
needs: Unit-Test
84+
name: Integration-Test
85+
# This is what will cancel the job concurrency
86+
concurrency:
87+
group: ${{ github.workflow }}-Integration-${{ github.event.pull_request.number || github.ref }}
88+
cancel-in-progress: true
89+
steps:
90+
- name: Checkout repository
91+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
92+
- name: Install Python
93+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
94+
with:
95+
python-version: "3.10"
96+
- name: Install tox
97+
run: python -m pip install tox==4.4.6
98+
- name: Run Integration Test
99+
run: tox -vv -e pytest-py310 -- tests/integration --csv=.tox/pytest-py310/intg-test.csv
100+
- name: Upload artifacts
101+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
102+
with:
103+
name: intg-test-results
104+
path: .tox/pytest-py310/*.csv
105+
# Use always() to always run this step to publish test results when there are test failures
106+
if: ${{ always() }}

‎pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ classifiers = [
3535
dev = [
3636
"pytest",
3737
"pytest-cov",
38+
"pytest-csv",
3839
"pre-commit==3.7.0",
3940
"addict",
4041
]

‎tox.ini

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[tox]
2+
isolated_build = true
3+
skip_missing_interpreters = true
4+
5+
[testenv]
6+
setenv =
7+
TOX_WORK_DIR={toxworkdir}
8+
passenv =
9+
HTTP_PROXY
10+
HTTPS_PROXY
11+
12+
[testenv:pre-commit]
13+
deps =
14+
pre-commit==3.7.0
15+
skip_install = true
16+
commands =
17+
pre-commit run --all-files
18+
19+
[testenv:pytest-{py310, py311}]
20+
extras = dev,dev_timm
21+
commands =
22+
pytest -ra --showlocals {posargs:tests/}

0 commit comments

Comments
 (0)