diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bbb969b..1742e3b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: push: tags: - - 'v*' + - '*' env: REGISTRY: ghcr.io @@ -19,10 +19,10 @@ jobs: packages: write steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Log in to the Container registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -30,14 +30,21 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push Docker image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 diff --git a/LICENSE b/LICENSE index e4fe93d..298ab0b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 dbrennand +Copyright (c) 2024 dbrennand Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/requirements.txt b/requirements.txt index 1f28d53..37e399f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,9 @@ -certifi==2023.7.22 -influxdb-client==1.37.0 -loguru==0.7.0 -python-dateutil==2.8.2 +certifi==2024.7.4 +influxdb-client==1.45.0 +loguru==0.7.2 +python-dateutil==2.9.0.post0 reactivex==4.0.4 +setuptools==73.0.1 six==1.16.0 -typing_extensions==4.7.1 -urllib3==2.0.4 +typing_extensions==4.12.2 +urllib3==2.2.2 diff --git a/speeder.py b/speeder.py index 7f33f6c..43b455a 100644 --- a/speeder.py +++ b/speeder.py @@ -1,7 +1,7 @@ """ MIT License -Copyright (c) 2023 dbrennand +Copyright (c) 2024 dbrennand Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,6 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ + from influxdb_client.client.write_api import SYNCHRONOUS from influxdb_client import InfluxDBClient from loguru import logger @@ -54,7 +55,7 @@ exit(1) else: # Create list from comma separated string of server IDs - SPEEDER_SPEEDTEST_SERVER_ID = SPEEDER_SPEEDTEST_SERVER_ID.split(",") + SPEEDER_SPEEDTEST_SERVER_IDs = SPEEDER_SPEEDTEST_SERVER_ID.split(",") # Connect to InfluxDB logger.debug( @@ -67,7 +68,7 @@ ) as client: # Run the speedtest using the librespeed/speedtest-cli on an interval while True: - for server_id in SPEEDER_SPEEDTEST_SERVER_ID: + for server_id in SPEEDER_SPEEDTEST_SERVER_IDs: logger.debug(f"Running speedtest for server ID: {server_id}.") result = subprocess.run( [ @@ -84,15 +85,20 @@ # Check if the speedtest failed if result.returncode != 0: # CLI errors go to stdout - logger.debug( + logger.error( f"Speedtest for server ID: {server_id} failed with exit code: {result.returncode}.\nError: {result.stdout}" ) else: logger.debug(f"Speedtest for server ID: {server_id} succeeded.") try: json_result = json.loads(result.stdout) + # Check if the JSON result is empty + if not json_result: + raise json.decoder.JSONDecodeError( + "JSON result is empty.", json_result, 0 + ) except json.decoder.JSONDecodeError as err: - logger.debug( + logger.error( f"Failed to parse JSON results for server ID: {server_id}.\nError: {err}" ) continue