Futsch1/form-analyzer

View on GitHub
.github/workflows/build.yml

Summary

Maintainability
Test Coverage
name: Build

on: [push, pull_request,workflow_dispatch]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: [ "3.7", "3.11" ]

    steps:
      - uses: actions/checkout@v3
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v3
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install flake8 pytest
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
      - name: Lint with flake8
        run: |
          # stop the build if there are Python syntax errors or undefined names
          flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
          # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
          flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

      - name: Test with pytest
        run: |
          coverage run -a -m pytest
          coverage html -d coverage

      - name: Coveralls
        if: ${{ matrix.python-version }} == "3.11"
        uses: AndreMiras/coveralls-python-action@develop

      - name: Upload test results
        if: ${{ matrix.python-version }} == "3.11"
        uses: actions/upload-artifact@v2
        with:
          name: coverage-report
          path: coverage/index.html

  release:
    name: Build wheel
    needs: [ build ]
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Set up Python 3.11
        uses: actions/setup-python@v3
        with:
          python-version: "3.11"
      - name: Install pypa/build
        run: |
          python -m pip install build --user
      - name: Build a binary wheel and a source tarball
        run: |
          git clean -dfx
          python -m build --sdist --wheel --outdir dist/ .
      - name: Upload wheel
        uses: actions/upload-artifact@v3
        with:
          name: wheel
          path: dist/*.whl
      - name: Publish distribution to PyPI
        if: startsWith(github.ref, 'refs/tags')
        uses: pypa/gh-action-pypi-publish@master
        with:
          skip_existing: true
          password: ${{ secrets.pypi_password }}
      - name: Create Release
        if: startsWith(github.ref, 'refs/tags')
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: false
          prerelease: false