Skip to content

Commit 7cd1d93

Browse files
authored
Update release.yml
1 parent 1c08af1 commit 7cd1d93

File tree

1 file changed

+42
-88
lines changed

1 file changed

+42
-88
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,27 @@ jobs:
4141
#
4242
# test built image caching
4343

44-
test_saving_built:
44+
test_saving:
45+
strategy:
46+
matrix:
47+
inspect_image:
48+
- test_project_node
49+
- amazon/aws-cli
50+
include:
51+
- inspect_image: test_project_node
52+
prepare_command: docker-compose -f test_project/docker-compose.yml -p test_project pull
53+
build_command: docker-compose -f test_project/docker-compose.yml -p test_project build
54+
- inspect_image: amazon/aws-cli
55+
prepare_command: echo
56+
build_command: docker pull amazon/aws-cli
57+
4558
runs-on: ubuntu-latest
4659
needs: build
4760
if: github.event_name != 'delete'
4861

4962
steps:
5063
- uses: actions/checkout@v2
51-
- run: docker-compose -f test_project/docker-compose.yml -p test_project pull
64+
- run: ${{ matrix.prepare_command }}
5265

5366
- name: Extract
5467
id: extract
@@ -64,92 +77,33 @@ jobs:
6477
- uses: ./action-dlc
6578
name: Run satackey/action-docker-layer-caching@${{ steps.extract.outputs.branch }}
6679
with:
67-
key: docker-layer-caching-test_project_node-sha:${{ github.sha }}-{hash}
68-
restore-keys: docker-layer-caching-test_project_node-sha:${{ github.sha }}-
69-
70-
- run: docker-compose -f test_project/docker-compose.yml -p test_project build
80+
key: docker-layer-caching-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
81+
restore-keys: docker-layer-caching-${{ matrix.inspect_image }}-sha:${{ github.sha }}-
82+
83+
- run: ${{ matrix.build_command }}
84+
85+
test_restoring:
86+
strategy:
87+
matrix:
88+
inspect_image:
89+
- test_project_node
90+
- amazon/aws-cli
91+
include:
92+
- inspect_image: test_project_node
93+
prepare_command: docker-compose -f test_project/docker-compose.yml -p test_project pull
94+
build_command: docker-compose -f test_project/docker-compose.yml -p test_project build
95+
- inspect_image: amazon/aws-cli
96+
prepare_command: echo
97+
build_command: docker pull amazon/aws-cli
7198

72-
test_restoring_built:
7399
runs-on: ubuntu-latest
74-
needs: test_saving_built
100+
needs: test_saving
75101

76102
steps:
77103
- uses: actions/checkout@v2
78-
- run: docker-compose -f test_project/docker-compose.yml -p test_project pull
79-
80-
- name: Extract
81-
id: extract
82-
run: |
83-
echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"
84-
85-
- name: Download action
86-
uses: actions/download-artifact@v2
87-
with:
88-
name: built
89-
path: action-dlc
90-
91-
- uses: ./action-dlc
92-
name: Run satackey/action-docker-layer-caching@${{ steps.extract.outputs.branch }}
93-
with:
94-
key: docker-layer-caching-test_project_node-sha:${{ github.sha }}-{hash}
95-
restore-keys: docker-layer-caching-test_project_node-sha:${{ github.sha }}-
96-
97-
- name: Show cached image info
98-
run: docker inspect test_project_node
99-
100-
- name: Get cached image ID
101-
run: echo ::set-output name=id::$(docker image ls -q test_project_node)
102-
id: cached
103-
104-
- run: docker-compose -f test_project/docker-compose.yml -p test_project build
105-
106-
- name: Show built image info
107-
run: docker inspect test_project_node
108-
109-
- name: Show built image ID
110-
run: echo ::set-output name=id::$(docker image ls -q test_project_node)
111-
id: latest
112-
113-
- name: Compare cached ID and after build ID
114-
run: |
115-
if [ ! '${{ steps.cached.outputs.id }}' = '${{ steps.latest.outputs.id }}' ];then
116-
echo cached != latest
117-
exit 1
118-
fi
119-
120-
#
121-
# test pulled image caching
122-
123-
test_saving_pulled:
124-
runs-on: ubuntu-latest
125-
needs: build
126-
if: github.event_name != 'delete'
127-
128-
steps:
129-
- name: Extract
130-
id: extract
131-
run: |
132-
echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"
133104

134-
- name: Download action
135-
uses: actions/download-artifact@v2
136-
with:
137-
name: built
138-
path: action-dlc
105+
- run: ${{ matrix.prepare_command }}
139106

140-
- uses: ./action-dlc
141-
name: Run satackey/action-docker-layer-caching@${{ steps.extract.outputs.branch }}
142-
with:
143-
key: docker-layer-caching-aws-cli-sha:${{ github.sha }}-{hash}
144-
restore-keys: docker-layer-caching-aws-cli-sha:${{ github.sha }}-
145-
146-
- run: docker run --rm amazon/aws-cli --version
147-
148-
test_restoring_pulled:
149-
runs-on: ubuntu-latest
150-
needs: test_saving_pulled
151-
152-
steps:
153107
- name: Extract
154108
id: extract
155109
run: |
@@ -164,23 +118,23 @@ jobs:
164118
- uses: ./action-dlc
165119
name: Run satackey/action-docker-layer-caching@${{ steps.extract.outputs.branch }}
166120
with:
167-
key: docker-layer-caching-aws-cli-sha:${{ github.sha }}-{hash}
168-
restore-keys: docker-layer-caching-aws-cli-sha:${{ github.sha }}-
121+
key: docker-layer-caching-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
122+
restore-keys: docker-layer-caching-${{ matrix.inspect_image }}-sha:${{ github.sha }}-
169123

170124
- name: Show cached image info
171-
run: docker inspect amazon/aws-cli
125+
run: docker inspect ${{ matrix.inspect_image }}
172126

173127
- name: Get cached image ID
174-
run: echo ::set-output name=id::$(docker image ls -q amazon/aws-cli)
128+
run: echo ::set-output name=id::$(docker image ls -q ${{ matrix.inspect_image }})
175129
id: cached
176130

177-
- run: docker pull amazon/aws-cli
131+
- run: ${{ matrix.build_command }}
178132

179133
- name: Show built image info
180-
run: docker inspect amazon/aws-cli
134+
run: docker inspect ${{ matrix.inspect_image }}
181135

182136
- name: Show built image ID
183-
run: echo ::set-output name=id::$(docker image ls -q amazon/aws-cli)
137+
run: echo ::set-output name=id::$(docker image ls -q ${{ matrix.inspect_image }})
184138
id: latest
185139

186140
- name: Compare cached ID and after build ID

0 commit comments

Comments
 (0)