From 85048ede5a658db9107d08f0bb467a0cc3061ae9 Mon Sep 17 00:00:00 2001 From: Tom Quist Date: Sun, 2 Jun 2024 13:07:45 +0200 Subject: [PATCH 1/3] Add most basic CI lint step This adds the most basic lint step to ensure valid Python code. --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a85733..8d7c30c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,9 @@ on: create: tags: - "*" + pull_request: + branches: + - "main" env: REGISTRY: ghcr.io @@ -110,3 +113,21 @@ jobs: - name: Inspect image run: | docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }}:${{ steps.meta.outputs.version }} + + lint: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + - name: Install pyflakes + run: | + python -m pip install --upgrade pip + pip install pyflakes + - name: Run pyflakes + run: | + pyflakes ./*.py \ No newline at end of file From f87778cd5a2b761c35cb082f90aff6b067d8427a Mon Sep 17 00:00:00 2001 From: Tom Quist Date: Sun, 2 Jun 2024 13:10:55 +0200 Subject: [PATCH 2/3] Fix lint errors --- HoymilesZeroExport.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/HoymilesZeroExport.py b/HoymilesZeroExport.py index af670f9..da47f94 100644 --- a/HoymilesZeroExport.py +++ b/HoymilesZeroExport.py @@ -17,7 +17,6 @@ __author__ = "Tobias Kraft" __version__ = "1.94" -import requests import time from requests.sessions import Session from requests.auth import HTTPBasicAuth @@ -826,7 +825,7 @@ def GetJson(self, path): return session.get(url, timeout=10).json() def GetPowermeterWatts(self): - ParsedData = self.GetJson(f'/rest') + ParsedData = self.GetJson('/rest') return CastToInt(ParsedData['saldo']) class DTU(Powermeter): From 7945c9855e871c9d7ac28bea5f444f7c3b17442e Mon Sep 17 00:00:00 2001 From: Tom Quist Date: Sun, 2 Jun 2024 13:14:43 +0200 Subject: [PATCH 3/3] Remove push in PR --- .github/workflows/ci.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d7c30c..5176243 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,9 +53,21 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push + - name: Build + if: github.event_name == 'pull_request' id: build uses: docker/build-push-action@v5 + with: + context: . + platforms: ${{ matrix.platform }} + file: ./Dockerfile + labels: ${{ steps.meta.outputs.labels }} + outputs: type=docker,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }} + build-args: BASE=${{ matrix.base }} + - name: Build and push + if: github.event_name != 'pull_request' + id: build_push + uses: docker/build-push-action@v5 with: context: . platforms: ${{ matrix.platform }} @@ -64,11 +76,13 @@ jobs: outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true build-args: BASE=${{ matrix.base }} - name: Export digest + if: github.event_name != 'pull_request' run: | mkdir -p /tmp/digests digest="${{ steps.build.outputs.digest }}" touch "/tmp/digests/${digest#sha256:}" - name: Upload digest + if: github.event_name != 'pull_request' uses: actions/upload-artifact@v3 with: name: digests @@ -78,6 +92,7 @@ jobs: merge: runs-on: ubuntu-latest + if: github.event_name != 'pull_request' permissions: contents: read packages: write