1
0
Fork 0

Add CI
Some checks failed
CI / test (push) Failing after 7s

This commit is contained in:
Miguel Jacq 2025-12-09 15:35:29 +11:00
parent 2aafefafb2
commit 6ae6866b15
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
2 changed files with 110 additions and 0 deletions

29
.forgejo/workflows/ci.yml Normal file
View file

@ -0,0 +1,29 @@
name: CI
on:
push:
jobs:
test:
runs-on: docker
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build and test a couple of PHP versions on Debian 13
run: scripts/ci.sh
# Notify if any previous step in this job failed
- name: Notify on failure
if: ${{ failure() }}
env:
WEBHOOK_URL: ${{ secrets.NODERED_WEBHOOK_URL }}
REPOSITORY: ${{ forgejo.repository }}
RUN_NUMBER: ${{ forgejo.run_number }}
SERVER_URL: ${{ forgejo.server_url }}
run: |
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"repository\":\"$REPOSITORY\",\"run_number\":\"$RUN_NUMBER\",\"status\":\"failure\",\"url\":\"$SERVER_URL/$REPOSITORY/actions/runs/$RUN_NUMBER\"}" \
"$WEBHOOK_URL"

81
scripts/ci.sh Executable file
View file

@ -0,0 +1,81 @@
#!/usr/bin/env bash
set -euo pipefail
# Space-separated list of PHP major.minor versions to build
PHPS="${PHPS:-"7.4 8.2 8.4"}"
# Matrix of base images with their distro codenames (image|codename)
BASE_MATRIX=(
"debian:13|trixie"
)
# Where to put artifacts on the host
OUT_DIR="${OUT_DIR:-"$(cd "$(dirname "$0")/.."; pwd)/build"}"
# Docker binary
DOCKER_BIN="${DOCKER_BIN:-docker}"
# Pass extra args to `docker build` if needed
EXTRA_BUILD_ARGS=${EXTRA_BUILD_ARGS:-}
export DOCKER_BUILDKIT=1
# Always run from scripts/ so relative paths work the same
cd "$(dirname "$0")"
# Dockerfile is in parent; use repo root as build context
DOCKERFILE="../Dockerfile"
CONTEXT=".."
mkdir -p "$OUT_DIR"
echo "==> Output directory: $OUT_DIR"
echo "==> Dockerfile: $DOCKERFILE (context: $CONTEXT)"
echo "==> PHP versions: $PHPS"
echo "==> Base matrix:"
printf ' - %s\n' "${BASE_MATRIX[@]}"
for entry in "${BASE_MATRIX[@]}"; do
IFS='|' read -r BASE_IMAGE CODENAME <<<"$entry"
for PHP_VER in $PHPS; do
TAG="pkg-php${PHP_VER}-${CODENAME}"
DEST_DIR="${OUT_DIR}/${CODENAME}/php${PHP_VER}"
echo
echo "==== Building: base=${BASE_IMAGE} (${CODENAME}), php=${PHP_VER} -> tag=${TAG}"
echo " Artifacts -> ${DEST_DIR}"
mkdir -p "${DEST_DIR}"
# Build the image.
$DOCKER_BIN build \
-f "${DOCKERFILE}" \
--build-arg "BASE_IMAGE=${BASE_IMAGE}" \
--build-arg "PHP_VER=${PHP_VER}" \
--progress=plain \
-t "${TAG}" \
${EXTRA_BUILD_ARGS} \
"${CONTEXT}"
# Export /dist/ from the image to the host
CID="$($DOCKER_BIN create "${TAG}" sh -c 'exit 0')"
# Copy artifacts
if ! $DOCKER_BIN cp "${CID}:/dist/." "${DEST_DIR}/"; then
echo "!! No /dist found in image ${TAG}."
else
#find "${DEST_DIR}" -type f ! -name "*.deb" -delete || true
# Sanity check
if compgen -G "${DEST_DIR}/*.deb" >/dev/null; then
echo "==> Collected $(ls -1 "${DEST_DIR}"/*.deb | wc -l | tr -d ' ') .deb files"
else
echo "!! No .deb files found for ${TAG} after copy."
fi
fi
done
done
echo
echo " Done. All artifacts are under: ${OUT_DIR}"
echo " Structure: build/<codename>/php<version>/*.deb"