From 4b258cf2bf1668d8e0adcb6b2be96b6cda36f42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Thu, 16 Apr 2020 22:51:52 +0200 Subject: [PATCH] Add hassfest action (#5) --- README.md | 28 ++++++++++++++++++++++++++++ hassfest/Dockerfile | 33 +++++++++++++++++++++++++++++++++ hassfest/entrypoint.sh | 16 ++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 hassfest/Dockerfile create mode 100644 hassfest/entrypoint.sh diff --git a/README.md b/README.md index a06bc32..95fec5a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # actions + GitHub Actions for Home Assistant workflows ## JQ @@ -11,3 +12,30 @@ GitHub Actions for Home Assistant workflows - `home-assistant/actions/py37-tox@master` - `home-assistant/actions/py36-tox@master` - `home-assistant/actions/py35-tox@master` + +## hassfest + +_Run hassfest to validate standalone integration repositories._ + +**action**: `home-assistant/actions/hassfest@master` + +example implementation: + +```yaml +name: Validate with hassfest + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * *' + +jobs: + validate: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v2" + - uses: home-assistant/actions/hassfest@master +``` + +This will run the `hassfest` action on every push and pull request to all branches, as well as every midnight. diff --git a/hassfest/Dockerfile b/hassfest/Dockerfile new file mode 100644 index 0000000..8d7ece1 --- /dev/null +++ b/hassfest/Dockerfile @@ -0,0 +1,33 @@ +FROM python:3-alpine + +COPY entrypoint.sh /entrypoint.sh + +RUN \ + apk add --no-cache \ + python3-dev \ + bash \ + git \ + gcc \ + libc-dev \ + libffi-dev \ + openssl-dev \ + \ + && rm -rf /var/cache/apk/* \ + \ + && git clone --depth 1 https://github.com/home-assistant/core.git /core \ + \ + && python3 -m pip install --no-cache-dir -e /core \ + \ + && chmod +x /entrypoint.sh + +WORKDIR "/github/workspace" +ENTRYPOINT ["/entrypoint.sh"] + +LABEL "name"="hassfest" +LABEL "maintainer"="Home Assistant " +LABEL "version"="1.0" + +LABEL "com.github.actions.name"="hassfest" +LABEL "com.github.actions.description"="Run hassfest to validate standalone integration repositories" +LABEL "com.github.actions.icon"="terminal" +LABEL "com.github.actions.color"="gray-dark" \ No newline at end of file diff --git a/hassfest/entrypoint.sh b/hassfest/entrypoint.sh new file mode 100644 index 0000000..f0666d1 --- /dev/null +++ b/hassfest/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +declare -a INTEGRATIONS + +for manifestfile in $(find $GITHUB_WORKSPACE -type f -name manifest.json); do + INTEGRATIONS+=(--integration-path) + INTEGRATIONS+=("$(dirname -- ${manifestfile})") +done + +if [ "${INTEGRATIONS}" = "" ]; then + echo "No integrations found!" + exit 1 +fi +echo "${INTEGRATIONS[@]}" +python3 -m script.hassfest --action validate "${INTEGRATIONS[@]}" \ No newline at end of file