.github/workflows/pythonpackage.yml

Summary

Maintainability
Test Coverage
name: Python package

on: [push]

jobs:

  build:
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13.0-alpha - 3.13.0"]
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip build
        python -m pip install -r tests/requirements.txt
    - name: Lint with flake8
      run: |
        pip install flake8
        # stop the build if there are Python syntax errors or undefined names
        flake8 flag --count --select=E9,F63,F7,F82 --show-source --statistics
        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
        flake8 flag --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
    - name: Test with pytest
      run: |
        pytest
    - name: Test install
      run: |
        python -m pip install .
    - name: Test build
      run: |
        python -m build

  coverage:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        # Disabling shallow clone is recommended for improving relevancy of reporting
        # 0 indicates all history for all branches and tags
        fetch-depth: 0
    - name: Set up Python 3.12
      uses: actions/setup-python@v4
      with:
        python-version: "3.12"
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install --upgrade build
        python -m pip install -r tests/requirements.txt
        python -m pip install coverage
        python -m pip install codacy-coverage
    - name: Generate coverage
      run: |
        coverage run -a tests/test_all_subregions.py
        coverage run -a tests/test_flag.py
        coverage run -a tests/test_singleflag.py
        coverage run -a tests/test_subregional.py
        coverage run -a tests/test_module.py
        coverage run -a tests/test_custom.py
    - name: Submit codacy
      run: |
        coverage xml
        python-codacy-coverage -r coverage.xml
      env:
        CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
      continue-on-error: true
    - name: Coveralls
      uses: AndreMiras/coveralls-python-action@v20201129
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
      continue-on-error: true
    - name: Codecov
      uses: codecov/codecov-action@v3
      continue-on-error: true
    - name: SonarCloud Scan
      uses: SonarSource/sonarcloud-github-action@v1.6
      continue-on-error: true
      with:
        args: >
          -Dsonar.organization=cvzi-github
          -Dsonar.projectKey=cvzi_flag
          -Dsonar.python.coverage.reportPaths=coverage.xml
          -Dsonar.sources=flag
          -Dsonar.host.url=https://sonarcloud.io
          -Dsonar.test.exclusions=tests/**
          -Dsonar.tests=tests/
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}