Skip to content

Commit

Permalink
fix: detach cache key from pyproject version
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkrzyskow committed Sep 25, 2024
1 parent 3467a9c commit 0e17595
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/reusable_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,47 @@ jobs:
echo '
${{ secrets.INPUT_ENV }}
' >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Checkout Caller Repo
uses: actions/checkout@v4
- name: Checkout mkdocs-nype repo
run: git clone --depth 1 https://github.com/nypesap/mkdocs-nype.git
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Download variable dependency list from the theme
run: |
wget -O requirements-theme.txt https://raw.githubusercontent.com/nypesap/mkdocs-nype/main/requirements.txt
wget -O pyproject-theme.toml https://raw.githubusercontent.com/nypesap/mkdocs-nype/main/pyproject.toml
- name: Install Python
id: install-python
uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: 3
cache: pip
- name: Process Python Cache
id: cache-requirements
uses: actions/cache@v4
with:
path: venv
key: requirements-${{ steps.install-python.outputs.python-version }}-${{ hashFiles('requirements*.txt', 'pyproject*.toml') }}
key: requirements-${{ steps.install-python.outputs.python-version }}-${{ hashFiles('mkdocs-nype/requirements*.txt', 'mkdocs-nype/mkdocs_nype/**') }}
restore_keys: |
requirements-${{ steps.install-python.outputs.python-version }}
- name: Install Uncached Requirements
if: steps.cache-requirements.outputs.cache-hit != 'true'
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- run: mkdir -p .cache; echo mkdocs-material > .cache/safe
- uses: actions/cache@v4
pip install mkdocs-nype/
- name: Create dummy cache file
run: mkdir -p .cache; echo mkdocs-material > .cache/safe
- name: Process Material for MkDocs Cache
uses: actions/cache@v4
with:
key: mkdocs-material-${{ hashfiles('.cache/**') }}
path: .cache
restore-keys: |
mkdocs-material-
- run: venv/bin/python -m mkdocs_nype --minify --inject-minified
- run: venv/bin/python -m mkdocs build --strict
- name: Run theme pre-build scripts
run: venv/bin/python -m mkdocs_nype --minify --inject-minified
- name: Build site
run: venv/bin/python -m mkdocs build --strict
- name: Prepare deploy archive
run: |
zip -r site.zip site/
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/test_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ jobs:
run: |
isort mkdocs_nype/ --check
black mkdocs_nype/ --check
- name: Check package version when contents change
if: "hashFiles('mkdocs_nype') != hashFiles('main-branch/mkdocs_nype')"
run: |
wget -O main_pyproject.toml https://raw.githubusercontent.com/nypesap/mkdocs-nype/refs/heads/main/pyproject.toml
python .github/scripts/compare_pyproject.py --dev-toml pyproject.toml --main-toml main_pyproject.toml
cache-init:
needs: style-check
runs-on: ubuntu-latest
Expand All @@ -50,7 +45,9 @@ jobs:
uses: actions/cache@v4
with:
path: venv
key: requirements-${{ steps.install-python.outputs.python-version }}-${{ hashFiles('requirements*.txt', 'pyproject*.toml') }}
key: requirements-${{ steps.install-python.outputs.python-version }}-${{ hashFiles('requirements*.txt', 'mkdocs_nype/**') }}
restore_keys: |
requirements-${{ steps.install-python.outputs.python-version }}
- name: Install Uncached Requirements
if: steps.cache-requirements.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -93,7 +90,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: venv
key: requirements-${{ steps.install-python.outputs.python-version }}-${{ hashFiles('mkdocs-nype/requirements*.txt', 'mkdocs-nype/pyproject*.toml') }}
key: requirements-${{ steps.install-python.outputs.python-version }}-${{ hashFiles('mkdocs-nype/requirements*.txt', 'mkdocs-nype/mkdocs_nype/**') }}
- name: Crate cache file to avoid empty cache
run: mkdir -p .cache; echo mkdocs-material > .cache/safe
- uses: actions/cache@v4
Expand All @@ -104,8 +101,8 @@ jobs:
mkdocs-material-
- run: venv/bin/python -m mkdocs_nype --minify --inject-minified
- run: venv/bin/python -m mkdocs build --strict
after-repos:
needs: check-repos
runs-on: ubuntu-latest
steps:
- run: echo "Success"
# after-repos:
# needs: check-repos
# runs-on: ubuntu-latest
# steps:
# - run: echo "Success"

0 comments on commit 0e17595

Please sign in to comment.