Changed test step

This commit is contained in:
estebanthi
2025-10-08 19:32:50 +02:00
parent 12cdd4064b
commit d26aad6059

View File

@@ -1,4 +1,5 @@
name: test
on:
push:
branches:
@@ -11,32 +12,78 @@ permissions:
jobs:
check-update:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Test the update was run, files will differ if not
run: |
set -euo pipefail
./update.sh
git diff --exit-code
- name: Display error message on failure
if: failure() # This condition ensures the step runs only if the previous step failed
run: echo "The diff after running the update.sh shows that the update.sh was not run before committing the PR."
if: failure()
run: echo "The diff after running update.sh shows it wasn't run before committing the PR."
check-build:
runs-on: ubuntu-latest
env:
DOCKER_NAMESPACE: wavyzz
CONTAINER_NAME: dolibarr_build
DOLI_PORT: "8085"
DOLI_INSTALL_AUTO: "0" # passed into the container if your image uses it
steps:
- uses: actions/checkout@v5
- env:
DOLI_INSTALL_AUTO: 0
DOCKER_NAMESPACE: "wavyzz"
- name: Checkout code
uses: actions/checkout@v5
- name: Build and run container
shell: bash
run: |
set -euo pipefail
# Regenerate all the image files
./update.sh
# Try to build the image inimages/develop
docker rm -f dolibarr_build
docker build -t ${DOCKER_NAMESPACE}/dolibarr:develop images/develop
docker run -d -p 127.0.0.1:8085:80 --name dolibarr_build ${DOCKER_NAMESPACE}/dolibarr:develop
docker ps | grep -q dolibarr_build
# Remove old container if it exists
if [ "$(docker ps -aq -f name=^/${CONTAINER_NAME}$)" ]; then
echo "Removing existing ${CONTAINER_NAME}..."
docker rm -f "${CONTAINER_NAME}" || true
fi
echo "Building image ${DOCKER_NAMESPACE}/dolibarr:develop..."
docker build -t "${DOCKER_NAMESPACE}/dolibarr:develop" images/develop
echo "Starting ${CONTAINER_NAME} on 127.0.0.1:${DOLI_PORT}..."
docker run -d \
-p "127.0.0.1:${DOLI_PORT}:80" \
--name "${CONTAINER_NAME}" \
-e DOLI_INSTALL_AUTO="${DOLI_INSTALL_AUTO}" \
"${DOCKER_NAMESPACE}/dolibarr:develop"
# Give it a moment to boot
sleep 5
# Verify container is running
if [ "$(docker inspect -f '{{.State.Running}}' "${CONTAINER_NAME}" 2>/dev/null)" != "true" ]; then
echo "❌ Container failed to start"
docker ps -a || true
docker logs --tail=200 "${CONTAINER_NAME}" || true
exit 1
fi
# Quick HTTP check
curl -sSf "http://127.0.0.1:${DOLI_PORT}/" > /dev/null || {
echo "❌ HTTP check failed on http://127.0.0.1:${DOLI_PORT}/"
docker logs --tail=200 "${CONTAINER_NAME}" || true
exit 1
}
echo "✅ Container started and responded over HTTP"
- name: Cleanup container
if: always()
shell: bash
run: |
docker rm -f "${CONTAINER_NAME}" || true