1
0
Fork 0
mirror of https://github.com/librenms/docker.git synced 2026-01-23 02:14:48 +00:00

ci: merge test workflows

This commit is contained in:
CrazyMax 2023-07-22 10:17:03 +02:00
parent ce5e994785
commit 3874a7b505
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
4 changed files with 20 additions and 84 deletions

View file

@ -1,84 +0,0 @@
name: test-edge
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'master'
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
env:
BUILD_TAG: librenms-test
CONTAINER_NAME: librenms
RUNNING_TIMEOUT: 120
RUNNING_LOG_CHECK: ready to handle connections
jobs:
test:
runs-on: ubuntu-latest
continue-on-error: true
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build
uses: docker/bake-action@v3
with:
targets: image-local
set: |
*.args.LIBRENMS_VERSION=master
env:
DEFAULT_TAG: ${{ env.BUILD_TAG }}
-
name: Start
run: |
docker compose up -d
working-directory: test
env:
LIBRENMS_IMAGE: ${{ env.BUILD_TAG }}
LIBRENMS_CONTAINER: ${{ env.CONTAINER_NAME }}
-
name: Test run
run: |
TIMEOUT=$((SECONDS + ${{ env.RUNNING_TIMEOUT }}))
while read LOGLINE; do
echo ${LOGLINE}
if [[ ${LOGLINE} == *"${{ env.RUNNING_LOG_CHECK }}"* ]]; then
echo "🎉 Container up!"
break
fi
if [[ $SECONDS -gt ${TIMEOUT} ]]; then
>&2 echo "❌ Failed to run ${{ env.CONTAINER_NAME }} container"
exit 1
fi
done < <(docker logs -f ${{ env.CONTAINER_NAME }} 2>&1)
CONTAINER_STATUS=$(docker container inspect --format "{{.State.Status}}" ${{ env.CONTAINER_NAME }})
if [[ ${CONTAINER_STATUS} != "running" ]]; then
>&2 echo "❌ Container ${{ env.CONTAINER_NAME }} returned status '$CONTAINER_STATUS'"
exit 1
fi
-
name: Logs
if: always()
run: |
docker compose logs
docker compose down --volumes > /dev/null 2>&1 || true
working-directory: test
env:
LIBRENMS_IMAGE: ${{ env.BUILD_TAG }}
LIBRENMS_CONTAINER: ${{ env.CONTAINER_NAME }}

View file

@ -23,7 +23,19 @@ env:
jobs:
test:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.version == 'master' }}
strategy:
fail-fast: false
matrix:
version:
- ''
- master
steps:
-
name: Prepare
if: matrix.version != ''
run: |
echo "LIBRENMS_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v3

View file

@ -115,6 +115,7 @@ RUN apk --update --no-cache add -t build-dependencies \
linux-headers \
musl-dev \
python3-dev \
&& echo "Installing LibreNMS https://github.com/librenms/librenms.git#${LIBRENMS_VERSION}..." \
&& git clone --depth=1 --branch ${LIBRENMS_VERSION} https://github.com/librenms/librenms.git . \
&& pip3 install --ignore-installed -r requirements.txt --upgrade \
&& COMPOSER_CACHE_DIR="/tmp" composer install --no-dev --no-interaction --no-ansi \

View file

@ -2,9 +2,16 @@ variable "DEFAULT_TAG" {
default = "librenms:local"
}
variable "LIBRENMS_VERSION" {
default = null
}
// Special target: https://github.com/docker/metadata-action#bake-definition
target "docker-metadata-action" {
tags = ["${DEFAULT_TAG}"]
args = {
LIBRENMS_VERSION = LIBRENMS_VERSION
}
}
// Default target if none specified