-
Notifications
You must be signed in to change notification settings - Fork 70
231 lines (200 loc) · 8.46 KB
/
test.yml
File metadata and controls
231 lines (200 loc) · 8.46 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: CI
on:
push:
branches:
- main
- release-1.[0-9]+
pull_request:
branches:
- main
- release-1.[0-9]+
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Lint
# Based on https://github.com/zavoloklom/docker-compose-linter/tree/main?tab=readme-ov-file
run: |
npx --yes dclint .
test:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-24.04
- ubuntu-24.04-arm
tool:
- docker
- podman
userConfig:
- "false"
- "true"
composeConfig:
- name: "default"
cliArgs: ""
- name: "corporate-proxy"
cliArgs: "-f compose.yaml -f compose-with-corporate-proxy.yaml"
- name: "dynamic-plugins-root"
cliArgs: "-f compose.yaml -f compose-dynamic-plugins-root.yaml"
- name: "orchestrator-workflow"
cliArgs: "-f compose.yaml -f orchestrator/compose.yaml"
- name: "developer-lightspeed"
cliArgs: "-f compose.yaml -f developer-lightspeed/compose.yaml"
name: "${{ matrix.tool }} compose - ${{ matrix.composeConfig.name }}${{ matrix.os != 'ubuntu-24.04' && format(' - {0}', matrix.os) || '' }}${{ matrix.userConfig == 'true' && ' - user config' || '' }}"
runs-on: ${{ matrix.os }}
env:
DOCKER_COMPOSE_VERSION: v5.0.1
PODMAN_IMAGE: quay.io/podman/stable:v5
# The default corporate proxy image is located on registry.redhat.io, which requires authentication.
CORPORATE_PROXY_IMAGE: docker.io/ubuntu/squid:latest
steps:
- uses: actions/checkout@v6
- name: Remove conflicting packages
run: |
# Remove any previous installations of Podman and Docker
for pkg in docker.io \
docker-doc \
docker-compose \
docker-compose-v2 \
podman-docker \
containerd \
crun \
runc \
buildah \
; do
sudo apt-get remove --purge -y $pkg || true
done
- name: Update Docker version
# https://docs.docker.com/engine/install/ubuntu#install-using-the-repository
# Docker is also needed for Podman tests (to run the Podman container)
run: |
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin
# Install standalone docker-compose for consistent version across docker/podman tests
echo "Installing docker-compose $DOCKER_COMPOSE_VERSION..."
sudo curl -fsSL "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-$(uname -m)" \
-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Also install as Docker CLI plugin
sudo mkdir -p /usr/local/lib/docker/cli-plugins
sudo ln -sf /usr/local/bin/docker-compose /usr/local/lib/docker/cli-plugins/docker-compose
- name: Setup Podman container environment
id: setup-podman
if: ${{ matrix.tool == 'podman' }}
uses: rm3l/setup-containerized-podman@7e2e9a2ddc2da87cbe754c0ed8975b7368388f56 # v2.0.0
with:
podman-image: ${{ env.PODMAN_IMAGE }}
compose-provider: docker-compose
docker-compose-version: ${{ env.DOCKER_COMPOSE_VERSION }}
env: |
CORPORATE_PROXY_IMAGE=${{ env.CORPORATE_PROXY_IMAGE }}
- name: Display container engine version
run: |
echo "*** ${{ matrix.tool }} version ***"
${{ matrix.tool }} version
echo
echo "*** ${{ matrix.tool }} compose version ***"
${{ matrix.tool }} compose version
- name: ${{ matrix.tool }} info
run: ${{ matrix.tool }} info
- name: Compose config
run: ${{ matrix.tool }} compose ${{ matrix.composeConfig.cliArgs }} config
- name: Add user-specific configuration
if: ${{ matrix.userConfig == 'true' }}
env:
# https://docs.github.com/en/actions/how-tos/monitor-workflows/enable-debug-logging#enabling-runner-diagnostic-logging
LOG_LEVEL: ${{ vars.ACTIONS_RUNNER_DEBUG == 'true' && 'debug' || 'info' }}
run: |
# Custom .env file
cat <<EOF > .env
LOG_LEVEL=${{ env.LOG_LEVEL }}
ROARR_LOG=true
NODE_DEBUG=fetch
GITHUB_APP_APP_ID=123456
GITHUB_APP_CLIENT_ID=MY_GITHUB_APP_CLIENT_ID
GITHUB_APP_CLIENT_SECRET=MY_GITHUB_APP_CLIENT_SECRET
GITHUB_APP_WEBHOOK_SECRET=MY_GITHUB_APP_WEBHOOK_SECRET
GITHUB_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nxxx\n-----END RSA PRIVATE KEY-----" # notsecret
EOF
# Custom dynamic-plugins.override.yaml
cat <<EOF > configs/dynamic-plugins/dynamic-plugins.override.yaml
includes: [dynamic-plugins.default.yaml]
plugins:
- package: ./dynamic-plugins/dist/red-hat-developer-hub-backstage-plugin-bulk-import-backend-dynamic
disabled: false
- package: ./dynamic-plugins/dist/red-hat-developer-hub-backstage-plugin-bulk-import
disabled: false
EOF
# Custom extra files
cp -vr configs/extra-files/github-app-credentials.example.yaml configs/extra-files/github-app-credentials.yaml
# Custom app-config.local.yaml
cp -vr configs/app-config/app-config.local.example.yaml configs/app-config/app-config.local.yaml
# Custom users.override.yaml
cp configs/catalog-entities/users.override.example.yaml configs/catalog-entities/users.override.yaml
# Custom components.override.yaml
cp configs/catalog-entities/components.override.example.yaml configs/catalog-entities/components.override.yaml
- name: Create dynamic plugins directory
if: ${{ matrix.composeConfig.name == 'dynamic-plugins-root' }}
run: |
mkdir -p dynamic-plugins-root
- name: Start app
run: |
${{ matrix.tool }} compose ${{ matrix.composeConfig.cliArgs }} up --detach --quiet-pull
${{ matrix.tool }} compose ${{ matrix.composeConfig.cliArgs }} ps
- name: Wait for HTTP 200 response from homepage
run: |
max=50
i=0
echo "Waiting for localhost to respond with status code 200..."
until curl -i --head --fail http://localhost:7007; do
i=$((i+1))
if [ "$i" -ge "$max" ]; then
echo "[$(date)] Max retries reached. Exiting. Take a look at the logs in the step below."
exit 1
fi
echo "($i/$max) [$(date)] Waiting for http://localhost:7007 to return HTTP 200..."
sleep 10
done
echo "[$(date)] RHDH is ready"
curl -i --insecure http://localhost:7007
- name: curl from RHDH Container (for troubleshooting)
if: failure()
run: |
${{ matrix.tool }} exec rhdh curl -i --head --fail http://localhost:7007
- name: Compose logs
if: always()
run: |
for svc in $(${{ matrix.tool }} compose ${{ matrix.composeConfig.cliArgs }} config --services | sort); do
echo "*** $svc ***"
${{ matrix.tool }} compose ${{ matrix.composeConfig.cliArgs }} logs --timestamps "$svc" || true
echo "************"
echo
done
- name: Tear down
if: always()
run: |
${{ matrix.tool }} compose ${{ matrix.composeConfig.cliArgs }} ps || true
${{ matrix.tool }} compose ${{ matrix.composeConfig.cliArgs }} down --volumes || true
- name: Cleanup Podman container environment
if: ${{ always() && matrix.tool == 'podman' }}
run: |
docker container stop ${{ steps.setup-podman.outputs.container-name }} || true
docker container rm ${{ steps.setup-podman.outputs.container-name }} || true