Skip to content

Commit c25f507

Browse files
authored
Merge pull request #364 from crazy-max/container-logs-check
test: use composite container-logs-check action
2 parents 1168e59 + 8d9cf3e commit c25f507

12 files changed

Lines changed: 49 additions & 128 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: build
22

33
concurrency:
4-
group: build-${{ github.ref }}
4+
group: ${{ github.workflow }}-${{ github.ref }}
55
cancel-in-progress: true
66

77
on:
@@ -13,8 +13,6 @@ on:
1313
paths-ignore:
1414
- '**.md'
1515
pull_request:
16-
branches:
17-
- 'master'
1816
paths-ignore:
1917
- '**.md'
2018

.github/workflows/labels.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: labels
22

3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
37
on:
48
push:
59
branches:

.github/workflows/test-edge.yml

Lines changed: 0 additions & 84 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: test
22

33
concurrency:
4-
group: test-${{ github.ref }}
4+
group: ${{ github.workflow }}-${{ github.ref }}
55
cancel-in-progress: true
66

77
on:
@@ -15,15 +15,25 @@ on:
1515
- '**.md'
1616

1717
env:
18-
BUILD_TAG: librenms-test
18+
BUILD_TAG: librenms:test
1919
CONTAINER_NAME: librenms
20-
RUNNING_TIMEOUT: 120
21-
RUNNING_LOG_CHECK: ready to handle connections
2220

2321
jobs:
2422
test:
2523
runs-on: ubuntu-latest
24+
continue-on-error: ${{ matrix.version == 'master' }}
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
version:
29+
- ''
30+
- master
2631
steps:
32+
-
33+
name: Prepare
34+
if: matrix.version != ''
35+
run: |
36+
echo "LIBRENMS_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
2737
-
2838
name: Checkout
2939
uses: actions/checkout@v3
@@ -49,32 +59,17 @@ jobs:
4959
LIBRENMS_IMAGE: ${{ env.BUILD_TAG }}
5060
LIBRENMS_CONTAINER: ${{ env.CONTAINER_NAME }}
5161
-
52-
name: Test run
53-
run: |
54-
TIMEOUT=$((SECONDS + ${{ env.RUNNING_TIMEOUT }}))
55-
while read LOGLINE; do
56-
echo ${LOGLINE}
57-
if [[ ${LOGLINE} == *"${{ env.RUNNING_LOG_CHECK }}"* ]]; then
58-
echo "🎉 Container up!"
59-
break
60-
fi
61-
if [[ $SECONDS -gt ${TIMEOUT} ]]; then
62-
>&2 echo "❌ Failed to run ${{ env.CONTAINER_NAME }} container"
63-
exit 1
64-
fi
65-
done < <(docker logs -f ${{ env.CONTAINER_NAME }} 2>&1)
66-
67-
CONTAINER_STATUS=$(docker container inspect --format "{{.State.Status}}" ${{ env.CONTAINER_NAME }})
68-
if [[ ${CONTAINER_STATUS} != "running" ]]; then
69-
>&2 echo "❌ Container ${{ env.CONTAINER_NAME }} returned status '$CONTAINER_STATUS'"
70-
exit 1
71-
fi
62+
name: Check container logs
63+
uses: crazy-max/.github/.github/actions/container-logs-check@main
64+
with:
65+
container_name: ${{ env.CONTAINER_NAME }}
66+
log_check: "ready to handle connections"
67+
timeout: 120
7268
-
7369
name: Logs
7470
if: always()
7571
run: |
7672
docker compose logs
77-
docker compose down --volumes > /dev/null 2>&1 || true
7873
working-directory: test
7974
env:
8075
LIBRENMS_IMAGE: ${{ env.BUILD_TAG }}

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,10 @@
407407
> :warning: **UPGRADE NOTES**
408408
> As the Docker container now runs as a non-root user, you have to first stop the container and change permissions to `data` volume:
409409
> ```
410-
> docker-compose stop
410+
> docker compose stop
411411
> chown -R ${PUID}:${PGID} data/
412-
> docker-compose pull
413-
> docker-compose up -d
412+
> docker compose pull
413+
> docker compose up -d
414414
> ```
415415
416416
## 1.57-RC1 (2019/10/30)
@@ -470,7 +470,7 @@
470470
471471
> :warning: **UPGRADE NOTES**
472472
> Sidecar cron and syslog-ng are now respectively handled with `SIDECAR_CRON` and `SIDECAR_SYSLOGNG` env vars
473-
> See docker-compose example and README for more info.
473+
> See compose example and README for more info.
474474
475475
## 1.51-RC1 (2019/05/01)
476476

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ RUN apk --update --no-cache add -t build-dependencies \
115115
linux-headers \
116116
musl-dev \
117117
python3-dev \
118+
&& echo "Installing LibreNMS https://github.com/librenms/librenms.git#${LIBRENMS_VERSION}..." \
118119
&& git clone --depth=1 --branch ${LIBRENMS_VERSION} https://github.com/librenms/librenms.git . \
119120
&& pip3 install --ignore-installed -r requirements.txt --upgrade \
120121
&& COMPOSER_CACHE_DIR="/tmp" composer install --no-dev --no-interaction --no-ansi \

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ To upgrade to the latest version of LibreNMS, pull the newer image and launch
263263
the container. LibreNMS will upgrade automatically:
264264

265265
```console
266-
$ docker-compose down
267-
$ docker-compose pull
268-
$ docker-compose up -d
266+
$ docker compose down
267+
$ docker compose pull
268+
$ docker compose up -d
269269
```
270270

271271
## Configuration Management
@@ -288,7 +288,7 @@ and will override the default values.
288288
You can edit the running configuration via the LibreNMS web UI or `lnms config:set`
289289

290290
```bash
291-
docker-compose exec librenms lnms config:set page_refresh 300
291+
docker compose exec librenms lnms config:set page_refresh 300
292292
```
293293

294294
### Re-Apply YAML Config
@@ -317,7 +317,7 @@ If you want to use the `lnms` command to perform common server operations like
317317
manage users, database migration, and more, type:
318318

319319
```console
320-
$ docker-compose exec librenms lnms
320+
$ docker compose exec librenms lnms
321321
```
322322

323323
### Validate
@@ -326,7 +326,7 @@ If you want to validate your installation from the CLI, type the following
326326
command:
327327

328328
```console
329-
$ docker-compose exec --user librenms librenms php validate.php
329+
$ docker compose exec --user librenms librenms php validate.php
330330
====================================
331331
Component | Version
332332
--------- | -------
@@ -350,8 +350,8 @@ SNMP | NET-SNMP 5.8
350350

351351
If you want to enable the new [Dispatcher service](https://docs.librenms.org/Extensions/Dispatcher-Service/),
352352
you have to run a "sidecar" container (see dispatcher service in
353-
[docker-compose.yml](examples/compose/docker-compose.yml) example) or run a
354-
simple container like this:
353+
[compose.yml](examples/compose/compose.yml) example) or run a simple container
354+
like this:
355355

356356
```console
357357
$ docker run -d --name librenms_dispatcher \
@@ -369,8 +369,8 @@ $ docker run -d --name librenms_dispatcher \
369369
### Syslog-ng container
370370

371371
If you want to enable syslog-ng, you have to run a "sidecar" container (see
372-
syslog-ng service in [docker-compose.yml](examples/compose/docker-compose.yml)
373-
example) or run a simple container like this:
372+
syslog-ng service in [compose.yml](examples/compose/compose.yml) example) or
373+
run a simple container like this:
374374

375375
```console
376376
$ docker run -d --name librenms_syslog \
@@ -395,8 +395,8 @@ enable_syslog: true
395395
### Snmptrapd container
396396

397397
If you want to enable snmptrapd, you have to run a "sidecar" container (see
398-
snmptrapd service in [docker-compose.yml](examples/compose/docker-compose.yml)
399-
example) or run a simple container like this:
398+
snmptrapd service in [compose.yml](examples/compose/compose.yml) example) or
399+
run a simple container like this:
400400

401401
```console
402402
$ docker run -d --name librenms_snmptrapd \

docker-bake.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ variable "DEFAULT_TAG" {
22
default = "librenms:local"
33
}
44

5+
variable "LIBRENMS_VERSION" {
6+
default = null
7+
}
8+
59
// Special target: https://github.com/docker/metadata-action#bake-definition
610
target "docker-metadata-action" {
711
tags = ["${DEFAULT_TAG}"]
12+
args = {
13+
LIBRENMS_VERSION = LIBRENMS_VERSION
14+
}
815
}
916

1017
// Default target if none specified
File renamed without changes.

0 commit comments

Comments
 (0)