-
Notifications
You must be signed in to change notification settings - Fork 56
125 lines (105 loc) · 3.59 KB
/
test_readme.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Readme Test
on:
push:
branches:
- master
schedule:
- cron: 0 0 */3 * *
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Output matrix
id: set_matrix
uses: actions/github-script@v2
with:
script: |
return {
inspect_image: [
'test_project_scratch',
'hello-world',
'nothing'
],
os: [
'ubuntu-latest',
'windows-latest',
],
include: [
{
inspect_image: 'test_project_scratch',
prepare_command: 'docker-compose -f test_project/docker-compose.yml -p test_project pull',
build_command: 'docker-compose -f test_project/docker-compose.yml -p test_project build',
}, {
inspect_image: 'hello-world',
prepare_command: ':',
build_command: 'docker pull hello-world',
}, {
inspect_image: 'nothing',
os: 'ubuntu-latest',
prepare_command: 'docker tag node:12 nothing',
build_command: ':',
}, {
inspect_image: 'nothing',
os: 'windows-latest',
prepare_command: 'docker tag mcr.microsoft.com/windows/nanoserver:1809 nothing',
build_command: ':',
}, {
branch: process.env.GITHUB_REF.replace('refs/heads/', '')
}
],
exclude: [
{
inspect_image: 'test_project_scratch',
os: 'windows-latest',
},
],
}
outputs:
matrix: ${{ steps.set_matrix.outputs.result }}
test_saving:
if: github.event_name != 'delete'
needs: build
strategy:
matrix: ${{ fromJSON(needs.build.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: ${{ matrix.prepare_command }}
- uses: satackey/action-docker-layer-caching@master-release
with:
key: docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
restore-keys: ''
- run: ${{ matrix.build_command }}
test_restoring:
needs: [build, test_saving]
strategy:
matrix: ${{ fromJSON(needs.build.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: ${{ matrix.prepare_command }}
- uses: satackey/action-docker-layer-caching@master-release
with:
key: never-restored-docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
restore-keys: docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-
skip-save: 'true'
- name: Show cached image info
run: docker inspect ${{ matrix.inspect_image }}
- name: Get cached image ID
run: echo ::set-output name=id::$(docker image ls -q ${{ matrix.inspect_image }})
id: cached
- run: ${{ matrix.build_command }}
- name: Show built image info
run: docker inspect ${{ matrix.inspect_image }}
- name: Show built image ID
run: echo ::set-output name=id::$(docker image ls -q ${{ matrix.inspect_image }})
id: latest
- name: Compare cached ID and after build ID
run: |
if [ ! '${{ steps.cached.outputs.id }}' = '${{ steps.latest.outputs.id }}' ];then
echo cached != latest
exit 1
fi