Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add most basic CI lint step #204

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading