Skip to content

Commit 92315b3

Browse files
committed
Update test_readme
1 parent 230fd1c commit 92315b3

File tree

1 file changed

+87
-21
lines changed

1 file changed

+87
-21
lines changed

.github/workflows/test_readme.yml

Lines changed: 87 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,113 @@ on:
77
schedule:
88
- cron: 0 0 */3 * *
99

10+
defaults:
11+
run:
12+
shell: bash
13+
1014
jobs:
11-
no_cache_build:
15+
build:
1216
runs-on: ubuntu-latest
1317

1418
steps:
15-
- run: docker image ls -q | xargs docker rmi
19+
- name: Output matrix
20+
id: set_matrix
21+
uses: actions/github-script@v2
22+
with:
23+
script: |
24+
return {
25+
inspect_image: [
26+
'test_project_scratch',
27+
'hello-world',
28+
'nothing'
29+
],
30+
os: [
31+
'ubuntu-latest',
32+
'windows-latest',
33+
],
34+
include: [
35+
{
36+
inspect_image: 'test_project_scratch',
37+
prepare_command: 'docker-compose -f test_project/docker-compose.yml -p test_project pull',
38+
build_command: 'docker-compose -f test_project/docker-compose.yml -p test_project build',
39+
}, {
40+
inspect_image: 'hello-world',
41+
prepare_command: ':',
42+
build_command: 'docker pull hello-world',
43+
}, {
44+
inspect_image: 'nothing',
45+
os: 'ubuntu-latest',
46+
prepare_command: 'docker tag node:12 nothing',
47+
build_command: ':',
48+
}, {
49+
inspect_image: 'nothing',
50+
os: 'windows-latest',
51+
prepare_command: 'docker tag mcr.microsoft.com/windows/nanoserver:1809 nothing',
52+
build_command: ':',
53+
}, {
54+
branch: process.env.GITHUB_REF.replace('refs/heads/', '')
55+
}
56+
],
57+
exclude: [
58+
{
59+
inspect_image: 'test_project_scratch',
60+
os: 'windows-latest',
61+
},
62+
],
63+
}
64+
65+
outputs:
66+
matrix: ${{ steps.set_matrix.outputs.result }}
67+
68+
test_saving:
69+
if: github.event_name != 'delete'
70+
needs: build
71+
strategy:
72+
matrix: ${{ fromJSON(needs.build.outputs.matrix) }}
73+
runs-on: ${{ matrix.os }}
74+
75+
steps:
1676
- uses: actions/checkout@v2
17-
- run: docker-compose -f test_project/docker-compose.yml -p test_project pull
1877

19-
- uses: satackey/action-docker-layer-caching@v0.0.8
78+
- run: ${{ matrix.prepare_command }}
79+
80+
- uses: satackey/action-docker-layer-caching@master-release
2081
with:
21-
key: docker-layer-caching-${{ github.workflow }}-${{ github.event_name }}-{hash}
22-
restore-keys: docker-layer-caching-${{ github.workflow }}-${{ github.event_name }}-
82+
key: docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
2383

24-
- run: docker image ls -q | xargs docker rmi
25-
- run: docker-compose -f test_project/docker-compose.yml -p test_project build --no-cache
84+
- run: ${{ matrix.build_command }}
2685

27-
cached_build:
28-
runs-on: ubuntu-latest
29-
needs:
30-
- no_cache_build
86+
test_restoring:
87+
needs: [build, test_saving]
88+
strategy:
89+
matrix: ${{ fromJSON(needs.build.outputs.matrix) }}
90+
runs-on: ${{ matrix.os }}
3191

3292
steps:
33-
- run: docker image ls -q | xargs docker rmi
3493
- uses: actions/checkout@v2
35-
- run: docker-compose -f test_project/docker-compose.yml -p test_project pull
3694

37-
- uses: satackey/action-docker-layer-caching@v0.0.8
95+
- run: ${{ matrix.prepare_command }}
96+
97+
- uses: satackey/action-docker-layer-caching@master-release
3898
with:
39-
key: docker-layer-caching-${{ github.workflow }}-${{ github.event_name }}-{hash}
40-
restore-keys: docker-layer-caching-${{ github.workflow }}-${{ github.event_name }}-
99+
key: never-restored-docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
100+
restore-keys: docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-
101+
skip-save: 'true'
102+
103+
- name: Show cached image info
104+
run: docker inspect ${{ matrix.inspect_image }}
41105

42106
- name: Get cached image ID
43-
run: echo ::set-output name=id::$(docker image ls -q test_project_node)
107+
run: echo ::set-output name=id::$(docker image ls -q ${{ matrix.inspect_image }})
44108
id: cached
45109

46-
- run: docker-compose -f test_project/docker-compose.yml -p test_project build
110+
- run: ${{ matrix.build_command }}
111+
112+
- name: Show built image info
113+
run: docker inspect ${{ matrix.inspect_image }}
47114

48115
- name: Show built image ID
49-
run: echo ::set-output name=id::$(docker image ls -q test_project_node)
116+
run: echo ::set-output name=id::$(docker image ls -q ${{ matrix.inspect_image }})
50117
id: latest
51118

52119
- name: Compare cached ID and after build ID
@@ -55,4 +122,3 @@ jobs:
55122
echo cached != latest
56123
exit 1
57124
fi
58-

0 commit comments

Comments
 (0)