-
Notifications
You must be signed in to change notification settings - Fork 6
142 lines (112 loc) · 3.96 KB
/
test.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
name: Build branch
on:
- push
- pull_request
jobs:
build:
name: Build lnd
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
- arm32v6
- arm32v7
ver:
- 0.5
- 0.6
- 0.7
- 0.8
- 0.9
env:
DOCKER_BUILDKIT: 1
APP: lnd
VER_ARCH: "${{matrix.ver}}-${{matrix.arch}}"
steps:
- uses: actions/[email protected]
- name: Verify all patches apply cleanly
run: ./scripts/verify-patches.sh "${{matrix.ver}}"
- name: Setup environment
if: matrix.arch != 'amd64'
run: |
GOARCH="$(echo "${{matrix.arch}}" | grep -oE 'arm(64)?')"
echo ::set-env name=GOARCH::"${GOARCH}"
GOARM="$(echo "${{matrix.arch}}" | grep arm32 | tail -c 2)"
echo ::set-env name=GOARM::"${GOARM}"
- name: Build lnd:${{matrix.ver}}-${{matrix.arch}}
run: |
ARCH="${{matrix.arch}}"
if [[ "${{matrix.arch}}" == "arm64" ]]; then
ARCH="arm64v8"
fi
docker build --no-cache "${{matrix.ver}}/" \
--build-arg "ARCH=${ARCH}" \
--build-arg "GOARCH=${GOARCH}" \
--build-arg "GOARM=${GOARM}" \
--tag "${APP}:${VER_ARCH}"
- name: Show built image details
run: docker images "${APP}"
- name: Save image to a .tgz file
run: |
mkdir -p image/
docker save "${APP}:${VER_ARCH}" | gzip > "image/${APP}-${VER_ARCH}.tgz"
- name: Print sha256sum of produced Docker image
run: sha256sum "image/${APP}-${VER_ARCH}.tgz"
- name: Add Docker image as build artifact
uses: actions/[email protected]
with:
name: docker-images
path: image/
- name: Extract binaries from the built image
run: |
mkdir -p bins/ binaries/
ID=$(docker create "${APP}:${VER_ARCH}")
docker cp "${ID}:/usr/local/bin/${APP}" bins/
docker cp "${ID}:/usr/local/bin/lncli" bins/
docker rm "${ID}"
# Compress both binaries into a one archive
tar -C bins/ -cvaf "binaries/${APP}-${VER_ARCH}.tgz" .
- name: Print sha256sum of extracted binaries
run: sha256sum bins/*
- name: Add raw binaries as build artifacts
uses: actions/[email protected]
with:
name: binaries
path: binaries/
test:
name: Check sanity of images
runs-on: ubuntu-18.04
needs: build
env:
QEMU_VERSION: v4.2.0
APP: lnd
steps:
- name: Download build artifact
uses: actions/[email protected]
with:
name: docker-images
- name: Print sha256sum of all Docker images
run: sha256sum docker-images/*
- name: Register self-compiled qemu
run: docker run --rm --privileged "meedamian/simple-qemu:${QEMU_VERSION}" -p yes
- name: Load all images locally
run: ls -d docker-images/* | xargs -I % docker load -i "%"
- name: List all tagged images
run: docker images "${APP}"
- name: Run sanity checks
env:
DIR: /usr/local/bin
run: |
for tag in $(docker images "${APP}" --format "{{.Tag}}"); do
echo
echo "~~~~~ ${APP}:${tag} ~~~~~"
docker inspect "${APP}:${tag}" | jq '.'
docker run --rm "${APP}:${tag}" --version
docker run --rm --entrypoint=lncli "${APP}:${tag}" --version
docker run --rm --entrypoint=uname "${APP}:${tag}" -a
docker run --rm --entrypoint=cat "${APP}:${tag}" /etc/os-release
docker run --rm --entrypoint=sha256sum "${APP}:${tag}" ${DIR}/${APP} ${DIR}/lncli
docker run --rm --entrypoint=sh -u=root "${APP}:${tag}" -c "apk add --no-cache file && file ${DIR}/${APP} ${DIR}/lncli"
done