Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/pythonpublish.yml
#	Dockerfile
#	README.md
#	grafana/dashboard.json
#	qbittorrent_exporter/exporter.py
#	setup.py
  • Loading branch information
friendlyFriend4000 committed Nov 26, 2023
2 parents 5e3676b + 75db331 commit 826a0d3
Show file tree
Hide file tree
Showing 15 changed files with 767 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
relative_files = True
omit = tests/*
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
__pycache__/
.coverage*
.github
.gitignore
.pdm*
.pre-commit-config.yaml
.vscode
build/
logo.png
tests
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
61 changes: 36 additions & 25 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,63 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Extract branch name
shell: bash
run: |
tag=${GITHUB_REF#refs/tags/}
tag=${tag#refs/heads/}
if echo $tag | grep -q -E "[0-9]+\.[0-9]+\.[0-9]+"; then
tag="v$tag"
fi
echo "##[set-output name=tag;]$tag"
id: extract_branch
uses: docker/setup-buildx-action@v3

- name: Docker hub meta
id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=true
tags: |
type=semver,pattern=v{{version}}
type=ref,event=branch
type=sha
images: ${{ github.actor }}/prometheus-qbittorrent-exporter

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Build and push docker to DockerHub
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64,linux/386
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: GHCR Docker meta
id: metaghcr
uses: docker/metadata-action@v5
with:
flavor: |
latest=true
tags: |
${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:latest
${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:${{ steps.extract_branch.outputs.tag }}
type=semver,pattern=v{{version}}
type=ref,event=branch
type=sha
images: ghcr.io/${{ github.actor }}/prometheus-qbittorrent-exporter

- name: Login to Github Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.GHCR_PERSONAL_TOKEN }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker to Github Container Registry
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64,linux/386
tags: |
ghcr.io/${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:latest
ghcr.io/${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:${{ steps.extract_branch.outputs.tag }}
tags: ${{ steps.metaghcr.outputs.tags }}
labels: ${{ steps.metaghcr.outputs.labels }}
59 changes: 59 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Run Unit Test via Pytest

on:
pull_request:
push:
branches:
- "master"

jobs:
lint-and-test:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
checks: write
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
- name: Install dependencies
run: pdm install
- name: Lint with black
uses: psf/black@stable
with:
options: "--check --verbose"
- name: Test with pytest
run: |
pdm run pytest --junit-xml=test-results.xml
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
test-results.xml
- name: Test with coverage
run: |
pdm run coverage run -m pytest -v -s
- name: Generate Coverage Report
run: |
pdm run coverage report -m
- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v3
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
name: python-coverage-comment-action
path: python-coverage-comment-action.txt
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,12 @@ dmypy.json

# Pyre type checker
.pyre/

# Ignore config.env
config.env

# Ignore pdm local files
.pdm-python

# Ignore ruff files
.ruff_cache
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: local
hooks:
- id: black
name: black
stages: [commit]
types: [python]
entry: pdm run black .
language: system
pass_filenames: false
always_run: true
- id: ruff
name: ruff
stages: [commit]
types: [python]
entry: pdm run ruff .
language: system
pass_filenames: false
always_run: true
fail_fast: true
- id: pytest
name: pytest
stages: [commit]
types: [python]
entry: pdm run pytest
language: system
pass_filenames: false
always_run: true
fail_fast: true
6 changes: 6 additions & 0 deletions config.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
QBITTORRENT_HOST=localhost
QBITTORRENT_PORT=8080
QBITTORRENT_USER=admin
QBITTORRENT_PASS=adminadmin
EXPORTER_PORT=8000
METRICS_PREFIX=qbittorrent
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 826a0d3

Please sign in to comment.