Skip to content

Commit cd1a770

Browse files
committed
15 | Add caching to workflow
1 parent ca13457 commit cd1a770

File tree

2 files changed

+45
-26
lines changed

2 files changed

+45
-26
lines changed

.github/workflows/test.yaml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,29 @@ jobs:
3333
--cache-to=type=local,dest=/tmp/.buildx-cache,mode=max \
3434
-t flask-inputfilter . --load
3535
36-
- name: Save flask-inputfilter image
37-
run: docker save -o flask-inputfilter.tar flask-inputfilter
38-
39-
- name: Upload flask-inputfilter artifact
40-
uses: actions/upload-artifact@v4
41-
with:
42-
name: flask-inputfilter-image
43-
path: flask-inputfilter.tar
44-
45-
test:
46-
runs-on: ubuntu-latest
47-
48-
steps:
49-
- name: Checkout code
50-
uses: actions/checkout@v4
51-
52-
- name: Download flask-inputfilter artifact
53-
uses: actions/download-artifact@v4
54-
with:
55-
name: flask-inputfilter-image
56-
57-
- name: Load flask-inputfilter image
58-
run: docker load -i flask-inputfilter.tar
36+
# - name: Save flask-inputfilter image
37+
# run: docker save -o flask-inputfilter.tar flask-inputfilter
38+
#
39+
# - name: Upload flask-inputfilter artifact
40+
# uses: actions/upload-artifact@v4
41+
# with:
42+
# name: flask-inputfilter-image
43+
# path: flask-inputfilter.tar
44+
#
45+
# test:
46+
# runs-on: ubuntu-latest
47+
#
48+
# steps:
49+
# - name: Checkout code
50+
# uses: actions/checkout@v4
51+
#
52+
# - name: Download flask-inputfilter artifact
53+
# uses: actions/download-artifact@v4
54+
# with:
55+
# name: flask-inputfilter-image
56+
#
57+
# - name: Load flask-inputfilter image
58+
# run: docker load -i flask-inputfilter.tar
5959

6060
- name: Run tests in Docker and upload coverage to Coveralls
6161
env:

.github/workflows/test_env.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,32 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
1616

17-
- name: Build Docker image
18-
run: docker build -f env_configs/Dockerfile . -t flask-inputfilter-env
17+
- name: Cache Docker layers
18+
uses: actions/cache@v4
19+
with:
20+
path: /tmp/.buildx-cache
21+
key: ${{ runner.os }}-docker-flask-inputfilter-env-${{ hashFiles('Dockerfile', '**') }}
22+
restore-keys: |
23+
${{ runner.os }}-docker-flask-inputfilter-env-
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v2
27+
with:
28+
driver-opts: image=moby/buildkit:latest
29+
30+
- name: Build flask-inputfilter-env image with cache
31+
run: |
32+
docker buildx build \
33+
--cache-from=type=local,src=/tmp/.buildx-cache \
34+
--cache-to=type=local,dest=/tmp/.buildx-cache,mode=max \
35+
-t flask-inputfilter-env \
36+
-f env_configs/Dockerfile \
37+
. --load
1938
2039
- name: Run tests in Docker
2140
run: |
2241
set -x # Print commands and their arguments as they are executed.
2342
set -e # Exit immediately if a command exits with a non-zero status.
2443
set -u # Exit immediately if a variable is not defined.
2544
26-
docker run flask-inputfilter-env tox
45+
docker run --rm flask-inputfilter-env tox

0 commit comments

Comments
 (0)