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 335bbcc
Showing 1 changed file with 92 additions and 4 deletions.
96 changes: 92 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,31 @@ 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: |
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 -it -v ./build-cache:/from -v po_off_build_cache:/to alpine ash -c 'cd /from ; cp -av . /to'
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 -it -v ./build-cache:/from -v po_off_test_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 +97,10 @@ 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: |
mkdir -p build-cache
docker container run --rm -it -v po_off_build_cache:/from -v ./build-cache:/to alpine ash -c 'cd /from ; cp -av . /to'
check_perl:
name: 🐪 Check Perl
Expand All @@ -96,8 +121,29 @@ 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 -it -v ./build-cache:/from -v po_off_build_cache:/to alpine ash -c 'cd /from ; cp -av . /to'
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 -it -v ./build-cache:/from -v po_off_test_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
with:
image: "openfoodfacts-server/backend:dev"
- name: build taxonomies (should use cache)
Expand All @@ -119,6 +165,27 @@ 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 -it -v ./build-cache:/from -v po_off_build_cache:/to alpine ash -c 'cd /from ; cp -av . /to'
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 -it -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 +197,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
with:
image: "openfoodfacts-server/backend:dev"
- name: tests
Expand All @@ -157,8 +224,29 @@ 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 -it -v ./build-cache:/from -v po_off_build_cache:/to alpine ash -c 'cd /from ; cp -av . /to'
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 -it -v ./build-cache:/from -v po_off_test_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
with:
image: "openfoodfacts-server/backend:dev"
- name: set right UID and GID in .envrc
Expand Down

0 comments on commit 335bbcc

Please sign in to comment.