name: Build on: push: branches: [master] tags: ['v*'] pull_request: branches: [master] workflow_dispatch: env: LATEST_PY_VERSION: 3.9 COVERAGE_ARGS: '--cov --cov-report=term --cov-report=xml' XDIST_ARGS: '--numprocesses=auto --dist=loadfile' jobs: # Run tests for each supported python version test: runs-on: ubuntu-18.04 strategy: matrix: python-version: [3.7, 3.8, 3.9, '3.10'] fail-fast: false services: nginx: image: kennethreitz/httpbin ports: - 80:80 steps: # Set up python + poetry - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - uses: snok/install-poetry@v1.3 with: version: 1.2.0a2 virtualenvs-in-project: true # Start integration test databases - uses: supercharge/mongodb-github-action@1.7.0 with: mongodb-version: 4.4 - uses: supercharge/redis-github-action@1.4.0 with: redis-version: 6 - uses: rrainn/dynamodb-action@v2.0.0 # Cache packages per python version, and reuse until lockfile changes - name: Cache python packages id: cache uses: actions/cache@v2 with: path: .venv key: venv-${{ matrix.python-version }}-latest-${{ hashFiles('poetry.lock') }} - name: Install dependencies if: steps.cache.outputs.cache-hit != 'true' run: poetry install -v -E all # Run tests with coverage report - name: Run tests run: | source $VENV pytest -rs -x tests/unit ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }} pytest -rs -x tests/integration --cov-append ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }} # Latest python version: send coverage report to codecov - name: "Upload coverage report to Codecov" if: ${{ matrix.python-version == env.LATEST_PY_VERSION }} uses: codecov/codecov-action@v2 # Run code analysis checks via pre-commit hooks analyze: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: ${{ env.LATEST_PY_VERSION }} - name: Run style checks & linting uses: pre-commit/action@v2.0.3