forked from demisto/content
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (102 loc) · 3.67 KB
/
pre-commit-reuse.yml
File metadata and controls
118 lines (102 loc) · 3.67 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: pre-commit
on:
workflow_call:
jobs:
pre-commit:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
contents: write
steps:
- name: Install poetry
uses: Gr1N/setup-poetry@v9
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set PYTHONPATH
run: echo "PYTHONPATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'poetry'
- name: Install dependencies
run: poetry install
- name: Cache Pre commit
id: cache-pre-commit
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit
- name: run pre-commit
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
BRANCH_NAME: ${{ github.head_ref }}
run: |
LABEL_NAMES=$(echo '${{ toJson(github.event.pull_request.labels) }}' | jq -r '.[].name')
if echo "$LABEL_NAMES" | grep -q "Contribution"; then
echo "Label 'Contribution' found!"
export DEMISTO_SDK_XSOAR_LINTER_WARNING_ANNOTATIONS=true
else
echo "Label 'Contribution' not found."
fi
source .venv/bin/activate
if [[ "$BRANCH_NAME" =~ ^AUD-demisto/.* ]]; then
echo "In docker auto update branch, pre commit on docker_autoupdate mode."
demisto-sdk pre-commit -g --mode=docker_autoupdate --show-diff-on-failure --verbose
elif [[ "$BRANCH_NAME" =~ ^packwise/.* ]]; then
echo "In packwise branch, pre commit with ignore flag."
demisto-sdk pre-commit -g --mode=packwise --show-diff-on-failure --verbose
else
echo "Not in docker auto update branch, pre commit on CI mode."
demisto-sdk pre-commit -g --validate --show-diff-on-failure --verbose --mode=ci
fi
- name: "Check coverage.xml exists"
if: always()
id: check-coverage-xml-exists
uses: andstor/file-existence-action@v2
with:
files: "coverage_report/coverage.xml"
- name: "Check pytest report exists"
if: always()
id: check-pytest-junit-exists
uses: andstor/file-existence-action@v2
with:
files: ".report_pytest.xml"
- name: Create pack-wise pytest report
run: poetry run python .github/github_workflow_scripts/parse_junit_per_pack.py
if: |
always() &&
steps.check-pytest-junit-exists.outputs.files_exists == 'true' &&
github.event.pull_request.head.repo.fork == false
- name: Upload junit & pack-wise pytest report
uses: actions/upload-artifact@v4
if: |
always() &&
steps.check-pytest-junit-exists.outputs.files_exists == 'true' &&
github.event.pull_request.head.repo.fork == false
with:
name: pytest
path: |
packwise_pytest_time.csv
.report_pytest.xml
if-no-files-found: error
- name: Pytest coverage comment
if: |
always() &&
steps.check-coverage-xml-exists.outputs.files_exists == 'true' &&
steps.check-pytest-junit-exists.outputs.files_exists == 'true' &&
! github.event.pull_request.head.repo.fork
uses: MishaKav/pytest-coverage-comment@main
continue-on-error: true # may fail on output > 65k chars
with:
pytest-xml-coverage-path: coverage_report/coverage.xml
junitxml-path: .report_pytest.xml
- uses: actions/cache/save@v4
if: always()
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit