From ce5e99478533a7ae808c3373b8ba0c32726a468d Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 22 Jul 2023 10:09:26 +0200 Subject: [PATCH 1/4] ci: missing concurrency check --- .github/workflows/build.yml | 4 +--- .github/workflows/labels.yml | 4 ++++ .github/workflows/test-edge.yml | 2 +- .github/workflows/test.yml | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4938e6e..9cd58dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ name: build concurrency: - group: build-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true on: @@ -13,8 +13,6 @@ on: paths-ignore: - '**.md' pull_request: - branches: - - 'master' paths-ignore: - '**.md' diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index d9f607a..91ec703 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -1,5 +1,9 @@ name: labels +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: branches: diff --git a/.github/workflows/test-edge.yml b/.github/workflows/test-edge.yml index 253e0e0..9baf1cf 100644 --- a/.github/workflows/test-edge.yml +++ b/.github/workflows/test-edge.yml @@ -1,7 +1,7 @@ name: test-edge concurrency: - group: test-edge-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true on: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c781609..83b37d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: test concurrency: - group: test-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true on: From 3874a7b5050cf2aa419570d5ad14930e18ce1e2b Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 22 Jul 2023 10:17:03 +0200 Subject: [PATCH 2/4] ci: merge test workflows --- .github/workflows/test-edge.yml | 84 --------------------------------- .github/workflows/test.yml | 12 +++++ Dockerfile | 1 + docker-bake.hcl | 7 +++ 4 files changed, 20 insertions(+), 84 deletions(-) delete mode 100644 .github/workflows/test-edge.yml diff --git a/.github/workflows/test-edge.yml b/.github/workflows/test-edge.yml deleted file mode 100644 index 9baf1cf..0000000 --- a/.github/workflows/test-edge.yml +++ /dev/null @@ -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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83b37d4..00c1a0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 1ac09de..2111034 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ diff --git a/docker-bake.hcl b/docker-bake.hcl index fddf4dc..4d97692 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -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 From e03b505d081153a996c34a64d6940f86c69fdd30 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 22 Jul 2023 10:18:11 +0200 Subject: [PATCH 3/4] test: use composite container-logs-check action --- .github/workflows/test.yml | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 00c1a0d..cb014dc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,8 @@ on: - '**.md' env: - BUILD_TAG: librenms-test + BUILD_TAG: librenms:test CONTAINER_NAME: librenms - RUNNING_TIMEOUT: 120 - RUNNING_LOG_CHECK: ready to handle connections jobs: test: @@ -61,32 +59,17 @@ jobs: 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: Check container logs + uses: crazy-max/.github/.github/actions/container-logs-check@main + with: + container_name: ${{ env.CONTAINER_NAME }} + log_check: "ready to handle connections" + timeout: 120 - 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 }} From 8d9cf3e991ab240df44380ce183ac8ab1ee4cd4b Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 22 Jul 2023 10:21:09 +0200 Subject: [PATCH 4/4] switch to compose v2 cmd --- CHANGELOG.md | 8 +++---- README.md | 24 +++++++++---------- .../{docker-compose.yml => compose.yml} | 0 .../{docker-compose.yml => compose.yml} | 0 .../{docker-compose.yml => compose.yml} | 0 test/{docker-compose.yml => compose.yml} | 0 6 files changed, 16 insertions(+), 16 deletions(-) rename examples/compose/{docker-compose.yml => compose.yml} (100%) rename examples/rrdcached-server/{docker-compose.yml => compose.yml} (100%) rename examples/traefik/{docker-compose.yml => compose.yml} (100%) rename test/{docker-compose.yml => compose.yml} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1daafcd..1408c13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -407,10 +407,10 @@ > :warning: **UPGRADE NOTES** > As the Docker container now runs as a non-root user, you have to first stop the container and change permissions to `data` volume: > ``` -> docker-compose stop +> docker compose stop > chown -R ${PUID}:${PGID} data/ -> docker-compose pull -> docker-compose up -d +> docker compose pull +> docker compose up -d > ``` ## 1.57-RC1 (2019/10/30) @@ -470,7 +470,7 @@ > :warning: **UPGRADE NOTES** > Sidecar cron and syslog-ng are now respectively handled with `SIDECAR_CRON` and `SIDECAR_SYSLOGNG` env vars -> See docker-compose example and README for more info. +> See compose example and README for more info. ## 1.51-RC1 (2019/05/01) diff --git a/README.md b/README.md index ad22787..4a98ce0 100644 --- a/README.md +++ b/README.md @@ -263,9 +263,9 @@ To upgrade to the latest version of LibreNMS, pull the newer image and launch the container. LibreNMS will upgrade automatically: ```console -$ docker-compose down -$ docker-compose pull -$ docker-compose up -d +$ docker compose down +$ docker compose pull +$ docker compose up -d ``` ## Configuration Management @@ -288,7 +288,7 @@ and will override the default values. You can edit the running configuration via the LibreNMS web UI or `lnms config:set` ```bash -docker-compose exec librenms lnms config:set page_refresh 300 +docker compose exec librenms lnms config:set page_refresh 300 ``` ### Re-Apply YAML Config @@ -317,7 +317,7 @@ If you want to use the `lnms` command to perform common server operations like manage users, database migration, and more, type: ```console -$ docker-compose exec librenms lnms +$ docker compose exec librenms lnms ``` ### Validate @@ -326,7 +326,7 @@ If you want to validate your installation from the CLI, type the following command: ```console -$ docker-compose exec --user librenms librenms php validate.php +$ docker compose exec --user librenms librenms php validate.php ==================================== Component | Version --------- | ------- @@ -350,8 +350,8 @@ SNMP | NET-SNMP 5.8 If you want to enable the new [Dispatcher service](https://docs.librenms.org/Extensions/Dispatcher-Service/), you have to run a "sidecar" container (see dispatcher service in -[docker-compose.yml](examples/compose/docker-compose.yml) example) or run a -simple container like this: +[compose.yml](examples/compose/compose.yml) example) or run a simple container +like this: ```console $ docker run -d --name librenms_dispatcher \ @@ -369,8 +369,8 @@ $ docker run -d --name librenms_dispatcher \ ### Syslog-ng container If you want to enable syslog-ng, you have to run a "sidecar" container (see -syslog-ng service in [docker-compose.yml](examples/compose/docker-compose.yml) -example) or run a simple container like this: +syslog-ng service in [compose.yml](examples/compose/compose.yml) example) or +run a simple container like this: ```console $ docker run -d --name librenms_syslog \ @@ -395,8 +395,8 @@ enable_syslog: true ### Snmptrapd container If you want to enable snmptrapd, you have to run a "sidecar" container (see -snmptrapd service in [docker-compose.yml](examples/compose/docker-compose.yml) -example) or run a simple container like this: +snmptrapd service in [compose.yml](examples/compose/compose.yml) example) or +run a simple container like this: ```console $ docker run -d --name librenms_snmptrapd \ diff --git a/examples/compose/docker-compose.yml b/examples/compose/compose.yml similarity index 100% rename from examples/compose/docker-compose.yml rename to examples/compose/compose.yml diff --git a/examples/rrdcached-server/docker-compose.yml b/examples/rrdcached-server/compose.yml similarity index 100% rename from examples/rrdcached-server/docker-compose.yml rename to examples/rrdcached-server/compose.yml diff --git a/examples/traefik/docker-compose.yml b/examples/traefik/compose.yml similarity index 100% rename from examples/traefik/docker-compose.yml rename to examples/traefik/compose.yml diff --git a/test/docker-compose.yml b/test/compose.yml similarity index 100% rename from test/docker-compose.yml rename to test/compose.yml