name: CI on: push: branches: [ main ] pull_request: branches: [ main ] jobs: test: runs-on: ubuntu-latest strategy: matrix: python-version: [3.7, 3.8, 3.9, '3.10', '3.11'] 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 pip install -r requirements.txt pip install -r requirements-dev.txt - 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 flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Check formatting with black run: | black --check . - name: Check imports with isort run: | isort --check-only --profile black . - name: Type check with mypy run: | mypy github_sponsors_bot.py - name: Test with pytest run: | pytest --cov=github_sponsors_bot --cov-report=xml env: GITHUB_WEBHOOK_SECRET: test_webhook_secret TELEGRAM_TOKEN: test_telegram_token TELEGRAM_CHAT_ID: 123456789 - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: file: ./coverage.xml fail_ci_if_error: false docker: runs-on: ubuntu-latest needs: test if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build Docker image uses: docker/build-push-action@v4 with: context: . push: false tags: github-sponsors-bot:latest cache-from: type=gha cache-to: type=gha,mode=max