Skip to content

Commit

Permalink
chore: improve CI caching (#526)
Browse files Browse the repository at this point in the history
* chore: improve CI caching

* fix: add OS to cache key
  • Loading branch information
tconbeer authored Apr 16, 2024
1 parent 8bb9660 commit 4ceb9f6
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 9 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v') }}
runs-on: ubuntu-latest
environment: publish
env:
POETRY_VIRTUALENVS_IN_PROJECT: 1
POETRY_INSTALLER_PARALLEL: 1
POETRY_VIRTUALENVS_CREATE: 1
permissions:
id-token: write

Expand All @@ -20,21 +24,34 @@ jobs:
uses: actions/checkout@v4
with:
ref: main

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: ${{ runner.os }}-poetry-171 # increment to reset cache

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1

- name: Get harlequin Version
id: harlequin_version
run: echo "harlequin_version=$(poetry version --short)" >> $GITHUB_OUTPUT

- name: Build package
run: poetry build --no-interaction

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Create a Github Release
uses: softprops/action-gh-release@v2
with:
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,55 @@ jobs:
permissions:
contents: write
pull-requests: write
env:
POETRY_VIRTUALENVS_IN_PROJECT: 1
POETRY_INSTALLER_PARALLEL: 1
POETRY_VIRTUALENVS_CREATE: 1

steps:
- name: Check out harlequin main branch
uses: actions/checkout@v4
with:
ref: main

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: ${{ runner.os }}-poetry-171 # increment to reset cache

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1

- name: Create release branch
run: |
git checkout -b release/v${{ github.event.inputs.newVersion }}
git push --set-upstream origin release/v${{ github.event.inputs.newVersion }}
- name: Bump version
run: poetry version ${{ github.event.inputs.newVersion }} --no-interaction

- name: Ensure package can be built
run: poetry build --no-interaction

- name: Update CHANGELOG
uses: thomaseizinger/keep-a-changelog-new-release@v2
with:
version: ${{ github.event.inputs.newVersion }}

- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Bumps version to ${{ github.event.inputs.newVersion }}

- name: Create pull request into main
uses: thomaseizinger/[email protected]
env:
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,48 @@ jobs:
static:
name: Static Analysis - 3.8
runs-on: ubuntu-latest
env:
POETRY_VIRTUALENVS_IN_PROJECT: 1
POETRY_INSTALLER_PARALLEL: 1
POETRY_VIRTUALENVS_CREATE: 1
steps:
- name: Check out Repo
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python 3.8
uses: actions/setup-python@v5
id: setup-python
with:
python-version: "3.8"

- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: ${{ runner.os }}-poetry-171 # increment to reset cache

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: static-venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install python dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --sync --no-interaction --without dev

- name: Run analysis
run: |
source .venv/bin/activate
black . --check
ruff .
ruff check .
mypy
31 changes: 26 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,38 @@ jobs:
runs-on: Windows-latest
env:
motherduck_token: ${{ secrets.HARLEQUIN_MOTHERDUCK_TOKEN }}
POETRY_VIRTUALENVS_IN_PROJECT: 1
POETRY_INSTALLER_PARALLEL: 1
POETRY_VIRTUALENVS_CREATE: 1
steps:
- name: Check out Repo
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Load cached Poetry installation
id: cached-poetry-install
uses: actions/cache@v4
with:
path: ~/.local
key: ${{ runner.os }}-poetry-171

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1

- name: Install python dependencies
run: poetry install --sync --no-interaction --only main,test

- name: Run tests
run: poetry run pytest -m "not online" -m "not flaky_windows" --snapshot-warn-unused

- name: Store snapshot report on failure
uses: actions/upload-artifact@v4
if: failure()
Expand All @@ -49,6 +64,9 @@ jobs:
runs-on: ${{ matrix.os }}-latest
env:
motherduck_token: ${{ secrets.HARLEQUIN_MOTHERDUCK_TOKEN }}
POETRY_VIRTUALENVS_IN_PROJECT: 1
POETRY_INSTALLER_PARALLEL: 1
POETRY_VIRTUALENVS_CREATE: 1
strategy:
fail-fast: false
matrix:
Expand All @@ -65,38 +83,41 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python ${{ matrix.py }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}

- name: Load cached Poetry installation
id: cached-poetry-install
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
key: ${{ runner.os }}-poetry-171

- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.4.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
version: 1.7.1

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install python dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --sync --no-interaction --only main,test
- name: Run tests
run: |
source .venv/bin/activate
pytest -m "not online"
- name: Store snapshot report on failure
uses: actions/upload-artifact@v4
if: failure()
Expand Down

0 comments on commit 4ceb9f6

Please sign in to comment.