Skip to content

Commit

Permalink
ci: cache taxonomies
Browse files Browse the repository at this point in the history
  • Loading branch information
McCio committed Oct 30, 2024
1 parent d969838 commit 0827b10
Showing 1 changed file with 68 additions and 4 deletions.
72 changes: 68 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,26 @@ jobs:
with:
# needs depth to run git log below
fetch-depth: 50
- uses: actions/cache@v4
id: cache
with:
path: ./build-cache
key: taxonomies-${{ hashFiles('taxonomies/**') }}
restore-keys: taxonomies-
- if: steps.cache.outputs.cache-hit == 'true'
name: Prepare build_cache volumes
run: |
proj=po_off
docker volume create \
--label com.docker.compose.project=$proj \
--label com.docker.compose.version=2.29.7 \
--label com.docker.compose.volume=build_cache \
${proj}_build_cache
docker container run --rm -v ./build-cache:/from -v ${proj}_build_cache:/to alpine ash -c 'cd /from ; cp -av . /to'
- name: build
run: make build container=backend
- name: push backend image as artifact
uses: ishworkh/docker-image-artifact-upload@v1
uses: ishworkh/container-image-artifact-upload@v2.0.0
with:
image: "openfoodfacts-server/backend:dev"
- name: Fetch origin/main
Expand All @@ -76,6 +92,9 @@ jobs:
git ls-files taxonomies/ | xargs -I{} git log -1 --date=format:%Y%m%d%H%M.%S --format='touch -t %ad "{}"' "{}" | bash
- name: Rebuild taxonomies
run: make build_taxonomies GITHUB_TOKEN="${{ secrets.TAXONOMY_CACHE_GITHUB_TOKEN }}"
- name: Prepare taxonomies for cache
run: |
docker container run --rm -v po_off_build_cache:/from -v "$(pwd)"/build-cache:/to alpine ash -c 'cd /from ; cp -av . /to'
check_perl:
name: 🐪 Check Perl
Expand All @@ -96,8 +115,23 @@ jobs:
# see https://stackoverflow.com/a/60984318/2886726
run: |
git ls-files taxonomies/ | xargs -I{} git log -1 --date=format:%Y%m%d%H%M.%S --format='touch -t %ad "{}"' "{}" | bash
- uses: actions/cache/restore@v4
id: cache
with:
path: ./build-cache
key: taxonomies-${{ hashFiles('taxonomies/**') }}
restore-keys: taxonomies-
- if: steps.cache.outputs.cache-hit == 'true'
name: Prepare build_cache volumes
run: |
docker volume create \
--label com.docker.compose.project=po_off \
--label com.docker.compose.version=2.29.7 \
--label com.docker.compose.volume=build_cache \
po_off_build_cache
docker container run --rm -v ./build-cache:/from -v po_off_build_cache:/to alpine ash -c 'cd /from ; cp -av . /to'
- name: Download backend image from artifacts
uses: ishworkh/docker-image-artifact-download@v1
uses: ishworkh/container-image-artifact-download@v2.0.0
with:
image: "openfoodfacts-server/backend:dev"
- name: build taxonomies (should use cache)
Expand All @@ -119,6 +153,21 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/cache/restore@v4
id: cache
with:
path: ./build-cache
key: taxonomies-${{ hashFiles('taxonomies/**') }}
restore-keys: taxonomies-
- if: steps.cache.outputs.cache-hit == 'true'
name: Prepare build_cache volumes
run: |
docker volume create \
--label com.docker.compose.project=po_off_test \
--label com.docker.compose.version=2.29.7 \
--label com.docker.compose.volume=build_cache \
po_off_test_build_cache
docker container run --rm -v ./build-cache:/from -v po_off_test_build_cache:/to alpine ash -c 'cd /from ; cp -av . /to'
- name: Fetch origin/main
# we need origin/main to have comparison linting work
run: |
Expand All @@ -130,7 +179,7 @@ jobs:
run: |
git ls-files taxonomies/ | xargs -I{} git log -1 --date=format:%Y%m%d%H%M.%S --format='touch -t %ad "{}"' "{}" | bash
- name: Download backend image from artifacts
uses: ishworkh/docker-image-artifact-download@v1
uses: ishworkh/container-image-artifact-download@v2.0.0
with:
image: "openfoodfacts-server/backend:dev"
- name: tests
Expand All @@ -157,8 +206,23 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/cache/restore@v4
id: cache
with:
path: ./build-cache
key: taxonomies-${{ hashFiles('taxonomies/**') }}
restore-keys: taxonomies-
- if: steps.cache.outputs.cache-hit == 'true'
name: Prepare build_cache volumes
run: |
docker volume create \
--label com.docker.compose.project=po_off \
--label com.docker.compose.version=2.29.7 \
--label com.docker.compose.volume=build_cache \
po_off_build_cache
docker container run --rm -v ./build-cache:/from -v po_off_build_cache:/to alpine ash -c 'cd /from ; cp -av . /to'
- name: Download backend image from artifacts
uses: ishworkh/docker-image-artifact-download@v1
uses: ishworkh/container-image-artifact-download@v2.0.0
with:
image: "openfoodfacts-server/backend:dev"
- name: set right UID and GID in .envrc
Expand Down

0 comments on commit 0827b10

Please sign in to comment.