forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve quality-gate conflict between PR and master branch
- Loading branch information
Showing
59 changed files
with
1,658 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,30 +7,99 @@ on: | |
# run daily, this refreshes the cache | ||
- cron: '13 2 * * *' | ||
|
||
concurrency: # On new push, cancel old workflows from the same PR, branch or tag: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
python-test: | ||
name: Python tests | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
docker-image: # See https://hub.docker.com/_/python/tags for images | ||
- python:2.7.18-alpine3.11 | ||
- python:3.11.4-alpine3.18 | ||
container: ${{ matrix.docker-image }} | ||
python-version: ['2.7', '3.11'] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # To check which files changed: origin/master..HEAD | ||
- uses: LizardByte/setup-python-action@master | ||
with: | ||
python-version: ${{matrix.python-version}} | ||
|
||
- uses: actions/cache@v3 | ||
name: Setup cache for running pre-commit fast | ||
with: | ||
path: ~/.cache/pre-commit | ||
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} | ||
|
||
- name: Install python 2 dependencies | ||
if: ${{ startsWith(matrix.docker-image, 'python:2.7.18') }} | ||
- run: echo "::add-matcher::.github/workflows/python-warning-matcher.json" | ||
name: "Setup GitHub for reporting Python warnings as annotations in pull request code review" | ||
|
||
- uses: pre-commit/[email protected] | ||
name: Run pre-commit checks (no spaces at end of lines, etc) | ||
if: ${{ matrix.python-version != '2.7' }} | ||
with: | ||
extra_args: --all-files --verbose --hook-stage commit | ||
env: | ||
SKIP: no-commit-to-branch | ||
|
||
- name: Install dependencies only needed for python 2 | ||
if: ${{ matrix.python-version == '2.7' }} | ||
run: pip install enum | ||
|
||
- name: Install dependencies | ||
run: pip install mock pytest | ||
- name: Install dependencies only needed for python 3 | ||
if: ${{ matrix.python-version != '2.7' }} | ||
run: pip install pandas pytype toml | ||
|
||
- name: Run python tests | ||
run: pytest scripts | ||
- name: Install common dependencies for Python ${{matrix.python-version}} | ||
run: pip install mock pytest-coverage pytest-mock | ||
|
||
- name: Run Pytest tests for Python ${{matrix.python-version}} | ||
run: > | ||
pytest --cov scripts scripts/ -vv -rA | ||
--junitxml=.git/pytest${{matrix.python-version}}.xml | ||
--cov-report term-missing | ||
--cov-report xml:.git/coverage${{matrix.python-version}}.xml | ||
env: | ||
PYTHONDEVMODE: yes | ||
|
||
- name: Upload Python ${{matrix.python-version}} coverage report to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
directory: .git | ||
files: coverage${{matrix.python-version}}.xml | ||
env_vars: OS,PYTHON | ||
fail_ci_if_error: false | ||
flags: python${{matrix.python-version}} | ||
name: coverage${{matrix.python-version}} | ||
verbose: true | ||
|
||
- uses: dciborow/[email protected] | ||
if: ${{ matrix.python-version != '2.7' }} | ||
with: | ||
reporter: github-pr-review | ||
level: warning | ||
# To be customized to cover remaining Python scripts: | ||
glob_pattern: "**/*.py" | ||
|
||
- name: Run pytype checks | ||
if: ${{ matrix.python-version != '2.7' }} | ||
run: ./pytype_reporter.py | ||
env: | ||
PR_NUMBER: ${{ github.event.number }} | ||
|
||
# Try to add pytype_report.py's summary file as a comment to the PR: | ||
# Documentation: https://github.com/marketplace/actions/add-pr-comment | ||
- name: Add the pytype summary as a comment to the PR (if permitted) | ||
uses: mshick/add-pr-comment@v2 | ||
# Depends on pytype checks, which are not run for python 2.7: | ||
if: ${{ matrix.python-version != '2.7' }} | ||
# Fails for user workflows without permissions(fork-based pull requests): | ||
continue-on-error: true | ||
with: | ||
message-path: .git/pytype-summary.md # Add the content of it as comment | ||
|
||
ocaml-test: | ||
name: Ocaml tests | ||
|
@@ -115,3 +184,13 @@ jobs: | |
|
||
- name: quality-gate | ||
run: make quality-gate | ||
|
||
- uses: reviewdog/action-actionlint@v1 | ||
name: GitHub Action linter from https://github.com/reviewdog/action-actionlint | ||
|
||
- name: pyflakes | ||
uses: reviewdog/action-pyflakes@master | ||
with: | ||
github_token: ${{ secrets.github_token }} | ||
reporter: github-pr-review | ||
level: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "python-warnings", | ||
"severity": "warning", | ||
"pattern": [ | ||
{ | ||
"regexp": "^.*/xen-api/(.+):([0-9]*):(.*):(.*)$", | ||
"file": 1, | ||
"line": 2, | ||
"code": 3, | ||
"message": 4 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# | ||
# Configuration of pre-commit, a Python framework for git hooks. | ||
# pre-commit is run for each git push by GitHub CI. It can run | ||
# locally as well for early feedback and automatic formatting | ||
# like trailing whitespace removal (to be configured later): | ||
# | ||
## For only installing the package itself, run: | ||
# pip3 install pre-commit | ||
# | ||
## For activating it as a pre-commit and pre-push hook (recommended): | ||
# pre-commit install --hook-type pre-push --hook-type pre-commit | ||
# | ||
## For manually executing the pre-push hook: | ||
# pre-commit run -av --hook-stage pre-push | ||
# | ||
default_stages: [commit, push] | ||
repos: | ||
# Recommendation for a minimal git pre-commit hook: | ||
# https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: no-commit-to-branch | ||
name: "The master branch should be pulled only, don't commit to it" | ||
args: [--branch, master] | ||
always_run: true | ||
- id: check-merge-conflict | ||
- id: check-yaml | ||
- id: check-executables-have-shebangs | ||
exclude: ocaml | ||
|
||
# Recommendation for a minimal git pre-push hook: | ||
# While using pre-commit yields great results, it | ||
# is "not fast". Therefore only run it pre-push, | ||
# (but always in GitHub CI of course): | ||
# | ||
# Calls ./pytype_reporter.py in a dedicated venv: | ||
# pre-commit run -av --hook-stage push | ||
- repo: local | ||
hooks: | ||
- id: pytype | ||
name: pytype | ||
entry: python3 pytype_reporter.py | ||
types: [python] | ||
stages: [push] | ||
verbose: true | ||
# This hook runs locally only when Python files change: | ||
language: python | ||
# Pytype supports running on Python 3.8 to Python3.11 currently: | ||
# https://google.github.io/pytype/support.html | ||
# If a dev's default python3 interpreter is outside that range, but | ||
# developers have such version installed, it can be configured here: | ||
# language_version: python3.11 | ||
require_serial: true | ||
additional_dependencies: [pandas, pytype] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.