Skip to content

Commit

Permalink
Update from template for Checkmk 23
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuka committed Jun 5, 2024
1 parent 7df931e commit 5683e6a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/ubuntu/.devcontainer/base.Dockerfile

# [Choice] CheckMK version: 2.2.0-latest
ARG VARIANT="2.2.0-latest"
# [Choice] CheckMK version: 2.3.0-latest
ARG VARIANT="2.3.0-latest"
FROM checkmk/check-mk-raw:${VARIANT}

RUN /docker-entrypoint.sh /bin/true
Expand Down
10 changes: 1 addition & 9 deletions .devcontainer/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@

NAME=$(python3 -c 'print(eval(open("package").read())["name"])')
VERSION=$(python3 -c 'print(eval(open("package").read())["version"])')
rm -f $NAME-$VERSION.mkp \
/omd/sites/cmk/var/cat check_mk/packages/${NAME}-*.mkp \
rm /omd/sites/cmk/var/check_mk/packages/${NAME} \
/omd/sites/cmk/var/check_mk/packages_local/${NAME}-*.mkp ||:

mkp -v package package 2>&1 | sed '/Installing$/Q' ||:

cp /omd/sites/cmk/var/check_mk/packages_local/$NAME-$VERSION.mkp .

mkp inspect $NAME-$VERSION.mkp

# Set Outputs for GitHub Workflow steps
if [ -n "$GITHUB_WORKSPACE" ]; then
echo "pkgfile=${NAME}-${VERSION}.mkp" >> $GITHUB_OUTPUT
echo "pkgname=${NAME}" >> $GITHUB_OUTPUT
echo "pkgversion=$VERSION" >> $GITHUB_OUTPUT
fi
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: focal, bionic
"args": { "VARIANT": "2.2.0-latest" }
"args": { "VARIANT": "2.3.0-latest" }
},

"customizations": {
Expand Down
2 changes: 2 additions & 0 deletions .devcontainer/symlink.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
PKGNAME=$(python3 -c 'print(eval(open("package").read())["name"])')
ln -sv $WORKSPACE $OMD_ROOT/local/lib/python3/cmk_addons/plugins/$PKGNAME

for DIR in 'agents' 'checkman' 'checks' 'doc' 'inventory' 'notifications' 'pnp-templates' 'web'; do
rm -rfv $OMD_ROOT/local/share/check_mk/$DIR
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Build Release Package
runs-on: ubuntu-latest
container:
image: checkmk/check-mk-raw:2.2.0-latest
image: checkmk/check-mk-raw:2.3.0-latest
permissions:
contents: write

Expand All @@ -24,17 +24,24 @@ jobs:
steps:
- name: Initialize Checkmk Site
run: /docker-entrypoint.sh /bin/true
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Parse Package File
run: |
NAME=$(python3 -c 'print(eval(open("package").read())["name"])')
VERSION=$(python3 -c 'print(eval(open("package").read())["version"])')
echo "CMKPKG_NAME=$NAME" >> "$GITHUB_ENV"
echo "CMKPKG_VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Setup links
run: .devcontainer/symlink.sh
- name: Update GITHUB_PATH
run: echo "/omd/sites/cmk/bin" >> $GITHUB_PATH
- name: Build Extension
run: .devcontainer/build.sh
run: |
chown -R cmk:cmk $GITHUB_WORKSPACE
su -l -c "mkp -v package $GITHUB_WORKSPACE/package" cmk
cp /omd/sites/cmk/var/check_mk/packages_local/${CMKPKG_NAME}-${CMKPKG_VERSION}.mkp .
echo "pkgfile=${CMKPKG_NAME}-${CMKPKG_VERSION}.mkp" >> $GITHUB_OUTPUT
id: cmkpkg

- name: Create Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
release_name: Release ${{ github.ref }}
draft: false
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Build Checkmk package
runs-on: ubuntu-latest
container:
image: checkmk/check-mk-raw:2.2.0-latest
image: checkmk/check-mk-raw:2.3.0-latest

env:
OMD_ROOT: /omd/sites/cmk
Expand All @@ -24,16 +24,24 @@ jobs:
steps:
- name: Initialize Checkmk Site
run: /docker-entrypoint.sh /bin/true
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Parse Package File
run: |
NAME=$(python3 -c 'print(eval(open("package").read())["name"])')
VERSION=$(python3 -c 'print(eval(open("package").read())["version"])')
echo "CMKPKG_NAME=$NAME" >> "$GITHUB_ENV"
echo "CMKPKG_VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Setup links
run: .devcontainer/symlink.sh
- name: Update GITHUB_PATH
run: echo "/omd/sites/cmk/bin" >> $GITHUB_PATH
- name: Build Extension
run: .devcontainer/build.sh
run: |
chown -R cmk:cmk $GITHUB_WORKSPACE
su -l -c "mkp -v package $GITHUB_WORKSPACE/package" cmk
cp /omd/sites/cmk/var/check_mk/packages_local/${CMKPKG_NAME}-${CMKPKG_VERSION}.mkp .
echo "pkgfile=${CMKPKG_NAME}-${CMKPKG_VERSION}.mkp" >> $GITHUB_OUTPUT
id: cmkpkg
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.cmkpkg.outputs.pkgfile }}
path: ${{ steps.cmkpkg.outputs.pkgfile }}
9 changes: 5 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ on:
push:
paths:
- '**.py'
- .github/workflows/lint.yml

jobs:
flake8_py3:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.12'
- name: Install flake8
run: pip install flake8
- name: Run flake8
Expand Down
33 changes: 14 additions & 19 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
name: pytest

on:
push: []
push:
paths:
- '**.py'
- .github/workflows/pytest.yml

jobs:
pytest:

runs-on: ubuntu-latest
container:
image: checkmk/check-mk-raw:2.2.0-latest

env:
OMD_ROOT: /omd/sites/cmk
OMD_SITE: cmk
CMK_SITE_ID: cmk
WORKSPACE: ${{ github.workspace }}
image: checkmk/check-mk-raw:2.3.0-latest

steps:
- name: Initialize Checkmk Site
run: /docker-entrypoint.sh /bin/true
- uses: actions/checkout@v3
- name: Setup links
run: ./.devcontainer/symlink.sh
- name: Install pytest
run: su -l -c "REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt pip3 install -r $GITHUB_WORKSPACE/.devcontainer/requirements.txt" cmk
- name: Update GITHUB_PATH
run: echo "/omd/sites/cmk/bin" >> $GITHUB_PATH
- name: Run pytest
run: python3 -m pytest
- name: Initialize Checkmk Site
run: /docker-entrypoint.sh /bin/true
- uses: actions/checkout@v4
- name: Setup links
run: .devcontainer/symlink.sh
- name: Install pytest
run: su -l -c "REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt pip3 install -r $GITHUB_WORKSPACE/.devcontainer/requirements.txt" cmk
- name: Run pytest
run: su -l -c "python3 -m pytest" cmk

0 comments on commit 5683e6a

Please sign in to comment.