forked from savdagod/ha-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add devcontainer setup for local testing
See https://developers.home-assistant.io/docs/add-ons/testing/ Also: add GitHub workflows for building and linting and use structured logging
- Loading branch information
1 parent
60862c8
commit 1c1e725
Showing
15 changed files
with
526 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "devcontainer for add-on repositories", | ||
"image": "ghcr.io/home-assistant/devcontainer:addons", | ||
"appPort": ["7123:8123", "7357:4357"], | ||
"postStartCommand": "bash devcontainer_bootstrap", | ||
"postCreateCommand": "sudo apt-get update && sudo apt-get install -y libwebp-dev", | ||
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"], | ||
"containerEnv": { | ||
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/go:1": { | ||
"version": "1.23.2" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode", "golang.go", "github.vscode-github-actions"], | ||
"settings": { | ||
"terminal.integrated.profiles.linux": { | ||
"zsh": { | ||
"path": "/usr/bin/zsh" | ||
} | ||
}, | ||
"terminal.integrated.defaultProfile.linux": "zsh", | ||
"editor.formatOnPaste": false, | ||
"editor.formatOnSave": true, | ||
"editor.formatOnType": true, | ||
"files.trimTrailingWhitespace": true | ||
} | ||
} | ||
}, | ||
"mounts": [ "type=volume,target=/var/lib/docker" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Go | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./TidbytAssistant | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.23.2" | ||
|
||
- name: Install dependencies | ||
run: sudo apt-get update && sudo apt-get -y install libweb-dev | ||
|
||
- name: Lint | ||
run: go vet ./... | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: hadolint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
defaults: | ||
run: | ||
working-directory: ./TidbytAssistant | ||
|
||
jobs: | ||
hadolint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4.2.1 | ||
- uses: brpaz/hadolint-action@v1.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Start Home Assistant", | ||
"type": "shell", | ||
"command": "supervisor_run", | ||
"group": { | ||
"kind": "test", | ||
"isDefault": true | ||
}, | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new" | ||
}, | ||
"problemMatcher": [] | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,35 @@ | ||
ARG BUILD_FROM | ||
ARG BUILD_FROM=homeassistant/amd64-base:latest | ||
|
||
FROM $BUILD_FROM | ||
FROM ${BUILD_FROM} AS builder | ||
|
||
# Args from build.yaml | ||
ARG GO_VERSION | ||
ARG GO_VERSION=1.23.2 | ||
|
||
# Copy data for add-on | ||
COPY hooks.yaml / | ||
ADD scripts /opt/scripts | ||
RUN chmod a+x /opt/scripts/* | ||
ADD display /opt/display | ||
SHELL ["/bin/ash", "-eo", "pipefail", "-c"] | ||
|
||
# Download Go and add to PATH | ||
RUN arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \ | ||
wget "https://go.dev/dl/go${GO_VERSION}.linux-${arch}.tar.gz" | ||
wget -q "https://go.dev/dl/go${GO_VERSION}.linux-${arch}.tar.gz" | ||
RUN arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \ | ||
tar -xzf go${GO_VERSION}.linux-${arch}.tar.gz -C /usr/local && \ | ||
rm go${GO_VERSION}.linux-${arch}.tar.gz | ||
ENV PATH=${PATH}:/usr/local/go/bin | ||
|
||
# Build Webhook binary using Go and move to PATH | ||
RUN go install github.com/adnanh/webhook@latest | ||
RUN mv /root/go/bin/webhook /usr/local/bin/webhook | ||
tar -xzf "go${GO_VERSION}.linux-${arch}.tar.gz" -C /usr/local && \ | ||
rm "go${GO_VERSION}.linux-${arch}.tar.gz" | ||
ENV PATH=/usr/local/go/bin:${PATH} | ||
ENV GOROOT=/usr/local/go | ||
|
||
# Download dependencies | ||
ENV GOPATH /usr/local/go | ||
ENV REPO $GOPATH/pixlet | ||
RUN apk update && \ | ||
apk upgrade -U && \ | ||
apk add curl wget git make libc-dev gcc ca-certificates npm libwebp-dev libwebp-tools patchelf gcompat && \ | ||
rm -rf /var/cache/* | ||
|
||
# Download Pixlet | ||
RUN git clone https://github.com/savdagod/pixlet.git $REPO | ||
WORKDIR $REPO | ||
|
||
#Build Pixlet | ||
RUN npm install && npm run build | ||
RUN make build | ||
RUN apk --no-cache add libc-dev gcc ca-certificates libwebp-dev libwebp-static | ||
|
||
# Move pixlet binary to path | ||
RUN mv $GOPATH/pixlet/pixlet /usr/local/bin/pixlet | ||
# Build binary | ||
COPY *.go go.mod go.sum /src/ | ||
WORKDIR /src | ||
RUN CGO_ENABLED=1 go build -ldflags "-s -w -linkmode=external '-extldflags=-static -lsharpyuv'" -o /tidbyt-assistant ./... | ||
|
||
# Clean up build prereqs | ||
RUN apk del -r curl wget git make gcc patchelf libc-dev | ||
RUN rm -r $GOPATH | ||
RUN rm -r /root/go | ||
FROM scratch | ||
|
||
CMD [ "webhook", "-hooks", "/hooks.yaml", "-verbose" ] | ||
COPY --from=builder /tidbyt-assistant /tidbyt-assistant | ||
#COPY --from=builder /usr/lib/libwebp*.so* /usr/lib/libsharpyuv.so* /usr/lib/ | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY display /display | ||
|
||
ENTRYPOINT [ "/tidbyt-assistant" ] | ||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/tidbyt-assistant", "-health", "http://localhost:9000/health" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
args: | ||
GO_VERSION: "1.23.1" | ||
GO_VERSION: "1.23.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.