diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 47a573d..87819d0 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -1,42 +1,89 @@ name: test + on: - push: - branches: - - main - pull_request: + push: + branches: + - main + pull_request: permissions: - contents: read + contents: read jobs: - check-update: - runs-on: ubuntu-latest + check-update: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v5 - 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: Test the update was run, files will differ if not - run: | - ./update.sh - git diff --exit-code + - name: Display error message on failure + if: failure() + run: echo "The diff after running update.sh shows it wasn't run before committing the PR." - - 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." + 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: + - 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 + + # 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 - check-build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - env: - DOLI_INSTALL_AUTO: 0 - DOCKER_NAMESPACE: "wavyzz" - run: | - # 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