KissPeter/APIFuzzer

View on GitHub
.github/workflows/python-app.yml

Summary

Maintainability
Test Coverage
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
  push:
    branches:
      - '**'
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ ubuntu-latest ] # , macos-latest, windows-latest
        python-version: [ '3.8', '3.9', '3.10', '3.11' ]
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v3
        with:
          python-version: ${{ matrix.python-version }}
      - name: Display Python version
        run: python --version
      - name: Install dependencies
        run: |
          sudo apt-get -y install libgnutls28-dev libcurl4-openssl-dev libssl-dev
          python -m pip install --upgrade pip
          pip install black vulture
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
          if [ -f test/requirements_for_test.txt ]; then pip install -r test/requirements_for_test.txt; fi
          ./APIFuzzer -h
      - name: Lint
        run: |
          black apifuzzer/
          vulture --min-confidence 100 apifuzzer/
          python3 test/test_application.py&
      - name: Test
        run: |
          pytest  -x --hypothesis-show-statistics --cov-report html --cov=apifuzzer  --html=pytest.html --self-contained-html --durations=10 --show-capture=stdout -vv -rP test
          coverage html
          coverage report
      - uses: actions/upload-artifact@v3
        if: always()
        with:
          name: Coverage-${{ matrix.python-version }}
          path: ./htmlcov
      - uses: actions/upload-artifact@v3
        if: always()
        with:
          name: Pytest-Report-${{ matrix.python-version }}
          path: pytest.html
  docker:
    runs-on: ubuntu-latest
    timeout-minutes: 300
    steps:
      - name: 'Checkout Repository'
        uses: actions/checkout@v3
      - uses: jpribyl/action-docker-layer-caching@v0.1.0
        continue-on-error: true
      - name: 'Docker Compose'
        uses: isbang/compose-action@v1.4.1
        with:
          compose-file: "./docker-compose.yml"
          up-flags: "--build --force-recreate"
      - name: 'Test docker  with help argument'
        run: docker run apifuzzer -h
      - name: Upload image
        if: success()
        uses: ishworkh/docker-image-artifact-upload@v1
        with:
          image: "apifuzzer:latest"
          retention_days: "30"