Add Python3 pre-commit config checks with pylint and mypy #18
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
name: build | |
on: [push, pull_request] | |
jobs: | |
python-tests: | |
name: "Python Tests" | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
# To have access to secrets, use the PR branch: | |
# https://github.com/orgs/community/discussions/26409 | |
ref: ${{github.event.pull_request.head.ref}} | |
repository: ${{github.event.pull_request.head.repo.full_name}} | |
- name: Build tests/*/info.json files for the Python tests | |
run: make -j $(nproc) | |
- name: pre-commit checks - setup cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: pre-commit checks - run checks | |
uses: pre-commit/[email protected] | |
env: | |
# For merging PRs to master, skip the no-commit-to-branch check: | |
SKIP: no-commit-to-branch | |
- name: Install Python2 dependencies | |
run: | | |
#: Install Python 2.7 from Ubuntu 20.04 using apt-get install | |
sudo apt-get update && sudo apt-get install -y python2 | |
curl -sSL https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py | |
python2 get-pip.py | |
if [ -f requirements.txt ]; then pip2 install -r requirements.txt; fi | |
if [ -f requirements-dev.txt ]; then pip2 install -r requirements-dev.txt; fi | |
pip2 install pytest pylint==1.9.4 | |
- name: Run pylint-1.9.4 | |
run: python2 -m pylint xtf-runner build/*.py | |
- name: Run python2 -m pytest to execute all unit and integration tests | |
run: python2 -m pytest -v -rA | |
build: | |
strategy: | |
matrix: | |
arch: [x86] | |
compiler: [llvm-12, llvm-13, llvm-14] | |
include: | |
- arch: x86 | |
compiler: gcc-9 | |
- arch: x86 | |
compiler: gcc-10 | |
- arch: x86 | |
compiler: gcc-11 | |
- arch: x86 | |
compiler: gcc-12 | |
- arch: x86 | |
compiler: gcc-13 | |
- arch: x86 | |
compiler: clang-12 | |
- arch: x86 | |
compiler: clang-13 | |
- arch: x86 | |
compiler: clang-14 | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Install | |
run: | | |
c=${{matrix.compiler}} | |
v=${c##llvm-} | |
case $c in | |
# Need all {llvm,clang,lld}-$v packages | |
llvm-*) EXTRA="clang-${v} lld-${v}" ;; | |
esac | |
sudo apt-get update -q | |
sudo apt-get install -y build-essential python3 ${{matrix.compiler}} ${EXTRA} | |
- uses: actions/checkout@v3 | |
- name: Build | |
run: | | |
# Select appropriate LLVM= or CC= | |
c=${{matrix.compiler}} | |
case $c in | |
llvm-*) COMP="LLVM=${c#llvm}" ;; | |
*) COMP="CC=$c" ;; | |
esac | |
make -j`nproc` ARCH=${{matrix.arch}} $CROSS $COMP |