CI: run on main, add a docker job, drop upstream-specific steps
The workflow only triggered on master. New job builds the image and runs contrib/docker-smoke-test.sh, which checks the SSL handling of the entrypoint. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
419ff90859
commit
0d1ebc6e3e
3 files changed
+69
-7
No files matched your search
@@ -2,9 +2,9 @@ name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
branches: [main]
|
||||
workflow_dispatch: # https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manually-run-a-workflow
|
||||
|
||||
concurrency:
|
||||
@@ -31,10 +31,8 @@ jobs:
|
||||
cache: 'pip'
|
||||
cache-dependency-path: 'pyproject.toml'
|
||||
|
||||
- name: Log Python version and Git tag
|
||||
run: |
|
||||
python3 --version
|
||||
git tag
|
||||
- name: Log Python version
|
||||
run: python3 --version
|
||||
|
||||
- name: Install Python deps
|
||||
run: |
|
||||
@@ -73,7 +71,6 @@ jobs:
|
||||
build_docs:
|
||||
# note: this build task is not related to read-the-docs; it is only here to sanity-check the docs can be built.
|
||||
# For the read-the-docs build, see .readthedocs.yml
|
||||
# and the webhook set up in https://github.com/spesmilo/electrumx/settings/hooks
|
||||
name: build_docs
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
@@ -94,3 +91,16 @@ jobs:
|
||||
run: |
|
||||
cd docs
|
||||
make html
|
||||
|
||||
docker:
|
||||
# builds the image and checks the SSL handling of its entrypoint (contrib/docker-smoke-test.sh)
|
||||
name: docker
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Build image
|
||||
run: docker build -t plm-electrumx .
|
||||
|
||||
- name: Smoke test
|
||||
run: contrib/docker-smoke-test.sh plm-electrumx
|
||||
@@ -19,3 +19,6 @@
|
||||
/e_x.egg-info/
|
||||
|
||||
.env
|
||||
|
||||
.coverage
|
||||
/htmlcov/
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
# Checks the SSL handling of docker-entrypoint.sh in the image (no node needed).
|
||||
# Usage: docker build -t plm-electrumx . && contrib/docker-smoke-test.sh [image]
|
||||
set -eu
|
||||
IMAGE="${1:-plm-electrumx}"
|
||||
ENTRYPOINT=/usr/local/bin/docker-entrypoint.sh
|
||||
tmp="$(mktemp -d)"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
mkdir -p "$tmp/db" "$tmp/ssl"
|
||||
|
||||
run() { # extra docker args..., then the entrypoint is run with "echo ok"
|
||||
docker run --rm --user "$(id -u):$(id -g)" \
|
||||
-v "$tmp/db:/var/lib/electrumx" -v "$tmp/ssl:/var/lib/electrumx-ssl" \
|
||||
"$@" --entrypoint "$ENTRYPOINT" "$IMAGE" echo ok 2>&1
|
||||
}
|
||||
fingerprint() { openssl x509 -in "$tmp/ssl/server.crt" -noout -fingerprint -sha256; }
|
||||
fail() { echo "FAIL: $*" >&2; exit 1; }
|
||||
|
||||
echo "1. first start generates a certificate and sets SERVICES"
|
||||
out="$(run)"
|
||||
echo "$out" | grep -q "generating a self-signed" || fail "no certificate generated: $out"
|
||||
echo "$out" | grep -q "SERVICES=tcp://:50001,ssl://:50002" || fail "wrong SERVICES: $out"
|
||||
[ -s "$tmp/ssl/server.key" ] || fail "no key"
|
||||
first="$(fingerprint)"
|
||||
|
||||
echo "2. second start reuses it"
|
||||
out="$(run)"
|
||||
echo "$out" | grep -q "using the existing SSL certificate" || fail "not reused: $out"
|
||||
[ "$(fingerprint)" = "$first" ] || fail "certificate changed"
|
||||
|
||||
echo "3. only one of the two files is an error, and nothing is overwritten"
|
||||
rm "$tmp/ssl/server.key"
|
||||
run | grep -q "ERROR: only one of" || fail "no error with a missing key"
|
||||
[ ! -e "$tmp/ssl/server.key" ] || fail "key was recreated"
|
||||
|
||||
echo "4. SSL disabled"
|
||||
run -e SSL_ENABLED=false | grep -q "SERVICES=tcp://:50001$" || fail "SSL not disabled"
|
||||
|
||||
echo "5. only SSL_CERTFILE is an error"
|
||||
run -e SSL_CERTFILE=/nope.pem | grep -q "set both SSL_CERTFILE and SSL_KEYFILE" || fail "no error"
|
||||
|
||||
echo "6. a non-writable data directory is an error"
|
||||
chmod 555 "$tmp/db"
|
||||
if [ "$(id -u)" != 0 ]; then
|
||||
run | grep -q "is not writable" || fail "no error for a non-writable directory"
|
||||
fi
|
||||
chmod 755 "$tmp/db"
|
||||
|
||||
echo "OK"
|
||||
Reference in new issue
Block a user