From 0dd28a2f135035fff82a21c2c3e3e9321c8c84c7 Mon Sep 17 00:00:00 2001 From: Marius Rieder Date: Fri, 5 Jul 2024 07:45:40 +0200 Subject: [PATCH] Update from template --- .devcontainer/Dockerfile | 4 ++-- .devcontainer/build.sh | 10 +--------- .devcontainer/requirements.txt | 2 ++ .github/workflows/build-release.yml | 21 ++++++++++++++------- .github/workflows/build.yml | 20 ++++++++++++++------ .github/workflows/lint.yml | 12 ++++++++---- .github/workflows/pytest.yml | 29 ++++++++++++++++------------- 7 files changed, 57 insertions(+), 41 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index f58ff84..205fc34 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh index 62901f1..ad9915a 100755 --- a/.devcontainer/build.sh +++ b/.devcontainer/build.sh @@ -2,8 +2,7 @@ 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' ||: @@ -11,10 +10,3 @@ 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 \ No newline at end of file diff --git a/.devcontainer/requirements.txt b/.devcontainer/requirements.txt index c248ac1..0ac3b24 100644 --- a/.devcontainer/requirements.txt +++ b/.devcontainer/requirements.txt @@ -1,4 +1,6 @@ flake8 pytest +pytest-md pytest-cov +pytest-emoji requests-mock \ No newline at end of file diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 1c3aa3e..94499de 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -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 @@ -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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18bcb70..d0026e0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 91c978a..f342cd0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,6 +4,7 @@ on: push: paths: - '**.py' + - .github/workflows/lint.yml jobs: flake8_py3: @@ -11,12 +12,15 @@ jobs: 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 uses: py-actions/flake8@v2 + with: + plugins: "flake8-github" + args: "--format github" \ No newline at end of file diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 695fba6..8dcd03f 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,14 +1,17 @@ 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 + image: checkmk/check-mk-raw:2.3.0-latest env: OMD_ROOT: /omd/sites/cmk @@ -17,14 +20,14 @@ jobs: WORKSPACE: ${{ github.workspace }} 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 \ No newline at end of file + - 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: | + chown -R cmk:cmk $GITHUB_WORKSPACE $GITHUB_STEP_SUMMARY + su -l -c "cd $GITHUB_WORKSPACE; python3 -m pytest -v --emoji -cov . --md $GITHUB_STEP_SUMMARY " cmk \ No newline at end of file