Skip to content

Commit

Permalink
Enable caches on CI (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
KapJI authored Sep 9, 2024
1 parent 4d7c93b commit 0c75b1b
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 15 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,24 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: abatilo/[email protected]
uses: abatilo/actions-poetry@v3

- name: Use local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v4
id: cache-poetry-deps
name: Cache Poetry dependencies
with:
poetry-version: 1.3.2
path: ./.venv
key: venv-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
venv-${{ matrix.os }}-${{ matrix.python-version }}-
- name: Install dependencies
- name: Install dependencies with Poetry
if: steps.cache-poetry-deps.outputs.cache-hit != 'true'
run: poetry install

- name: Test package building
Expand Down
36 changes: 33 additions & 3 deletions .github/workflows/linting-and-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- master
pull_request:

env:
RUNS_ON: ubuntu-latest

jobs:
pre-commit:
name: Pre-commit
Expand All @@ -23,11 +26,38 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: abatilo/[email protected]
uses: abatilo/actions-poetry@v3

- name: Use local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v4
id: cache-poetry-deps
name: Cache Poetry dependencies
with:
path: ./.venv
key: venv-${{ env.RUNS_ON }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
venv-${{ env.RUNS_ON }}-${{ matrix.python-version }}-
- uses: actions/cache@v4
name: Cache pre-commit hooks
with:
poetry-version: 1.3.2
path: ~/.cache/pre-commit/
key: >
${{ format('pre-commit-{0}-{1}-{2}',
env.RUNS_ON,
matrix.python-version,
hashFiles('.pre-commit-config.yaml')
) }}
restore-keys: |
pre-commit-${{ env.RUNS_ON }}-${{ matrix.python-version }}-
pre-commit-${{ env.RUNS_ON }}-
- name: Install dependencies
- name: Install dependencies with Poetry
if: steps.cache-poetry-deps.outputs.cache-hit != 'true'
run: poetry install

- name: Run pre-commit on all files
Expand Down
22 changes: 19 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
release:
types: [published]

env:
RUNS_ON: ubuntu-latest

jobs:
publish:
name: Publish
Expand All @@ -21,11 +24,24 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: abatilo/[email protected]
uses: abatilo/actions-poetry@v3

- name: Use local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v4
id: cache-poetry-deps
name: Cache Poetry dependencies
with:
poetry-version: 1.3.2
path: ./.venv
key: venv-${{ env.RUNS_ON }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
venv-${{ env.RUNS_ON }}-${{ matrix.python-version }}-
- name: Install dependencies
- name: Install dependencies with Poetry
if: steps.cache-poetry-deps.outputs.cache-hit != 'true'
run: poetry install

- name: Set version
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ repos:
- id: pylint
name: pylint
entry: poetry run pylint
exclude: ^glocaltokens/google/
language: system
types: [python]
- id: pytest
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ types-protobuf = "^4.24.0.4"
"Bug Tracker" = "https://github.com/leikoilja/glocaltokens/issues"
"Release Notes" = "https://github.com/leikoilja/glocaltokens/releases"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.pylint.master]
extension-pkg-whitelist = [
"_socket",
Expand Down Expand Up @@ -98,8 +102,4 @@ warn_unreachable = true
[tool.codespell]
ignore-words-list = "aas"
quiet-level = 2
skip = "poetry.lock,./.git/*,./.mypy_cache/*,*.egg-info"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
skip = "poetry.lock,./.git/*,./.mypy_cache/*,./.venv/*,*.egg-info"

0 comments on commit 0c75b1b

Please sign in to comment.