Skip to content
Draft
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
1 change: 0 additions & 1 deletion .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
matrix:
platform:
- linux/arm64/v8
- linux/arm
- linux/arm64
- linux/amd64

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'deployments/**'
- 'gen/**'
- '*.md'
- 'ui/**'

pull_request:
branches:
Expand All @@ -23,6 +24,7 @@ on:
- 'deployments/**'
- 'gen/**'
- '*.md'
- 'ui/**'

jobs:
lint:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'deployments/**'
- 'scripts/**'
- '*.md'
- 'ui/**'

pull_request:
branches:
Expand All @@ -23,6 +24,7 @@ on:
- 'deployments/**'
- 'scripts/**'
- '*.md'
- 'ui/**'

jobs:
tests:
Expand Down
155 changes: 155 additions & 0 deletions .github/workflows/ui-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: "UI CI/CD"

on:
push:
branches:
- main
- v2
paths:
- 'ui/**'
- '.github/workflows/ui-ci.yml'

pull_request:
branches:
- main
- v2
types: [ opened, synchronize ]
paths:
- 'ui/**'
- '.github/workflows/ui-ci.yml'

jobs:
# Lint job - runs on PR and push
lint:
name: "Lint"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ui

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.13.0
run_install: 'true'

- name: Run ESLint
run: pnpm lint

# Test job - runs on PR and push
test:
name: "Test"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ui

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.13.0
run_install: 'true'

- name: Run tests
run: |
if pnpm run test --if-present; then
echo "Tests completed successfully"
else
echo "No tests found or tests failed, but continuing..."
fi
continue-on-error: true

- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: ui-test-results
path: ui/coverage/
if-no-files-found: ignore

# Build job - runs on PR and push
build:
name: "Build UI"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ui

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.13.0
run_install: 'true'

- name: Build application
run: pnpm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ui-build
path: ui/dist/
retention-days: 7

# Type check job - runs on PR and push
type-check:
name: "Type Check"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ui

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.13.0
run_install: 'true'

- name: Run TypeScript type check
run: pnpm tsc

# Test coverage report - runs only on PR
test-coverage:
name: "Test Coverage Report"
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: [ test ]
continue-on-error: true
defaults:
run:
working-directory: ./ui

permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 10.13.0
run_install: true

- name: Generate coverage report
uses: artiomtr/jest-coverage-report-action@v2
with:
test-script: pnpm jest --reporters="summary" --reporters="github-actions" --passWithNoTests --json --outputFile=report.json
package-manager: pnpm
github-token: ${{ secrets.GITHUB_TOKEN }}
19 changes: 11 additions & 8 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$TARGETPLATFORM golang:1.24.0-bookworm AS base

Check warning on line 1 in build/Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image (linux/arm64)

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

Check warning on line 1 in build/Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image (linux/arm64/v8)

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

Check warning on line 1 in build/Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image (linux/amd64)

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

WORKDIR /ChargePi/src
COPY . /ChargePi/src
Expand Down Expand Up @@ -29,17 +29,21 @@
RUN --mount=type=cache,target="/root/.cache/go-build" \
go build -o ChargePi -v -tags="linux" .

FROM --platform=$BUILDPLATFORM node:19 AS build-ui
FROM node:24 AS build-ui

WORKDIR /ui

COPY ./ui/package*.json .
COPY ./ui .
RUN corepack enable pnpm
RUN corepack install -g [email protected]
COPY ./ui/pnpm-lock.yaml ./
COPY ./ui/package*.json ./
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile

RUN --mount=type=cache,target=/root/.npm npm install
RUN npm run build
COPY ./ui .
RUN pnpm build

# Test the client
FROM --platform=$TARGETPLATFORM golang:1.24.0-bookworm AS test

Check warning on line 46 in build/Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image (linux/arm64)

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

Check warning on line 46 in build/Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image (linux/arm64/v8)

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

Check warning on line 46 in build/Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image (linux/amd64)

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

WORKDIR /ChargePi/src

Expand Down Expand Up @@ -71,7 +75,7 @@
# Run tests
ENTRYPOINT ["go", "test","-v","./...","-coverpkg=./...","-short" ,"-coverprofile=unit_coverage.out"]

FROM --platform=$TARGETPLATFORM alpine AS chargepi

Check warning on line 78 in build/Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image (linux/arm64)

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

Check warning on line 78 in build/Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image (linux/arm64/v8)

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

Check warning on line 78 in build/Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image (linux/amd64)

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

WORKDIR /etc/ChargePi

Expand All @@ -87,10 +91,9 @@
COPY --from=base /ChargePi/src/ChargePi /usr/bin/ChargePi

# Copy the UI static files
COPY --from=build-ui /ui/build/* /usr/bin/ui/build/*
COPY --from=build-ui /ui/build /usr/bin/ui/build

EXPOSE 8080
HEALTHCHECK --interval=5s --timeout=3s CMD curl --fail http://localhost:8080/healthz || exit 1

ENTRYPOINT ["ChargePi"]
CMD ["-c", "/etc/ChargePi/configs/config.yaml", "run"]
ENTRYPOINT ["ChargePi", "-c", "/etc/ChargePi/configs/config.yaml", "run"]
13 changes: 0 additions & 13 deletions ui/.eslintignore

This file was deleted.

35 changes: 16 additions & 19 deletions ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['svelte3', '@typescript-eslint'],
ignorePatterns: ['*.cjs'],
overrides: [{files: ['*.svelte'], processor: 'svelte3/svelte3'}],
settings: {
'svelte3/typescript': () => require('typescript'),
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
},
env: {
browser: true,
es2017: true,
node: true,
},
};
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
10 changes: 0 additions & 10 deletions ui/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion ui/.npmrc

This file was deleted.

13 changes: 0 additions & 13 deletions ui/.prettierignore

This file was deleted.

9 changes: 0 additions & 9 deletions ui/.prettierrc

This file was deleted.

Loading
Loading