Skip to content

Commit

Permalink
Merge pull request #204 from tomquist/add-ci-lint
Browse files Browse the repository at this point in the history
Add most basic CI lint step
  • Loading branch information
reserve85 authored Jun 3, 2024
2 parents 6b2c955 + 7945c98 commit 1682580
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
38 changes: 37 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
create:
tags:
- "*"
pull_request:
branches:
- "main"

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -50,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 }}
Expand All @@ -61,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
Expand All @@ -75,6 +92,7 @@ jobs:

merge:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -110,3 +128,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
3 changes: 1 addition & 2 deletions HoymilesZeroExport.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
__author__ = "Tobias Kraft"
__version__ = "1.94"

import requests
import time
from requests.sessions import Session
from requests.auth import HTTPBasicAuth
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 1682580

Please sign in to comment.