Skip to content

Commit

Permalink
Merge pull request #16 from smlx/passthrough
Browse files Browse the repository at this point in the history
Add support for inverter and debug passthrough
  • Loading branch information
smlx authored Jan 19, 2024
2 parents 2b2d898 + f141e88 commit b6aa8ee
Show file tree
Hide file tree
Showing 29 changed files with 1,914 additions and 525 deletions.
6 changes: 3 additions & 3 deletions .github/dependabot.yml → .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: 2
updates:
- package-ecosystem: docker
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
- package-ecosystem: github-actions
interval: weekly
- package-ecosystem: docker
directory: /
schedule:
interval: daily
Expand Down
17 changes: 17 additions & 0 deletions .github/dependency-review-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# https://github.com/cncf/foundation/blob/main/allowed-third-party-license-policy.md
allow-licenses:
- 'Apache-2.0'
- 'BSD-2-Clause'
- 'BSD-2-Clause-FreeBSD'
- 'BSD-3-Clause'
- 'ISC'
- 'MIT'
- 'PostgreSQL'
- 'Python-2.0'
- 'X11'
- 'Zlib'

# this action is GPL-3 but it is only used in CI
# https://github.com/actions/dependency-review-action/issues/530#issuecomment-1638291806
allow-dependencies-licenses: >
pkg:githubactions/vladopajic/go-test-coverage@bcd064e5ceef1ccec5441519eb054263b6a44787
14 changes: 0 additions & 14 deletions .github/dependency-review-config.yml

This file was deleted.

77 changes: 27 additions & 50 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,75 +1,52 @@
name: Build
on: pull_request
name: build
on:
pull_request:
branches:
- main
permissions: {}
jobs:
build:
build-snapshot:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
binary:
- sems_mitm_exporter
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install Go
uses: actions/setup-go@v5
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: stable
- name: Set up environment
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
- run: echo "GOVERSION=$(go version)" >> "$GITHUB_ENV"
- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
version: latest
args: build --snapshot --clean
- name: Tar up binaries
# work around limitations in the upload/download artifact actions
# https://github.com/actions/download-artifact#limitations
run: tar -cvf dist.tar dist
- name: Upload binaries tar file
uses: actions/upload-artifact@v4
with:
name: dist.tar
path: dist.tar
buildimage:
permissions:
contents: read
packages: write
if: ${{ !startsWith(github.head_ref, 'dependabot/') }}
strategy:
matrix:
binary:
- sems_mitm_exporter
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download binaries tar file
uses: actions/download-artifact@v4
with:
name: dist.tar
- name: Untar binaries
run: tar -xvf dist.tar
args: build --clean --debug --single-target --snapshot
- name: Login to GHCR
uses: docker/login-action@v3
if: github.actor != 'dependabot[bot]'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
# this id is namespaced per matrix run
- name: Get Docker metadata
if: github.actor != 'dependabot[bot]'
id: docker_metadata
uses: docker/metadata-action@v5
uses: docker/metadata-action@dbef88086f6cef02e264edb7dbf63250c17cef6c # v5.5.0
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.binary }}
- run: echo "GITHUB_REPOSITORY_NAME=$(basename ${{ github.repository }})" >> "$GITHUB_ENV"
- name: Build and push ${{ matrix.binary }} container image
id: docker_build
uses: docker/build-push-action@v5
if: github.actor != 'dependabot[bot]'
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
push: true
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
file: deploy/docker/Dockerfile
file: Dockerfile
build-args: BINARY=${{ matrix.binary }}
context: dist/${{ matrix.binary }}_linux_amd64_v1
build-args:
BINARY=${{ matrix.binary }}
18 changes: 9 additions & 9 deletions .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
name: "CodeQL"

name: codeQL
on:
push:
branches:
- main
pull_request:
branches:
- main

permissions: {}
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language:
- go
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: stable
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
33 changes: 16 additions & 17 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
name: Coverage
name: coverage
on:
push:
branches:
- main

permissions: {}
jobs:
coverage:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure git
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Set up go
uses: actions/setup-go@v5
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: stable
- name: Calculate coverage
run: |
go test -v -covermode=count -coverprofile=coverage.out.raw -coverpkg=./... ./...
grep -v mock_ coverage.out.raw > coverage.out
- name: Convert coverage to lcov
uses: jandelgado/gcov2lcov-action@v1
- name: Coveralls
uses: coverallsapp/github-action@v2
go test -v -covermode=atomic -coverprofile=cover.out.raw -coverpkg=./... ./...
# remove mocks from coverage calculation
grep -Ev 'mock_|_enumer.go' cover.out.raw > cover.out
- name: Generage coverage badge
uses: vladopajic/go-test-coverage@bcd064e5ceef1ccec5441519eb054263b6a44787 # v2.8.2
with:
github-token: ${{ secrets.github_token }}
profile: cover.out
local-prefix: github.com/smlx/goodwe-exporters
git-token: ${{ secrets.GITHUB_TOKEN }}
# orphan branch for storing badges
git-branch: badges
35 changes: 25 additions & 10 deletions .github/workflows/dependabot-automerge.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

name: dependabot auto-merge
on:
pull_request:
branches:
- main
permissions: {}
jobs:
dependabot:
dependabot-automerge:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
if: github.actor == 'dependabot[bot]'
steps:
- name: Enable auto-merge for Dependabot PRs
- name: Fetch dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@c9c4182bf1b97f5224aee3906fd373f6b61b4526 # v1.6.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Auto-merge Dependabot PRs
# don't auto-merge action updates to appease OpenSSF scorecard
if: ${{ ! contains(steps.metadata.outputs.package-ecosystem, 'github-actions') }}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Auto-approve well-maintained dependencies
if: contains(steps.metadata.outputs.dependency-names, 'k8s.io/client-go')
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
19 changes: 10 additions & 9 deletions .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: 'Dependency Review'
name: dependency review
on:
- pull_request
permissions:
contents: read
pull_request:
branches:
- main
permissions: {}
jobs:
dependency-review:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: Dependency Review
uses: actions/dependency-review-action@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/dependency-review-action@c74b580d73376b7750d3d2a50bfb8adc2c937507 # v3.1.5
with:
config-file: '.github/dependency-review-config.yml'
config-file: .github/dependency-review-config.yaml
41 changes: 25 additions & 16 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
name: Lint
on: pull_request
name: lint
on:
pull_request:
branches:
- main
permissions: {}
jobs:
golangci-lint:
name: lint
lint-go:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
- uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
args: --timeout=180s
commitlint:
lint-commits:
permissions:
pull-requests: read
contents: read
pull-requests: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Lint commit messages
uses: wagoid/commitlint-github-action@v5
- uses: wagoid/commitlint-github-action@5ce82f5d814d4010519d15f0552aec4f17a1e1fe # v5.4.5
with:
configFile: .github/commitlint.config.js
lint-actions:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: docker://rhysd/actionlint:latest@sha256:2eb91a78b5a19140be099c7b4262d298c2567f2a9f27e10ed2a4323c5bcface8
with:
args: -color
Loading

0 comments on commit b6aa8ee

Please sign in to comment.