Skip to content

Commit

Permalink
Merge branch 'develop' into activation-sparsity-ov-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-savelyevv committed Dec 16, 2024
2 parents 75ca314 + d927956 commit fddbbd3
Show file tree
Hide file tree
Showing 629 changed files with 144,292 additions and 38,991 deletions.
74 changes: 74 additions & 0 deletions .github/scripts/pytest_md_summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright (c) 2024 Intel Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import xml.etree.ElementTree as ET


def parse_xml_report(xml_file) -> None:
"""
Parse the XML report generated by pytest.
:param xml_file: Path to the XML report file
:return: None
"""
try:
tree = ET.parse(xml_file)
except FileNotFoundError:
sys.exit(1)

root = tree.getroot()

# Build the summary table in Markdown format
table_lines = []
table_lines.append("| Test Name | Status | Time | Message |")
table_lines.append("|:----------|:------:|-----:|:--------|")

# Iterate over test cases
for testcase in root.findall(".//testcase"):
test_name = testcase.get("name")
time_duration = float(testcase.get("time", "0"))
message = ""
if testcase.find("failure") is not None:
status = "$${\color{red}Failed}$$"
message = testcase.find("failure").get("message", "")
elif testcase.find("error") is not None:
status = "$${\color{red}Error}$$"
elif testcase.find("skipped") is not None:
status = "$${\color{orange}Skipped}$$"
message = testcase.find("skipped").get("message", "")
else:
status = "$${\color{green}Ok}$$"

# Append each row to the table
if message:
message = message.splitlines()[0][:60]
table_lines.append(f"| {test_name} | {status} | {time_duration:.0f} | {message} |")

if len(table_lines) > 2:
# Print the summary table only if there are test cases
print("\n".join(table_lines))


if __name__ == "__main__":
"""
This script generates a summary table in Markdown format from an XML report generated by pytest.
Usage in GitHub workflow:
- name: Test Summary
if: ${{ !cancelled() }}
run: |
python .github/scripts/generate_examples_summary.py pytest-results.xml >> $GITHUB_STEP_SUMMARY
"""
try:
parse_xml_report(sys.argv[1])
except Exception as e:
print(f"Error: {e}")
53 changes: 20 additions & 33 deletions .github/workflows/api_changes_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: API changes check
permissions: read-all

on:
pull_request_target:
pull_request:
branches:
- develop

Expand Down Expand Up @@ -41,37 +41,24 @@ jobs:
echo ${CHANGED_FILES}
CHANGED_FILES=$(echo $CHANGED_FILES | tr '\n' ' ')
echo "changed_files=${CHANGED_FILES}" >> $GITHUB_OUTPUT
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ !(contains(steps.diff.outputs.changed_files, 'differ')) && contains(github.event.pull_request.labels.*.name, 'API') }}
with:
github-token: ${{ secrets.ADD_LABELS_WITH_REST_API }}
script: |
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: "API"
})
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
- name: Add label
if: ${{ contains(steps.diff.outputs.changed_files, 'differ') }}
run: |
echo '{"pr_number": "${{ github.event.pull_request.number }}", "action": "add"}' > api_status.json
- name: Remove label
if: ${{ !(contains(steps.diff.outputs.changed_files, 'differ')) && contains(github.event.pull_request.labels.*.name, 'API') }}
run: |
echo '{"pr_number": "${{ github.event.pull_request.number }}", "action": "remove"}' > api_status.json
- name: No change label
if: ${{ !(contains(steps.diff.outputs.changed_files, 'differ')) && !contains(github.event.pull_request.labels.*.name, 'API') }}
run: |
echo '{"pr_number": "${{ github.event.pull_request.number }}", "action": "none"}' > api_status.json
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
github-token: ${{ secrets.ADD_LABELS_WITH_REST_API }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["API"]
})
- name: Add release label
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ contains(github.event.pull_request.base.ref, 'release_v') }}
with:
github-token: ${{ secrets.ADD_LABELS_WITH_REST_API }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["release_target"]
})
name: api_status
path: api_status.json
61 changes: 61 additions & 0 deletions .github/workflows/api_set_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Set API label
permissions: read-all

on:
workflow_run:
workflows: ["API changes check"]
types:
- completed

jobs:
update_labels:
runs-on: ubuntu-latest

permissions:
pull-requests: write

steps:
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6
with:
run_id: ${{ github.event.workflow_run.id }}
name: api_status

- name: Get api_status
run: cat api_status.json

- name: Set output value
id: status
run: |
echo "action=$(cat api_status.json | jq -r .action)" >> $GITHUB_OUTPUT
echo "pr_number=$(cat api_status.json | jq -r .pr_number)" >> $GITHUB_OUTPUT
- name: Print outputs
run: echo ${{ steps.status.outputs.action }} ${{ steps.status.outputs.pr_number }}

- name: Add label
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ steps.status.outputs.action == 'add' }}
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
github.rest.issues.addLabels({
issue_number: ${{ steps.status.outputs.pr_number }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["API"]
})
- name: Remove label
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ steps.status.outputs.action == 'remove' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.removeLabel({
issue_number: ${{ steps.status.outputs.pr_number }},
owner: context.repo.owner,
repo: context.repo.repo,
name: "API"
})
4 changes: 4 additions & 0 deletions .github/workflows/build_html_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: ${{ inputs.ref }}
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.10.14
cache: pip
- name: Install NNCF and doc requirements
run: |
pip install .
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/build_schema_page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ jobs:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.10.14
cache: pip

- name: Install and Build
run: |
pip install json-schema-for-humans
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Test examples
permissions: read-all

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
pull_request_number:
description: 'The pull request number'
default: ''
pytest_args:
description: 'Pytest arguments'
default: ''
skip_windows:
description: 'Skip tests on Windows'
type: boolean
default: false

concurrency:
group: test-examples-${{ github.workflow }}-${{ github.ref }}-${{ github.event.inputs.pytest_args || '' }}-${{github.event.inputs.pull_request_number || ''}}
cancel-in-progress: false

jobs:
examples-cpu:
name: Test exmaples CPU [${{ matrix.group }}/4]
runs-on: ubuntu-22.04-16-cores
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
lfs: true
fetch-depth: 0 # Fetch full history to allow checking out any branch or PR
- name: Fetch and Checkout the Pull Request Branch
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pull_request_number != '' }}
run: |
git fetch origin pull/${{ github.event.inputs.pull_request_number }}/head:pr-${{ github.event.inputs.pull_request_number }}
git checkout pr-${{ github.event.inputs.pull_request_number }}
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.10.14
cache: pip
- name: cpuinfo
run: cat /proc/cpuinfo
- name: Install test requirements
run: |
pip install -r tests/cross_fw/examples/requirements.txt
- name: Print installed modules
run: pip list
- name: Run examples test scope
run: |
set +e
python -m pytest -s -ra tests/cross_fw/examples \
--junit-xml=pytest-results.xml \
--durations-path=tests/cross_fw/examples/.test_durations \
--splitting-algorithm=least_duration \
--splits 4 \
--group ${{ matrix.group }} \
${{ github.event.inputs.pytest_args || '' }}
ret=$?
[ $ret -eq 5 ] && [ -n "${{ github.event.inputs.pytest_args || '' }}" ] && exit 0 || exit $ret
env:
TQDM_DISABLE: 1
- name: Test Summary
if: ${{ !cancelled() }}
run: |
python .github/scripts/pytest_md_summary.py pytest-results.xml >> $GITHUB_STEP_SUMMARY
examples-win-cpu:
name: Test exmaples CPU Windows [${{ matrix.group }}/4]
runs-on: windows-2019-16-core
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.skip_windows == 'false' }}
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
lfs: true
fetch-depth: 0 # Fetch full history to allow checking out any branch or PR
- name: Fetch and Checkout the Pull Request Branch
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pull_request_number != '' }}
run: |
git fetch origin pull/${{ github.event.inputs.pull_request_number }}/head:pr-${{ github.event.inputs.pull_request_number }}
git checkout pr-${{ github.event.inputs.pull_request_number }}
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: "3.10"
cache: pip
- uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1
- name: Install NNCF and test requirements
run: |
pip install -e .
pip install -r tests/cross_fw/examples/requirements.txt
- name: Print installed modules
run: pip list
- name: Run examples test scope
run: |
set +e
export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")"
export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")"
export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")"
python -m pytest -s -ra tests/cross_fw/examples \
--junit-xml=pytest-results.xml \
--durations-path=tests/cross_fw/examples/.test_durations \
--splitting-algorithm=least_duration \
--splits 4 \
--group ${{ matrix.group }} \
${{ github.event.inputs.pytest_args || '' }}
ret=$?
[ $ret -eq 5 ] && [ -n "${{ github.event.inputs.pytest_args || '' }}" ] && exit 0 || exit $ret
env:
TQDM_DISABLE: 1
- name: Test Summary
if: ${{ !cancelled() }}
run: |
python .github/scripts/pytest_md_summary.py pytest-results.xml >> $GITHUB_STEP_SUMMARY
Loading

0 comments on commit fddbbd3

Please sign in to comment.