diff --git a/.flake8 b/.flake8 index 6e1b26d..0f5e61f 100644 --- a/.flake8 +++ b/.flake8 @@ -4,6 +4,10 @@ # https://github.com/psf/black/blob/master/docs/compatible_configs.md max-line-length = 88 +extend-exclude = + # ignore cache directory for CI + .cache + extend-ignore = # ignore E203 because black might reformat it E203, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a3a3b1..b52539a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,40 +1,73 @@ -name: Continuous integration +name: "Continuous integration" on: [push, pull_request] +env: + PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip + POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/pypoetry + DEFAULT_PYTHON: "3.8" + jobs: test: - name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }} + name: "Test Python ${{ matrix.python-version }} on ${{ matrix.os }}" runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] python-version: ["3.7", "3.8", "3.9"] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - name: "Check out repository" + uses: actions/checkout@v2 + + - name: "Set up Python" + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + + - name: "Set up dependency cache" + uses: actions/cache@v2 + with: + key: deps-${{ secrets.GH_CACHE }}-${{ runner.os }}-python${{ matrix.python-version }}-${{ hashFiles('**/*.lock') }} + path: | + ${{ env.PIP_CACHE_DIR }} + ${{ env.POETRY_CACHE_DIR }} + + - name: "Install dependencies" run: pip install poetry && poetry install - - name: Run tests + + - name: "Run tests" run: poetry run pytest check: - name: Lint and type checks + name: "Lint and type checks" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - name: "Check out repository" + uses: actions/checkout@v2 + + - name: "Set up Python" + uses: actions/setup-python@v2 with: - python-version: "3.8" - - name: Install dependencies + python-version: ${{ env.DEFAULT_PYTHON }} + + - name: "Set up dependency cache" + uses: actions/cache@v2 + with: + key: deps-${{ secrets.GH_CACHE }}-${{ runner.os }}-python${{ env.DEFAULT_PYTHON }}-${{ hashFiles('**/*.lock') }} + path: | + ${{ env.PIP_CACHE_DIR }} + ${{ env.POETRY_CACHE_DIR }} + + - name: "Install dependencies" run: pip install poetry && poetry install - - name: Format checks + + - name: "Check formatting" run: poetry run black --check . - - name: Lint checks + + - name: "Check linter" run: poetry run flake8 - - name: Type checks + + - name: "Checks types" run: poetry run mypy build: @@ -42,18 +75,32 @@ jobs: runs-on: ubuntu-latest needs: [test, check] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - name: "Check out repository" + uses: actions/checkout@v2 + + - name: "Set up Python" + uses: actions/setup-python@v2 with: - python-version: "3.8" - - name: Install dependencies + python-version: ${{ env.DEFAULT_PYTHON }} + + - name: "Set up dependency cache" + uses: actions/cache@v2 + with: + key: deps-${{ secrets.GH_CACHE }}-${{ runner.os }}-python${{ env.DEFAULT_PYTHON }}-${{ hashFiles('**/*.lock') }} + path: | + ${{ env.PIP_CACHE_DIR }} + ${{ env.POETRY_CACHE_DIR }} + + - name: "Install dependencies" run: pip install poetry && poetry install - - name: Build artifacts + + - name: "Build artifacts" run: | poetry build poetry run mkdocs build - - if: startsWith(github.ref, 'refs/tags/v') - name: Deploy to PyPI and GitHub Pages + + - name: "Deploy to PyPI and GitHub Pages" + if: startsWith(github.ref, 'refs/tags/v') env: USER_NAME: ${{ github.actor }} USER_ID: ${{ github.event.sender.id }} diff --git a/.gitignore b/.gitignore index ce391fa..dc118d3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ site *.egg-info .python-version __pycache__ +.cache