Skip to content

Commit

Permalink
Merge branch 'evcc-io:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Blowfly69 authored Apr 25, 2024
2 parents 81f94bf + 1d4e695 commit c16e5c7
Show file tree
Hide file tree
Showing 214 changed files with 23,543 additions and 2,299 deletions.
93 changes: 80 additions & 13 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ jobs:
steps:
- uses: actions/checkout@v4

# - uses: actions/setup-go@v5
- uses: erezrokah/setup-go@feat/add_cache_prefix
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: clean-cache-
cache: false
id: go

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-clean-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-clean-
${{ runner.os }}-go-
- name: Install tools
run: make install

Expand All @@ -47,12 +56,22 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: erezrokah/setup-go@feat/add_cache_prefix
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: build-cache-
cache: false
id: go

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-
${{ runner.os }}-go-
- uses: actions/setup-node@v4
with:
node-version: "18"
Expand All @@ -70,13 +89,22 @@ jobs:
steps:
- uses: actions/checkout@v4

# - uses: actions/setup-go@v5
- uses: erezrokah/setup-go@feat/add_cache_prefix
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: test-cache-
cache: false
id: go

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-test-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-test-
${{ runner.os }}-go-
- name: Test
run: mkdir dist && touch dist/empty && make test

Expand All @@ -93,12 +121,24 @@ jobs:
cache: false # avoid cache thrashing
id: go

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-lint-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-lint-
${{ runner.os }}-go-
- run: mkdir dist && touch dist/empty

- name: Lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
skip-pkg-cache: true
skip-build-cache: true
args: --out-format=colored-line-number --timeout 5m

ui:
Expand Down Expand Up @@ -139,16 +179,31 @@ jobs:
integration:
name: Integration
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2]
shardTotal: [2]

steps:
- uses: actions/checkout@v4

- uses: erezrokah/setup-go@feat/add_cache_prefix
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: integration-cache-
cache: false
id: go

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-integration-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-integration-
${{ runner.os }}-go-
- uses: actions/setup-node@v4
with:
node-version: "18"
Expand All @@ -160,15 +215,27 @@ jobs:
- name: Build Go
run: make build

- uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}

- name: Install playwright
run: npx playwright install --with-deps chromium

- name: Run tests
run: npx playwright test
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}

# - name: Run tests
# uses: docker://mcr.microsoft.com/playwright:v1.34.3-jammy
# with:
# args: npx playwright test

- uses: actions/upload-artifact@v4
if: always()
if: ${{ !cancelled() }}
with:
name: playwright-report
name: playwright-report-${{ matrix.shardIndex }}
path: playwright-report/
retention-days: 14
42 changes: 42 additions & 0 deletions .github/workflows/docs-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Create Documentation Issue

on:
pull_request_target:
types: [closed]
branches: [master]

jobs:
check-label-and-create-issue:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Check for 'needs documentation' label
id: check-label
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const hasLabel = labels.some(label => label.name === 'needs documentation');
return hasLabel;
result-encoding: string

- name: Create Docs Issue
if: steps.check-label.outputs.result == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const title = `Document: ${context.payload.pull_request.title}`;
const body = `We need to document the new feature introduced in this PR: ${context.payload.pull_request.html_url}`;
await github.rest.issues.create({
owner: 'evcc-io',
repo: 'docs',
title: title,
body: body
});
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ npm run playwright

#### Simulating device state

Since we dont want to run tests agains real devices or cloud services we've build a simple simulator that lets you emulated meters, vehicles and loadpoints. The simulators web interface runs on http://localhost:7072.
Since we don't want to run tests against real devices or cloud services, we've build a simple simulator that lets you emulated meters, vehicles and loadpoints. The simulators web interface runs on http://localhost:7072.

```
npm run simulator
Expand Down
6 changes: 5 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,18 @@ type PhaseSwitcher interface {
Phases1p3p(phases int) error
}

type PhaseGetter interface {
GetPhases() (int, error)
}

// Diagnosis is a helper interface that allows to dump diagnostic data to console
type Diagnosis interface {
Diagnose()
}

// ChargeTimer provides current charge cycle duration
type ChargeTimer interface {
ChargingTime() (time.Duration, error)
ChargeDuration() (time.Duration, error)
}

// ChargeRater provides charged energy amount in kWh
Expand Down
11 changes: 3 additions & 8 deletions api/chargemode.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ func ChargeModeString(mode string) (ChargeMode, error) {
var _ encoding.TextUnmarshaler = (*ChargeMode)(nil)

func (c *ChargeMode) UnmarshalText(text []byte) error {
casted, err := ChargeModeString(string(text))
if err != nil {
return err
}

*c = casted

return nil
var err error
*c, err = ChargeModeString(string(text))
return err
}
11 changes: 2 additions & 9 deletions api/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@ package api

type Feature int

func (f *Feature) UnmarshalText(text []byte) error {
feat, err := FeatureString(string(text))
if err == nil {
*f = feat
}
return err
}

//go:generate enumer -type Feature
//go:generate enumer -type Feature -text
const (
_ Feature = iota
Offline
CoarseCurrent
IntegratedDevice
Heating
Retryable
WelcomeCharge
)
26 changes: 21 additions & 5 deletions api/feature_enumer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c16e5c7

Please sign in to comment.