forked from openvinotoolkit/anomalib
-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (74 loc) · 2.58 KB
/
pre_merge.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Pre-Merge Checks
on:
push:
branches: [main]
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch: # run on request (no need for PR)
# This is what will cancel the workflow concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
Code-Quality-Checks:
runs-on: [self-hosted, linux, x64]
steps:
- name: CHECKOUT REPOSITORY
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Tox
run: pip install tox
- name: Code quality checks
run: tox -e pre-commit
Pre-Merge-Checks:
runs-on: [self-hosted, linux, x64]
needs: Code-Quality-Checks
if: github.event.pull_request.draft == false
strategy:
max-parallel: 1
matrix:
include:
- python-version: "3.10"
tox-env: "py310"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Tox
run: pip install tox
- name: Link the dataset path to the dataset directory in the repository root.
run: |
ln -s $ANOMALIB_DATASET_PATH ./datasets
ln -s $ANOMALIB_DATASET_PATH ./notebooks/datasets
- name: Coverage
run: tox -e pre-merge-${{ matrix.tox-env }}
- name: Upload coverage report
run: |
# If the workflow is triggered from PR then it gets the commit id from the PR.
# else it uses the commit id of the latest commit. This is because the commit
# of the checked-out branch/commit does not exist in the tree as it is grafted.
if [ -n "${{ github.event.pull_request.head.sha }}" ]
then
COMMIT_ID=${{ github.event.pull_request.head.sha }}
else
COMMIT_ID=${{ github.sha }}
fi
# Pass token from secrets if available. Otherwise it takes it from the environment variable of the CI
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
if [ -n "${{ secrets.CODECOV_TOKEN }}" ]
then
./codecov -t ${{ secrets.CODECOV_TOKEN }} --sha $COMMIT_ID -U $HTTP_PROXY -f .tox/coverage.xml
else
./codecov -t "${CODECOV_TOKEN}" --sha $COMMIT_ID -U $HTTP_PROXY -f .tox/coverage.xml
fi