-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (141 loc) · 4.5 KB
/
docker-image.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
name: "Docker Image CI"
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
workflow_dispatch:
inputs:
release:
type: boolean
description: "Release the built Docker image into 'ghcr.io'"
jobs:
lint:
name: "Lint"
runs-on: "ubuntu-20.04"
steps:
- uses: "actions/checkout@v4"
- name: "Download ShellCheck"
uses: "robinraju/release-downloader@v1.10"
with:
repository: "koalaman/shellcheck"
tag: "v0.10.0"
filename: "shellcheck-v*.linux.x86_64.tar.xz"
tarBall: false
zipBall: false
- name: "Extract ShellCheck"
run: |
tar xvf ./shellcheck-v*.tar.xz
rm -v ./shellcheck-v*.tar.xz
mv -v ./shellcheck-v*/shellcheck "./shellcheck"
rm -rv ./shellcheck-v*
./shellcheck --version
- name: "Install PyCodeStyle"
run: |
sudo apt-get install -y --no-install-recommends \
python3-pycodestyle
- name: "ShellCheck"
run: |
./shellcheck \
--color=always \
etc/cron.*/* \
usr/local/*bin/*
- name: "PyCodeStyle"
run: |
python3 -m pycodestyle \
.
build:
name: "Build ${{ github.event_name == 'workflow_dispatch' && inputs.release && 'and Deploy' || '' }} Docker Image"
env:
RUNS_ON: "ubuntu-20.04"
permissions:
packages: "write"
runs-on: "ubuntu-20.04"
steps:
- name: "Build Docker Image"
uses: "docker/build-push-action@v5"
with:
load: true
tags: "distcc-docker:${{ env.RUNS_ON }}"
- name: "Test starting the container"
run: |
docker run \
--init \
--rm \
"distcc-docker:${{ env.RUNS_ON }}" \
--jobs $(nproc) \
-- \
bash -c \
"set -x; ps fauxw; /usr/bin/ls -alh .; /usr/bin/ls -alh /var/log; cat /var/log/*; exit;"
- name: "Test that \"dcc_free_mem\" is reported"
run: |
set -ex
docker run \
--detach \
--init \
--name "distcc-1" \
--publish "3632:3632/tcp" \
--publish "3633:3633/tcp" \
--rm \
"distcc-docker:${{ env.RUNS_ON }}" \
--jobs $(nproc) \
-- \
bash -c "set -x; sleep 120; exit;"
sleep 10
STAT_RESULT="$(curl "http://localhost:3633" | grep "dcc_free_mem")"
if [ -z "$STAT_RESULT" ]; then
echo "Server did not report 'dcc_free_mem'!" >&2
exit 1
fi
docker kill "distcc-1"
- name: "Test compilation in the container"
run: |
set -ex
sudo apt-get update -y
sudo apt-get install distcc g++ --no-install-recommends
sudo update-distcc-symlinks
docker run \
--detach \
--init \
--name "distcc-1" \
--publish "3632:3632/tcp" \
--publish "3633:3633/tcp" \
--rm \
"distcc-docker:${{ env.RUNS_ON }}" \
--jobs $(nproc) \
-- \
bash -c "set -x; sleep 120; exit;"
sleep 10
curl "http://localhost:3633"
echo "int main() { return MY_EXIT_CODE; }" >> main.cpp
DISTCC_HOSTS="127.0.0.1:3632/$(nproc),lzo" \
distcc /usr/bin/g++ \
-D MY_EXIT_CODE=42 \
-c \
./main.cpp \
-o main.o
rm -v main.cpp
curl "http://localhost:3633" | grep "dcc_compile_ok 1"
docker kill "distcc-1"
/usr/bin/g++ main.o -o main
set +e
./main
if [ "$?" -ne 42 ]; then
echo "Unexpected error code obtained!" >&2
exit 1
fi
- name: "Log in to GitHub Container Registry (GHCR)"
if: "github.ref == 'refs/heads/master' && github.event_name == 'workflow_dispatch' && inputs.release"
uses: "docker/login-action@v3"
with:
registry: "ghcr.io"
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: "Upload image to GHCR"
if: "github.ref == 'refs/heads/master' && github.event_name == 'workflow_dispatch' && inputs.release"
uses: "docker/build-push-action@v5"
with:
push: true
tags: "ghcr.io/${{ github.actor }}/distcc-docker:${{ env.RUNS_ON }}"