From 3be05acec8c60706445689e9120e5fcedf8553a1 Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Wed, 1 Jan 2020 19:31:36 -0500 Subject: [PATCH 01/25] Bump version for develop --- varken/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/varken/__init__.py b/varken/__init__.py index fc803e10..863ebfa0 100644 --- a/varken/__init__.py +++ b/varken/__init__.py @@ -1,2 +1,2 @@ -VERSION = "1.7.6" -BRANCH = 'master' +VERSION = "1.7.7" +BRANCH = 'develop' From 64e994aeeafea4bd4e66990c0c88ab4fce3ec807 Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Wed, 1 Jan 2020 19:33:07 -0500 Subject: [PATCH 02/25] Fix changelog link for next release --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fae7135e..e5f992c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ **Merged pull requests:** -- v1.7.6 Merge [\#163](https://github.com/Boerderij/Varken/pull/163) ([samwiseg0](https://github.com/samwiseg0)) +- v1.7.6 Merge [\#165](https://github.com/Boerderij/Varken/pull/165) ([samwiseg0](https://github.com/samwiseg0)) **Fixed bugs:** From be276a60222d931abbd4e8851a85d50d5c8484de Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Thu, 2 Jan 2020 10:17:17 -0600 Subject: [PATCH 03/25] test removing tcp line --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9214eff5..20f44a5a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ stages: image: docker:stable stage: build and push variables: - DOCKER_HOST: tcp://docker:2375/ + #DOCKER_HOST: tcp://docker:2375/ DOCKER_DRIVER: overlay2 services: - docker:dind From 044f28967a24d53e012272ddfe30605eeb25cb0f Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Thu, 2 Jan 2020 10:22:15 -0600 Subject: [PATCH 04/25] Test successful. Removing DOCKER_HOST completely --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20f44a5a..464e3586 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,6 @@ stages: image: docker:stable stage: build and push variables: - #DOCKER_HOST: tcp://docker:2375/ DOCKER_DRIVER: overlay2 services: - docker:dind From 55fd938f9609eff81d64e972187d0ccf8af871a6 Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Thu, 2 Jan 2020 11:44:23 -0500 Subject: [PATCH 05/25] Add artists count to Tautulli payload. Fixes #163 --- varken/tautulli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/varken/tautulli.py b/varken/tautulli.py index c0ec8e55..a8d677b7 100644 --- a/varken/tautulli.py +++ b/varken/tautulli.py @@ -218,6 +218,7 @@ def get_stats(self): data['fields']['episodes'] = int(library['child_count']) elif library['section_type'] == 'artist': + data['fields']['artists'] = int(library['count']) data['fields']['albums'] = int(library['parent_count']) data['fields']['tracks'] = int(library['child_count']) influx_payload.append(data) From 264150a20145a3b59beb77a22e8bf8238d29f337 Mon Sep 17 00:00:00 2001 From: samwiseg0 <2241731+samwiseg0@users.noreply.github.com> Date: Thu, 9 Apr 2020 10:12:20 -0400 Subject: [PATCH 06/25] Update bug_report.md Change to `awaiting-triage` --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0364d15f..a2b1f91c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,7 @@ name: Bug report about: Create a report to help us improve title: "[BUG]" -labels: awaiting-approval +labels: awaiting-triage assignees: '' --- From c05bd13b286ffbd375fe2a8dff654d6846c48828 Mon Sep 17 00:00:00 2001 From: samwiseg0 <2241731+samwiseg0@users.noreply.github.com> Date: Thu, 9 Apr 2020 10:12:47 -0400 Subject: [PATCH 07/25] Update feature_request.md Change to `awaiting-triage` --- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 54cdb669..6bdd1510 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,7 +2,7 @@ name: Feature request about: Suggest an idea for this project title: "[Feature Request]" -labels: awaiting-approval +labels: awaiting-triage assignees: '' --- From 2c278118792cb960f0ffb29ae9b076a9497206b6 Mon Sep 17 00:00:00 2001 From: Derek Miller Date: Sun, 26 Apr 2020 17:35:36 -0700 Subject: [PATCH 08/25] Fix type error due to missing namedtuple field when fetching lidarr queue --- varken/structures.py | 1 + 1 file changed, 1 insertion(+) diff --git a/varken/structures.py b/varken/structures.py index 6f12591a..d4eea165 100644 --- a/varken/structures.py +++ b/varken/structures.py @@ -494,6 +494,7 @@ class LidarrQueue(NamedTuple): protocol: str = None downloadClient: str = None indexer: str = None + outputPath: str = None downloadForced: bool = None id: int = None From 0556c076385399c84023d665fec9f6ed8021fc5f Mon Sep 17 00:00:00 2001 From: samwiseg0 <2241731+samwiseg0@users.noreply.github.com> Date: Tue, 15 Dec 2020 00:11:14 -0500 Subject: [PATCH 09/25] Remove Unifi from docker-compose --- docker-compose.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5260fbde..a3cb252b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -107,14 +107,6 @@ services: - VRKN_SICKCHILL_1_VERIFY_SSL=false - VRKN_SICKCHILL_1_GET_MISSING=true - VRKN_SICKCHILL_1_GET_MISSING_RUN_SECONDS=300 - - VRKN_UNIFI_1_URL=unifi.domain.tld:8443 - - VRKN_UNIFI_1_USERNAME=ubnt - - VRKN_UNIFI_1_PASSWORD=ubnt - - VRKN_UNIFI_1_SITE=default - - VRKN_UNIFI_1_USG_NAME=MyRouter - - VRKN_UNIFI_1_SSL=false - - VRKN_UNIFI_1_VERIFY_SSL=false - - VRKN_UNIFI_1_GET_USG_STATS_RUN_SECONDS=300 depends_on: - influxdb restart: unless-stopped From a1f37e1bfb7b4216318fba70676032da70e33394 Mon Sep 17 00:00:00 2001 From: samwiseg0 <2241731+samwiseg0@users.noreply.github.com> Date: Tue, 15 Dec 2020 00:11:41 -0500 Subject: [PATCH 10/25] Update README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bd88fb9f..fe95bca1 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ ecosystem into InfluxDB using Grafana for a frontend Requirements: * [Python 3.6.7+](https://www.python.org/downloads/release/python-367/) * [Python3-pip](https://pip.pypa.io/en/stable/installing/) -* [InfluxDB](https://www.influxdata.com/) +* [InfluxDB 1.8.x](https://www.influxdata.com/) * [Grafana](https://grafana.com/)

@@ -32,7 +32,6 @@ Supported Modules: * [Radarr](https://radarr.video/) - A fork of Sonarr to work with movies à la Couchpotato. * [Tautulli](https://tautulli.com/) - A Python based monitoring and tracking tool for Plex Media Server. * [Ombi](https://ombi.io/) - Want a Movie or TV Show on Plex or Emby? Use Ombi! -* [Unifi](https://unifi-sdn.ubnt.com/) - The Global Leader in Managed Wi-Fi Systems * [Lidarr](https://lidarr.audio/) - Looks and smells like Sonarr but made for music. Key features: @@ -51,7 +50,8 @@ Please read [Asking for Support](https://wiki.cajun.pro/books/varken/chapter/ask ### InfluxDB [InfluxDB Installation Documentation](https://wiki.cajun.pro/books/varken/page/influxdb-d1f) - +Note: Only v1.8.x is currently supported. + Influxdb is required but not packaged as part of Varken. Varken will create its database on its own. If you choose to give varken user permissions that do not include database creation, please ensure you create an influx database From 82f8e4a698a3a7de59ea7a4531bbc6f568eb26f8 Mon Sep 17 00:00:00 2001 From: samwiseg0 <2241731+samwiseg0@users.noreply.github.com> Date: Tue, 15 Dec 2020 00:12:38 -0500 Subject: [PATCH 11/25] Change exit code. Fixes #174 --- varken/dbmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/varken/dbmanager.py b/varken/dbmanager.py index 04eb51e9..c832fdf3 100644 --- a/varken/dbmanager.py +++ b/varken/dbmanager.py @@ -20,7 +20,7 @@ def __init__(self, server): self.logger.info('Influxdb version: %s', version) except ConnectionError: self.logger.critical("Error testing connection to InfluxDB. Please check your url/hostname") - exit() + exit(1) databases = [db['name'] for db in self.influx.get_list_database()] From e54029fca3a3a15d6894f7daa39f1acdaba93133 Mon Sep 17 00:00:00 2001 From: samwiseg0 <2241731+samwiseg0@users.noreply.github.com> Date: Tue, 15 Dec 2020 00:13:27 -0500 Subject: [PATCH 12/25] Update for ombi v4. Fixes #186 --- varken/structures.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/varken/structures.py b/varken/structures.py index d4eea165..deb40179 100644 --- a/varken/structures.py +++ b/varken/structures.py @@ -140,6 +140,7 @@ class OmbiTVRequest(NamedTuple): totalSeasons: int = None tvDbId: int = None requestedByAlias: str = None + requestStatus: str = None class OmbiMovieRequest(NamedTuple): @@ -176,6 +177,7 @@ class OmbiMovieRequest(NamedTuple): langCode: str = None languageCode: str = None requestedByAlias: str = None + requestStatus: str = None # Sonarr From 56fb3abc687b1cb82ce1e9051001e54aaa548071 Mon Sep 17 00:00:00 2001 From: samwiseg0 <2241731+samwiseg0@users.noreply.github.com> Date: Tue, 15 Dec 2020 23:17:35 -0500 Subject: [PATCH 13/25] Add invalid template workflow --- .github/workflows/invalid_template.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/invalid_template.yml diff --git a/.github/workflows/invalid_template.yml b/.github/workflows/invalid_template.yml new file mode 100644 index 00000000..e69de29b From 1ab925640361fcd90d08f003103a871ab7adcf10 Mon Sep 17 00:00:00 2001 From: samwiseg0 <2241731+samwiseg0@users.noreply.github.com> Date: Tue, 15 Dec 2020 23:20:56 -0500 Subject: [PATCH 14/25] Add support request workflow --- .github/workflows/support.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/support.yml diff --git a/.github/workflows/support.yml b/.github/workflows/support.yml new file mode 100644 index 00000000..e69de29b From f5aa55a1db9eca4160c9f17f8d4dc2e0dd8eafef Mon Sep 17 00:00:00 2001 From: samwiseg0 <2241731+samwiseg0@users.noreply.github.com> Date: Tue, 15 Dec 2020 23:25:36 -0500 Subject: [PATCH 15/25] Update workflows --- .github/workflows/invalid_template.yml | 19 +++++++++++++++++++ .github/workflows/support.yml | 25 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/.github/workflows/invalid_template.yml b/.github/workflows/invalid_template.yml index e69de29b..c98d3174 100644 --- a/.github/workflows/invalid_template.yml +++ b/.github/workflows/invalid_template.yml @@ -0,0 +1,19 @@ +name: 'Invalid Template' + +on: + issues: + types: [labeled, unlabeled, reopened] + +jobs: + support: + runs-on: ubuntu-latest + steps: + - uses: dessant/support-requests@v2 + with: + github-token: ${{ github.token }} + support-label: 'invalid:template-incomplete' + issue-comment: > + :wave: @{issue-author}, please edit your issue and follow the template provided. + close-issue: false + lock-issue: true + issue-lock-reason: 'resolved' diff --git a/.github/workflows/support.yml b/.github/workflows/support.yml index e69de29b..df74c107 100644 --- a/.github/workflows/support.yml +++ b/.github/workflows/support.yml @@ -0,0 +1,25 @@ +name: 'Support Request' + +on: + issues: + types: [labeled, unlabeled, reopened] + +jobs: + support: + runs-on: ubuntu-latest + steps: + - uses: dessant/support-requests@v2 + with: + github-token: ${{ github.token }} + support-label: 'support' + issue-comment: > + :wave: @{issue-author}, we use the issue tracker exclusively + for bug reports and feature requests. However, this issue appears + to be a support request. Please use our support channels + to get help with Varken! + + - [Discord](https://discord.gg/VjZ6qSM) + - [Discord Quick Access](http://cyborg.decreator.dev/channels/518970285773422592/530424560504537105/) + close-issue: true + lock-issue: false + issue-lock-reason: 'off-topic' From eeb0198e3db6eb456dde0ef400eae664ca984c9b Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Mon, 21 Dec 2020 10:35:01 -0600 Subject: [PATCH 16/25] move pipeline to github native, remove redundant dockerfiles, and add helper actions --- .../docker-multi-login-action/action.yml | 23 ++++ .../action.yml | 46 ++++++++ .github/workflows/docker.yaml | 106 ++++++++++++++++++ Dockerfile | 17 ++- Dockerfile.arm | 22 ---- Dockerfile.arm64 | 22 ---- 6 files changed, 187 insertions(+), 49 deletions(-) create mode 100644 .github/actions/docker-multi-login-action/action.yml create mode 100644 .github/actions/docker-target-image-list-action/action.yml create mode 100644 .github/workflows/docker.yaml delete mode 100644 Dockerfile.arm delete mode 100644 Dockerfile.arm64 diff --git a/.github/actions/docker-multi-login-action/action.yml b/.github/actions/docker-multi-login-action/action.yml new file mode 100644 index 00000000..aab3f206 --- /dev/null +++ b/.github/actions/docker-multi-login-action/action.yml @@ -0,0 +1,23 @@ +name: 'Docker Multi Login Action' +description: 'Log in to dockerhub, quay, and github container registry' +runs: + using: "composite" + steps: + - shell: bash + run: | + echo "🔑 Logging into dockerhub..." + if docker login --username ${{ fromJSON(env.secrets).DOCKERHUB_USERNAME }} --password ${{ fromJSON(env.secrets).DOCKERHUB_PASSWORD }} > /dev/null 2>&1; then + echo "🎉 Login Succeeded!" + fi + - shell: bash + run: | + echo "🔑 Logging into quay.io..." + if docker login quay.io --username ${{ fromJSON(env.secrets).QUAY_USERNAME }} --password ${{ fromJSON(env.secrets).QUAY_PASSWORD }} > /dev/null 2>&1; then + echo "🎉 Login Succeeded!" + fi + - shell: bash + run: | + echo "🔑 Logging into ghcr.io..." + if docker login ghcr.io --username ${{ fromJSON(env.secrets).GHCR_USERNAME }} --password ${{ fromJSON(env.secrets).GHCR_PASSWORD }} > /dev/null 2>&1; then + echo "🎉 Login Succeeded!" + fi diff --git a/.github/actions/docker-target-image-list-action/action.yml b/.github/actions/docker-target-image-list-action/action.yml new file mode 100644 index 00000000..dc08c893 --- /dev/null +++ b/.github/actions/docker-target-image-list-action/action.yml @@ -0,0 +1,46 @@ +name: 'Docker Target Image List Generator' +description: 'A Github Action to generate a list of fully qualified target images for docker related steps' +inputs: + registries: + description: "Comma separated list of docker registries" + required: false + default: "docker.io,quay.io,ghcr.io" + images: + description: "Comma separated list of images" + required: true + tags: + description: "Comma separated list of image tags" + required: false + default: "edge" +outputs: + fully-qualified-target-images: + description: "List of fully qualified docker target images" + value: ${{ steps.gen-fqti.outputs.fully-qualified-target-images }} +runs: + using: "composite" + steps: + - name: Generate fully qualified docker target images + id: gen-fqti + shell: bash + run: | + IFS=',' read -r -a registries <<< "${{ inputs.registries }}" + IFS=',' read -r -a images <<< "${{ inputs.images }}" + IFS=',' read -r -a tags <<< "${{ inputs.tags }}" + FQTI="" + echo "Generating fully qualified docker target images for:" + echo "🐋 Registries: ${#registries[@]}" + echo "📷 Images: ${#images[@]}" + echo "🏷️ Tags: ${#tags[@]}" + echo "🧮 Total: $((${#registries[@]}*${#images[@]}*${#tags[@]}))" + for registry in "${registries[@]}"; do + for image in "${images[@]}"; do + for tag in "${tags[@]}"; do + if [ -z "$FQTI" ]; then + FQTI="${registry}/${image}:${tag}" + else + FQTI="$FQTI,${registry}/${image}:${tag}" + fi + done + done + done + echo ::set-output name=fully-qualified-target-images::${FQTI} diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 00000000..831ab495 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,106 @@ +name: varken +on: + schedule: + - cron: '0 10 * * *' + push: + branches: master + tags: + - 'v*.*.*' + paths: + - 'varken/**' + - 'Varken.py' + - 'Dockerfile' + pull_request: + branches: master + paths: + - 'varken/**' + - 'Varken.py' + - 'Dockerfile' + workflow_dispatch: + inputs: + tag: + description: 'Use this tag instead of most recent' + required: false + ignore-existing-tag: + description: 'Ignore existing tag if "true"' + required: false +env: + IMAGES: ${{ github.repository_owner }}/${{ github.workflow }} + PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7" +jobs: + lint-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-verison: '3.x' + run: pip install flake8 + - name: Lint + run: flake8 --max-line-length 120 Varken.py varken/*.py + build: + runs-on: ubuntu-latest + needs: lint-and-test + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Prepare + id: prep + run: | + VERSION=edge + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} + fi + if [ "${{ github.event_name }}" = "schedule" ]; then + VERSION=nightly + fi + TAGS="${VERSION}" + if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="$TAGS,latest" + fi + echo ::set-output name=version::${VERSION} + echo ::set-output name=tags::${TAGS} + echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + echo ::set-output name=vcs_ref::${GITHUB_SHA::8} + - uses: ./.github/actions/docker-target-image-list-action + name: Generate Target Images + id: gen-tags + with: + images: ${{ env.IMAGES }} + tags: ${{ steps.prep.outputs.tags }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: ${{ env.PLATFORMS }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + with: + install: true + version: latest + driver-opts: image=moby/buildkit:master + - name: Docker Multi Login + uses: ./.github/actions/docker-multi-login-action + env: + secrets: ${{ toJSON(secrets) }} + - name: Build and Push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: ${{ env.PLATFORMS }} + pull: true + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.gen-tags.outputs.fully-qualified-target-images }} + build-args: | + VERSION=${{ steps.prep.outputs.version }} + BUILD_DATE=${{ steps.prep.outputs.build_date }} + VCS_REF=${{ steps.prep.outputs.vcs_ref }} + - name: Inspect + if: ${{ github.event_name != 'pull_request' }} + run: | + IFS=',' read -r -a images <<< "${{ steps.gen-tags.outputs.fully-qualified-target-images }}" + for image in "${images[@]}"; do + docker buildx imagetools inspect ${image} + done diff --git a/Dockerfile b/Dockerfile index 5538ce1f..94a90ad7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,15 @@ -FROM amd64/python:3.7.3-alpine - -LABEL maintainers="dirtycajunrice,samwiseg0" +FROM python:3.9.1-alpine + +LABEL maintainer="dirtycajunrice,samwiseg0" \ + org.opencontainers.image.created=$BUILD_DATE \ + org.opencontainers.image.url="https://github.com/Boerderij/Varken" \ + org.opencontainers.image.source="https://github.com/Boerderij/Varken" \ + org.opencontainers.image.version=$VERSION \ + org.opencontainers.image.revision=$VCS_REF \ + org.opencontainers.image.vendor="boerderij" \ + org.opencontainers.image.title="varken" \ + org.opencontainers.image.description="Varken is a standalone application to aggregate data from the Plex ecosystem into InfluxDB using Grafana for a frontend" \ + org.opencontainers.image.licenses="MIT" ENV DEBUG="True" @@ -20,5 +29,3 @@ RUN apk add --no-cache tzdata && \ pip install --no-cache-dir -r /app/requirements.txt CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py - -VOLUME /config diff --git a/Dockerfile.arm b/Dockerfile.arm deleted file mode 100644 index 2a5732fd..00000000 --- a/Dockerfile.arm +++ /dev/null @@ -1,22 +0,0 @@ -FROM arm32v6/python:3.7.3-alpine - -LABEL maintainers="dirtycajunrice,samwiseg0" - -ENV DEBUG="True" - -ENV DATA_FOLDER="/config" - -WORKDIR /app - -COPY /requirements.txt /Varken.py /app/ - -COPY /varken /app/varken - -COPY /data /app/data - -RUN apk add --no-cache tzdata && \ - pip install --no-cache-dir -r /app/requirements.txt - -CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py - -VOLUME /config diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 deleted file mode 100644 index a83d917e..00000000 --- a/Dockerfile.arm64 +++ /dev/null @@ -1,22 +0,0 @@ -FROM arm64v8/python:3.7.3-alpine - -LABEL maintainers="dirtycajunrice,samwiseg0" - -ENV DEBUG="True" - -ENV DATA_FOLDER="/config" - -WORKDIR /app - -COPY /requirements.txt /Varken.py /app/ - -COPY /varken /app/varken - -COPY /data /app/data - -RUN apk add --no-cache tzdata && \ - pip install --no-cache-dir -r /app/requirements.txt - -CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py - -VOLUME /config From 0906480270f89e0f80843fe2bfcbaa70bab3cefb Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Mon, 21 Dec 2020 11:00:45 -0600 Subject: [PATCH 17/25] make version/branch dynamic to build and add build-date --- .github/workflows/docker.yaml | 8 ++- .gitlab-ci.yml | 128 ---------------------------------- Dockerfile | 16 +++-- Varken.py | 4 +- varken/__init__.py | 3 +- 5 files changed, 20 insertions(+), 139 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 831ab495..9d653303 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -3,7 +3,9 @@ on: schedule: - cron: '0 10 * * *' push: - branches: master + branches: + - master + - develop tags: - 'v*.*.*' paths: @@ -11,7 +13,9 @@ on: - 'Varken.py' - 'Dockerfile' pull_request: - branches: master + branches: + - master + - develop paths: - 'varken/**' - 'Varken.py' diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 464e3586..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,128 +0,0 @@ -stages: - - test - - build and push - - manifests - - release - -.common_build: &common_build - image: docker:stable - stage: build and push - variables: - DOCKER_DRIVER: overlay2 - services: - - docker:dind - except: - - tags - only: - changes: - - "Dockerfile*" - - Varken.py - - varken/* - - .gitlab-ci.yml - before_script: - - mkdir $HOME/.docker - - echo '{"experimental":"enabled"}' > $HOME/.docker/config.json - - if [[ $CI_COMMIT_REF_NAME == "master" ]]; then - export TAG=$(grep -i version varken/__init__.py | cut -d \ -f3 | tr -d \"); - else - export TAG="develop"; - fi - - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USER" --password-stdin - - export CI_PROJECT_PATH=$(echo $CI_PROJECT_PATH | tr "[:upper:]" "[:lower:]") - -.common_release: &common_release - <<: *common_build - tags: - - docker - - shared - only: - refs: - - master - -flake8: - image: python:3.7.3-alpine - stage: test - cache: - key: "varken-cache" - paths: - - .cache/pip - - venv/ - variables: - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - tags: - - shared - before_script: - - python -m venv venv - - source venv/bin/activate - - pip install -U flake8 - script: - - flake8 --max-line-length 120 Varken.py varken/*.py - -amd64: - <<: *common_build - tags: - - docker - - shared - script: - - docker build --pull - --cache-from "$CI_PROJECT_PATH":"$TAG-amd64" - -t "$CI_PROJECT_PATH":"$TAG-amd64" . - - docker push "$CI_PROJECT_PATH":"$TAG-amd64" - -armv6: - <<: *common_build - tags: - - docker - - arm - script: - - docker build --pull - --cache-from "$CI_PROJECT_PATH":"$TAG-arm" - -t "$CI_PROJECT_PATH":"$TAG-arm" - -f Dockerfile.arm . - - docker push "$CI_PROJECT_PATH":"$TAG-arm" - -arm64v8: - <<: *common_build - tags: - - docker - - arm64 - script: - - docker build --pull - --cache-from "$CI_PROJECT_PATH":"$TAG-arm64" - -t "$CI_PROJECT_PATH":"$TAG-arm64" - -f Dockerfile.arm64 . - - docker push "$CI_PROJECT_PATH":"$TAG-arm64" - -versioned: - <<: *common_build - stage: manifests - tags: - - docker - - shared - script: - - docker manifest create "$CI_PROJECT_PATH":"$TAG" - "$CI_PROJECT_PATH":"$TAG-amd64" - "$CI_PROJECT_PATH":"$TAG-arm64" - "$CI_PROJECT_PATH":"$TAG-arm" - - docker manifest push -p "$CI_PROJECT_PATH":"$TAG" - -latest: - <<: *common_release - stage: manifests - tags: - - docker - script: - - docker manifest create "$CI_PROJECT_PATH":latest - "$CI_PROJECT_PATH":"$TAG-amd64" - "$CI_PROJECT_PATH":"$TAG-arm64" - "$CI_PROJECT_PATH":"$TAG-arm" - - docker manifest push -p "$CI_PROJECT_PATH":latest - -github: - <<: *common_release - stage: release - script: - - apk add git - - git remote set-url origin "https://$GITHUB_USER:$GITHUB_TOKEN@github.com/$CI_PROJECT_PATH.git" - - git tag $TAG - - git push --tags \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 94a90ad7..7cf4b07e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,11 @@ FROM python:3.9.1-alpine +ENV DEBUG="True" \ + DATA_FOLDER="/config" \ + VERSION="0.0.0" + BRANCH="edge" + BUILD_DATE="1/1/1970" + LABEL maintainer="dirtycajunrice,samwiseg0" \ org.opencontainers.image.created=$BUILD_DATE \ org.opencontainers.image.url="https://github.com/Boerderij/Varken" \ @@ -11,10 +17,6 @@ LABEL maintainer="dirtycajunrice,samwiseg0" \ org.opencontainers.image.description="Varken is a standalone application to aggregate data from the Plex ecosystem into InfluxDB using Grafana for a frontend" \ org.opencontainers.image.licenses="MIT" -ENV DEBUG="True" - -ENV DATA_FOLDER="/config" - WORKDIR /app COPY /requirements.txt /Varken.py /app/ @@ -25,7 +27,9 @@ COPY /data /app/data COPY /utilities /app/data/utilities -RUN apk add --no-cache tzdata && \ - pip install --no-cache-dir -r /app/requirements.txt +RUN \ + apk add --no-cache tzdata \ + && pip install --no-cache-dir -r /app/requirements.txt \ + && sed -i "s/0.0.0/${VERSION}/;s/develop/${BRANCH}/;s/1\/1\/1970/${BUILD_DATE//\//\\/}/" varken/__init__.py CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py diff --git a/Varken.py b/Varken.py index f8c6270a..3641cbc4 100644 --- a/Varken.py +++ b/Varken.py @@ -15,7 +15,7 @@ from varken import structures # noqa from varken.ombi import OmbiAPI from varken.unifi import UniFiAPI -from varken import VERSION, BRANCH +from varken import VERSION, BRANCH, BUILD_DATE from varken.sonarr import SonarrAPI from varken.radarr import RadarrAPI from varken.lidarr import LidarrAPI @@ -87,7 +87,7 @@ def thread(job, **kwargs): vl.logger.info(u"Python %s", version) - vl.logger.info("Varken v%s-%s", VERSION, BRANCH) + vl.logger.info("Varken v%s-%s %s", VERSION, BRANCH, BUILD_DATE) CONFIG = INIParser(DATA_FOLDER) DBMANAGER = DBManager(CONFIG.influx_server) diff --git a/varken/__init__.py b/varken/__init__.py index 863ebfa0..2971205d 100644 --- a/varken/__init__.py +++ b/varken/__init__.py @@ -1,2 +1,3 @@ -VERSION = "1.7.7" +VERSION = "0.0.0" BRANCH = 'develop' +BUILD_DATE = '1/1/1970' From 09432c3724c117181556a53a324a68cc31d7b1f1 Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Mon, 21 Dec 2020 11:05:22 -0600 Subject: [PATCH 18/25] move run to test line --- .github/workflows/docker.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 9d653303..6d2c8cce 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -41,9 +41,8 @@ jobs: uses: actions/setup-python@v2 with: python-verison: '3.x' - run: pip install flake8 - name: Lint - run: flake8 --max-line-length 120 Varken.py varken/*.py + run: pip install flake8 && flake8 --max-line-length 120 Varken.py varken/*.py build: runs-on: ubuntu-latest needs: lint-and-test From 286bf1ed291dc7c043b53047be4526c5dc8b266f Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Mon, 21 Dec 2020 11:11:50 -0600 Subject: [PATCH 19/25] have self check --- .github/workflows/docker.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 6d2c8cce..14dfafa6 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -9,6 +9,7 @@ on: tags: - 'v*.*.*' paths: + - '.github/workflows/docker.yaml' - 'varken/**' - 'Varken.py' - 'Dockerfile' @@ -17,6 +18,7 @@ on: - master - develop paths: + - '.github/workflows/docker.yaml' - 'varken/**' - 'Varken.py' - 'Dockerfile' From 307eb62adfee6405e236a7b5a3fe90cf49e3b1ea Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Mon, 21 Dec 2020 11:16:00 -0600 Subject: [PATCH 20/25] remove f from strings with no formatting --- varken/iniparser.py | 2 +- varken/unifi.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/varken/iniparser.py b/varken/iniparser.py index 9de62bfa..e241f31b 100644 --- a/varken/iniparser.py +++ b/varken/iniparser.py @@ -254,7 +254,7 @@ def parse_opts(self, read_file=False): server_id) exit(1) - maxmind_license_key = env.get(f'VRKN_GLOBAL_MAXMIND_LICENSE_KEY', + maxmind_license_key = env.get('VRKN_GLOBAL_MAXMIND_LICENSE_KEY', self.config.get('global', 'maxmind_license_key')) server = TautulliServer(id=server_id, url=scheme + url, api_key=apikey, diff --git a/varken/unifi.py b/varken/unifi.py index 2c3d5d0b..2d792b8b 100644 --- a/varken/unifi.py +++ b/varken/unifi.py @@ -27,7 +27,7 @@ def get_cookie(self): post = connection_handler(self.session, req, self.server.verify_ssl, as_is_reply=True) if not post or not post.cookies.get('unifises'): - self.logger.error(f"Could not retrieve session cookie from UniFi Controller") + self.logger.error("Could not retrieve session cookie from UniFi Controller") return cookies = {'unifises': post.cookies.get('unifises')} @@ -39,7 +39,7 @@ def get_site(self): get = connection_handler(self.session, req, self.server.verify_ssl) if not get: - self.logger.error(f"Could not get list of sites from UniFi Controller") + self.logger.error("Could not get list of sites from UniFi Controller") return site = [site['name'] for site in get['data'] if site['name'].lower() == self.server.site.lower() or site['desc'].lower() == self.server.site.lower()] From 8c576423f4121f4ff5e6e17977da226a11a4c545 Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Mon, 21 Dec 2020 11:17:35 -0600 Subject: [PATCH 21/25] fix typo --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 14dfafa6..1b4536b0 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -42,7 +42,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v2 with: - python-verison: '3.x' + python-version: '3.x' - name: Lint run: pip install flake8 && flake8 --max-line-length 120 Varken.py varken/*.py build: From 61bcc5acb4d0001cf2e77d1b40259305922dcdcc Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Mon, 21 Dec 2020 11:19:40 -0600 Subject: [PATCH 22/25] make forced lowercase --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 1b4536b0..b0bef9cb 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -31,7 +31,7 @@ on: description: 'Ignore existing tag if "true"' required: false env: - IMAGES: ${{ github.repository_owner }}/${{ github.workflow }} + IMAGES: boerderij/varken PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7" jobs: lint-and-test: From b8f9ff61aa7ddd58fa55ac485630d3bd757a8777 Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Mon, 21 Dec 2020 11:21:55 -0600 Subject: [PATCH 23/25] add escapes --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7cf4b07e..c5c41fa0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,8 @@ FROM python:3.9.1-alpine ENV DEBUG="True" \ DATA_FOLDER="/config" \ - VERSION="0.0.0" - BRANCH="edge" + VERSION="0.0.0" \ + BRANCH="edge" \ BUILD_DATE="1/1/1970" LABEL maintainer="dirtycajunrice,samwiseg0" \ From 39771182019d236c36d63686292e74dea3271240 Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Mon, 21 Dec 2020 11:31:17 -0600 Subject: [PATCH 24/25] add branch to build inputs --- .github/workflows/docker.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index b0bef9cb..8818fcbf 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -61,12 +61,16 @@ jobs: if [ "${{ github.event_name }}" = "schedule" ]; then VERSION=nightly fi + if [[ ${GITHUB_REF##*/} == "develop" ]]; then + VERSION=develop + fi TAGS="${VERSION}" if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then TAGS="$TAGS,latest" fi echo ::set-output name=version::${VERSION} echo ::set-output name=tags::${TAGS} + echo ::set-output name=branch::${GITHUB_REF##*/} echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') echo ::set-output name=vcs_ref::${GITHUB_SHA::8} - uses: ./.github/actions/docker-target-image-list-action @@ -100,6 +104,7 @@ jobs: tags: ${{ steps.gen-tags.outputs.fully-qualified-target-images }} build-args: | VERSION=${{ steps.prep.outputs.version }} + BRANCH=${{ steps.prep.outputs.branch }} BUILD_DATE=${{ steps.prep.outputs.build_date }} VCS_REF=${{ steps.prep.outputs.vcs_ref }} - name: Inspect From 50eb83a3c3c8f8dd623c4d6dce6393a165cc0f84 Mon Sep 17 00:00:00 2001 From: samwiseg0 <2241731+samwiseg0@users.noreply.github.com> Date: Mon, 21 Dec 2020 12:34:04 -0500 Subject: [PATCH 25/25] Do not lock issue as it will precent the author from commenting. --- .github/workflows/invalid_template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/invalid_template.yml b/.github/workflows/invalid_template.yml index c98d3174..647cdeca 100644 --- a/.github/workflows/invalid_template.yml +++ b/.github/workflows/invalid_template.yml @@ -15,5 +15,5 @@ jobs: issue-comment: > :wave: @{issue-author}, please edit your issue and follow the template provided. close-issue: false - lock-issue: true + lock-issue: false issue-lock-reason: 'resolved'