forked from MiczFlor/RPi-Jukebox-RFID
-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (131 loc) · 5.49 KB
/
docker_debian_unified.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Test Install Scripts Debian Unified
# let only one instance run the test so cache is not corrupted.
# cancel already running instances as only the last run will be relevant
concurrency:
group: ${{ github.ref }}-debian-unified
cancel-in-progress: true
on:
schedule:
# run at 5 every sunday
- cron: '0 5 * * 0'
push:
branches-ignore:
- 'future3/**'
pull_request:
# The branches below must be a subset of the branches above
branches: [ develop ]
workflow_dispatch:
env:
DOCKER_IMAGE_NAME: rpi-jukebox-rfid
CACHE_SCOPE: ${{ github.ref }}-debian-unified
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
runs_on: ubuntu-latest
matrix_debian_version: "['bullseye', 'buster']"
cache_scope: ${{ steps.set-cache_scope.outputs.cache_scope }}
image_tag_name: ${{ steps.set-image_tag_name.outputs.image_tag_name }}
image_file_path: ${{ steps.set-image_file_path.outputs.image_file_path }}
cache_key: ${{ steps.set-cache_key.outputs.cache_key }}
steps:
- name: Set Output cache_scope
id: set-cache_scope
run: echo "cache_scope="${{ env.CACHE_SCOPE }}-{0}" >> $GITHUB_OUTPUT
- name: Set Output image_tag_name
id: set-image_tag_name
run: echo "image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:{0}-test" >> $GITHUB_OUTPUT
- name: Set Output image_file_path
id: set-image_file_path
run: echo "image_file_path=./${{ env.DOCKER_IMAGE_NAME }}-{0}.tar" >> $GITHUB_OUTPUT
- name: Set Output cache_key
id: set-cache_key
run: echo "cache_key=${{ steps.set-cache_scope.outputs.cache_scope }}-${{ github.sha }}#${{ github.run_attempt }}" >> $GITHUB_OUTPUT
build:
needs: [prepare]
runs-on: ${{ needs.prepare.outputs.runs_on }}
strategy:
fail-fast: false
matrix:
debian_version: ${{ fromJSON(needs.prepare.outputs.matrix_debian_version) }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build Image ARMv7 - Base
uses: docker/build-push-action@v5
with:
context: .
load: false
push: false
file: ./ci/Dockerfile.debian.test_install_unified.armv7
target: user
platforms: linux/arm/v7
tags: ${{ format( needs.prepare.outputs.image_tag_name, matrix.debian_version) }}-base
cache-from: type=gha,scope=${{ format( needs.prepare.outputs.cache_scope, matrix.debian_version) }}
cache-to: type=gha,mode=max,scope=${{ format( needs.prepare.outputs.cache_scope, matrix.debian_version) }}
build-args: |
DEBIAN_VERSION=${{ matrix.debian_version }}
- name: Build Image ARMv7 - Update
uses: docker/build-push-action@v5
with:
context: .
load: false
push: false
file: ./ci/Dockerfile.debian.test_install_unified.armv7
target: test-update
platforms: linux/arm/v7
tags: ${{ format( needs.prepare.outputs.image_tag_name, matrix.debian_version) }}
cache-from: type=gha,scope=${{ format( needs.prepare.outputs.cache_scope, matrix.debian_version) }}
# DON'T use 'cache-to' here as then the layer is cached and this build would be useless
outputs: type=docker,dest=${{ format( needs.prepare.outputs.image_file_path, matrix.debian_version) }}
build-args: |
DEBIAN_VERSION=${{ matrix.debian_version }}
GIT_BRANCH=${{ github.ref_name }}
GIT_URL=${{ github.server_url }}/${{ github.repository }}
- name: Cache Check Docker Image
uses: actions/cache/restore@v3
id: cache-restore
with:
lookup-only: true
key: ${{ format( needs.prepare.outputs.cache_key, matrix.debian_version) }}
path: ${{ format( needs.prepare.outputs.image_file_path, matrix.debian_version) }}
- name: Cache Save Docker Image
uses: actions/cache/save@v3
if: ${{ ! steps.cache-restore.outputs.cache-hit }}
with:
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
path: ${{ format( needs.prepare.outputs.image_file_path, matrix.debian_version) }}
test:
needs: [prepare, build]
runs-on: ${{ needs.prepare.outputs.runs_on }}
strategy:
fail-fast: false
matrix:
debian_version: ${{ fromJSON(needs.prepare.outputs.matrix_debian_version) }}
username: [hans] #[pi, hans]
test_script: [run_installation_tests.sh, run_installation_tests2.sh, run_installation_tests3.sh]
steps:
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Cache Restore Docker Image
uses: actions/cache/restore@v3
with:
key: ${{ needs.prepare.outputs.cache_key }}
path: ${{ format( needs.prepare.outputs.image_file_path, matrix.debian_version) }}
fail-on-cache-miss: true
- name: Load Docker Image
run: |
docker load --input ${{ format( needs.prepare.outputs.image_file_path, matrix.debian_version) }}
- name: Run Test ${{ matrix.debian_version }}-${{ matrix.username }}-${{ matrix.test_script }}
uses: tj-actions/docker-run@v2
with:
image: ${{ format( needs.prepare.outputs.image_tag_name, matrix.debian_version) }}
options: --platform linux/arm/v7 --user ${{ matrix.username }}
name: ${{ matrix.test_script }}
args: |
./${{ matrix.test_script }}