|
| 1 | +name: "Check python code" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - "**.py" |
| 7 | + - pyproject.toml |
| 8 | + - pre-commit-config.yaml |
| 9 | + - ".github/workflows/run-dev-tests.yml" |
| 10 | + pull_request: |
| 11 | + types: opened |
| 12 | + paths: |
| 13 | + - "**.py" |
| 14 | + - "**requirements*.txt" |
| 15 | + - pyproject.toml |
| 16 | + - pre-commit-config.yaml |
| 17 | + - ".github/workflows/run-dev-tests.yml" |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v3 |
| 24 | + - uses: actions/setup-python@v4 |
| 25 | + with: |
| 26 | + python-version: '3.x' |
| 27 | + - name: Build wheel |
| 28 | + run: python3 -m pip wheel --no-deps -w dist . |
| 29 | + - name: Upload wheel as artifact |
| 30 | + uses: actions/upload-artifact@v3 |
| 31 | + with: |
| 32 | + name: cpp-linter-action_wheel |
| 33 | + path: ${{ github.workspace }}/dist/*.whl |
| 34 | + |
| 35 | + test: |
| 36 | + needs: [build] |
| 37 | + strategy: |
| 38 | + fail-fast: false |
| 39 | + matrix: |
| 40 | + py: ['3.7', '3.8', '3.9', '3.10'] |
| 41 | + os: ['windows-latest', ubuntu-latest] |
| 42 | + version: ['13', '12', '11', '10', '9', '8', '7'] |
| 43 | + include: |
| 44 | + - tools_dir: 'N/A' |
| 45 | + - os: 'windows-latest' |
| 46 | + version: '10' |
| 47 | + tools_dir: temp |
| 48 | + - os: 'windows-latest' |
| 49 | + version: '10' |
| 50 | + tools_dir: temp |
| 51 | + - os: 'windows-latest' |
| 52 | + version: '11' |
| 53 | + tools_dir: temp |
| 54 | + - os: 'windows-latest' |
| 55 | + version: '12' |
| 56 | + tools_dir: temp |
| 57 | + - os: 'ubuntu-latest' |
| 58 | + version: '13' |
| 59 | + tools_dir: temp |
| 60 | + # - version: '14' |
| 61 | + # tools_dir: temp |
| 62 | + - version: '7' |
| 63 | + tools_dir: temp |
| 64 | + - version: '8' |
| 65 | + tools_dir: temp |
| 66 | + - version: '9' |
| 67 | + tools_dir: temp |
| 68 | + |
| 69 | + runs-on: ${{ matrix.os }} |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v3 |
| 72 | + |
| 73 | + - uses: actions/setup-python@v4 |
| 74 | + with: |
| 75 | + python-version: ${{ matrix.py }} |
| 76 | + |
| 77 | + - name: download wheel artifact |
| 78 | + uses: actions/download-artifact@v3 |
| 79 | + with: |
| 80 | + name: cpp-linter-action_wheel |
| 81 | + path: dist |
| 82 | + |
| 83 | + - name: Install workflow deps |
| 84 | + # using a wildcard as filename on Windows requires a bash shell |
| 85 | + shell: bash |
| 86 | + run: python3 -m pip install pytest coverage[toml] dist/*.whl |
| 87 | + |
| 88 | + - name: Install clang-tools |
| 89 | + if: matrix.tools_dir == 'temp' |
| 90 | + run: | |
| 91 | + python -m pip install clang-tools |
| 92 | + clang-tools --install ${{ matrix.version }} --directory ${{ runner.temp }}/clang-tools |
| 93 | +
|
| 94 | + - name: Collect Coverage (native clang install) |
| 95 | + if: matrix.tools_dir == 'N/A' |
| 96 | + env: |
| 97 | + CLANG_VERSION: ${{ matrix.version }} |
| 98 | + run: coverage run -m pytest |
| 99 | + |
| 100 | + - name: Collect Coverage (non-native clang install) |
| 101 | + if: matrix.tools_dir == 'temp' |
| 102 | + env: |
| 103 | + CLANG_VERSION: ${{ runner.temp }}/clang-tools |
| 104 | + run: coverage run -m pytest |
| 105 | + |
| 106 | + - run: coverage report && coverage xml |
| 107 | + |
| 108 | + - uses: codecov/codecov-action@v3 |
| 109 | + if: matrix.os == 'ubuntu-latest' && matrix.version == '12' && matrix.py == '3.10' |
| 110 | + with: |
| 111 | + files: ./coverage.xml |
| 112 | + fail_ci_if_error: true # optional (default = false) |
| 113 | + verbose: true # optional (default = false) |
0 commit comments