name: Python sanity on: [pull_request] jobs: build: name: Running sanity tests runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: [2.7, 3.8] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Get pip cache dir id: pip-cache run: | python -m pip install --upgrade pip echo "::set-output name=dir::$(pip cache dir)" - name: pip cache uses: actions/cache@v2 with: path: ${{ steps.pip-cache.outputs.dir }} key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements-dev.txt') }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.python-version }}- - name: Install dependencies run: | pip install -r requirements-dev.txt - name: Lint with flake8 id: flake8 run: | rm -f flake8.output flake8 . --statistics --output-file=flake8.output \ && echo "::set-output name=lint::ok" \ || echo "::set-output name=lint::error" cat flake8.output | awk -F: '{ if ($0 ~ /^\./) { gsub(/^[ \t]+/,"",$4); print "::error file=" $1 ",line=" $2 ",col=" $3 "::" $4 } else { print $0 } }' flake8 . --select=E9,F63,F7,F82 \ && echo "::set-output name=syntax::ok" \ || echo "::set-output name=syntax::error" - name: Run tests id: tests if: ${{ steps.flake8.outputs.syntax == 'ok' }} run: | coverage run coverage report - name: Upload coverage report to Codecov if: ${{ steps.tests.conclusion == 'success' }} env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} run: | coverage xml bash <(curl -s https://codecov.io/bash) \ || echo "::warning ::Codecov upload failed" - name: Error on flake8 if: ${{ steps.flake8.outputs.lint != 'ok' }} run: | flake8 . --count --statistics --exit-zero --quiet echo "::error ::Please correct flake8 warnings and errors" exit 1