Skip to content

Commit

Permalink
Use caching more effectively
Browse files Browse the repository at this point in the history
- Use `actions/setup-python` to manage caching for `pip`
- Stop trying to cache Docker images since it would be unreasonable
  anyway given the size of images being used
- Stop caching cookiecutter templates since downloading as part of a
  cache or downloading via `git` from GitHub are effectively the same
- Continue caching the Briefcase data directory
  • Loading branch information
rmartin16 committed Nov 17, 2023
1 parent d00f5ea commit eb289f2
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 34 deletions.
39 changes: 15 additions & 24 deletions .github/workflows/app-build-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,37 +69,24 @@ jobs:

- name: Package Name
id: package
run: echo "name=$(basename '${{ inputs.repository }}')" >> ${GITHUB_OUTPUT}
run: echo "name=$(basename '${{ inputs.repository }}')" | tee -a ${GITHUB_OUTPUT}

- name: Determine Cache Directories
- name: Determine Cache Directory
id: dirs
run: |
echo "cookiecutters-data-dir=~/.cookiecutters" >> ${GITHUB_OUTPUT}
if [[ "${{ startsWith(inputs.runner-os, 'ubuntu') }}" == "true" ]]; then
echo "briefcase-data-dir=~/.cache/briefcase" >> ${GITHUB_OUTPUT}
echo "pip-cache-dir=~/.cache/pip" >> ${GITHUB_OUTPUT}
elif [[ "${{ startsWith(inputs.runner-os, 'macos') }}" == "true" ]]; then
echo "briefcase-data-dir=~/Library/Caches/org.beeware.briefcase" >> ${GITHUB_OUTPUT}
echo "pip-cache-dir=~/Library/Caches/pip" >> ${GITHUB_OUTPUT}
echo "docker-cache-dir=~/Library/Containers/com.docker.docker/Data/vms/0/" >> ${GITHUB_OUTPUT}
elif [[ "${{ startsWith(inputs.runner-os, 'windows') }}" == "true" ]]; then
echo "briefcase-data-dir=~/AppData/Local/BeeWare/briefcase/Cache" >> ${GITHUB_OUTPUT}
echo "pip-cache-dir=~/AppData/Local/pip/Cache" >> ${GITHUB_OUTPUT}
echo "docker-cache-dir=C:/ProgramData/DockerDesktop" >> ${GITHUB_OUTPUT}
fi
case "$(tr '[:upper:]' '[:lower:]' <<< '${{ inputs.runner-os }}')" in
ubuntu* ) BRIEFCASE_DIR="~/.cache/briefcase" ;;
macos* ) BRIEFCASE_DIR="~/Library/Caches/org.beeware.briefcase" ;;
windows* ) BRIEFCASE_DIR="~/AppData/Local/BeeWare/briefcase/Cache" ;;
* ) echo "::error::Failed to determine the Briefcase data directory path" ;;
esac
echo "briefcase-data-dir=${BRIEFCASE_DIR}" | tee -a ${GITHUB_OUTPUT}
- name: Cache Briefcase Tools
uses: actions/cache@v3.3.2
with:
key: briefcase-${{ runner.os }}-${{ inputs.repository }}-${{ inputs.framework }}-${{ inputs.target-platform }}-${{ inputs.target-format }}
path: |
${{ steps.dirs.outputs.cookiecutters-data-dir }}
${{ steps.dirs.outputs.briefcase-data-dir }}
${{ steps.dirs.outputs.pip-cache-dir }}
${{ steps.dirs.outputs.docker-cache-dir }}
key: briefcase-${{ inputs.runner-os }}-${{ inputs.repository }}-${{ inputs.framework }}-${{ inputs.target-platform }}-${{ inputs.target-format }}-
path: ${{ steps.dirs.outputs.briefcase-data-dir }}

- name: Determine System python3 Version
id: system-python
Expand All @@ -111,6 +98,10 @@ jobs:
uses: actions/setup-python@v4.7.1
with:
python-version: ${{ inputs.python-version }}
cache: pip
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
- name: Get Packages
# Briefcase will build and package itself in a previous step in its CI
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/app-create-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,14 @@ jobs:
id: package
run: echo "name=$(basename '${{ inputs.repository }}')" >> ${GITHUB_OUTPUT}

- name: Cache Briefcase Tools
uses: actions/cache@v3.3.2
with:
key: briefcase-${{ runner.os }}-${{ inputs.framework }}
path: ~/.cookiecutters

- name: Set up Python
uses: actions/setup-python@v4.7.1
with:
python-version: ${{ inputs.python-version }}
cache: "pip"
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
- name: Get Packages
# Briefcase will build and package itself in a previous step in its CI
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Pre-commit checks
uses: ./.github/workflows/pre-commit-run.yml
with:
pre-commit-source: "pre-commit"
pre-commit-source: pre-commit

test-docs-build-verify:
name: Test Verify Docs Build
Expand Down Expand Up @@ -118,7 +118,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4.7.1
with:
python-version: "3.X"
python-version: 3.X
cache: pip
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
.pre-commit-config.yaml
- name: Install Briefcase
id: briefcase
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/pre-commit-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ jobs:
uses: actions/setup-python@v4.7.1
with:
python-version: ${{ inputs.python-version }}
cache: pip
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
.pre-commit-config.yaml
- name: Cache pre-commit
uses: actions/cache@v3.3.2
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pre-commit-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ jobs:
uses: actions/setup-python@v4.7.1
with:
python-version: 3.X
cache: pip
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
- name: Install pre-commit
run: python -m pip install ${{ inputs.pre-commit-source || 'pre-commit' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
uses: actions/setup-python@v4.7.1
with:
python-version: ${{ inputs.python-version }}
cache: "pip"
cache: pip
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/towncrier-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
uses: actions/setup-python@v4.7.1
with:
python-version: ${{ inputs.python-version }}
cache: "pip"
cache: pip
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
Expand Down

0 comments on commit eb289f2

Please sign in to comment.