Code Monkey home page Code Monkey logo

action-addon-linter's Introduction

๐Ÿš€ Frenck's Github Action: Home Assistant Add-on Linter

GitHub Release Project Stage Project Maintenance License

Sponsor Frenck via GitHub Sponsors

๐Ÿš€ Frenck's GitHub Action for linting Home Assistant Add-ons.

About

This GitHub Action is able to validate/lint Home Assistant Add-on configuration files.

Besides checking for validity of add-on configuration files, it will also warn for default configurations that can be removed and cleaned up.

Usage

name: Lint
on: [push, pull_request]
jobs:
  build:
    name: Add-on configuration
    runs-on: ubuntu-latest
    steps:
      - name: โคต๏ธ Check out code from GitHub
        uses: actions/checkout@v3
      - name: ๐Ÿš€ Run Home Assistant Add-on Lint
        uses: frenck/action-addon-linter@v2
        with:
          path: "./addon"

Arguments

Input Description Usage
path Path to the folder containing the add-on config.json file. Required
community Enable Home Assistant Community Add-ons mode, with specific checks. Optional

Updating the JSON Schema

For the larger part, JSON Schemas are used to validate the configuration files. The schema files for both the add-on config.json and build.json can be found in the src/ folder.

  • src/config.schema.json is used to validate config.json
  • src/build.schema.json is used to validate build.json

If you adjust the schema, please make sure they are pretty:

npx prettier --write ./src/config.schema.json

Changelog & Releases

This repository keeps a change log using GitHub's releases functionality.

Releases are based on Semantic Versioning, and use the format of MAJOR.MINOR.PATCH. In a nutshell, the version will be incremented based on the following:

  • MAJOR: Incompatible or major changes.
  • MINOR: Backwards-compatible new features and enhancements.
  • PATCH: Backwards-compatible bugfixes and package updates.

Versions & Updating

You can specify which version of this GitHub Action your workflow should use. And even allowing for using the latest major or minor version.

For example; this will use release v1.1.1 of a GitHub Action:

- name: ๐Ÿš€ Run Home Assistant Add-on Lint
  uses: frenck/[email protected]

While the following example, will use the v1.1.x minor release, for example if v1.1.2 is the latest releases (starting with v1.1), this will run v1.1.2:

- name: ๐Ÿš€ Run Home Assistant Add-on Lint
  uses: frenck/[email protected]

As in the examples throughout the documentation, the following example is locked on major version, meaning any v1.x.x latest version will be used, as long as it is version 1.

- name: ๐Ÿš€ Run Home Assistant Add-on Lint
  uses: frenck/action-addon-linter@v1

Automatically update using Dependabot

The advantage of locking against a more specific version, is that it prevents surprises if an issue or breaking changes were introduced in a newer release.

The disadvantage of being more specific, is that it requires you to keep things up to date. Fortunately, GitHub has a tool for that, called: Dependabot.

Dependabot can automatically open a pull request on your repository to update this Action for you. You can instantly see if the new version works (as the pull request shows the success or failure status) and you can decide to merge it in by hitting the merge button. Quick, easy and always up2date.

To enable Dependabot, create a file called .github/dependabot.yaml:

version: 2
updates:
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: daily

Your all set! Dependabot will now check (and update) your GitHub actions every day. ๐Ÿคฉ

Contributing

This is an active open-source project. We are always open to people who want to use the code or contribute to it.

We've set up a separate document for our contribution guidelines.

Thank you for being involved! ๐Ÿ˜

Authors & contributors

The original setup of this repository is by Franck Nijhof.

For a full list of all authors and contributors, check the contributor's page.

License

MIT License

Copyright (c) 2021-2023 Franck Nijhof

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

action-addon-linter's People

Contributors

dependabot[bot] avatar felipecrs avatar frenck avatar ludeeus avatar renovate[bot] avatar wrt54g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

action-addon-linter's Issues

Publish schema json to public url

I also have some json schema files for my pet project I publish them to github pages (with custom domain but that doesn't matter).
So my schema file is available from the internet and that means they automatically work in VSCode.

If you would clone sonos-api-docs and edit this file it does the json checking right in the editor. Because I've set the $schema in the json.

https://github.com/svrooij/sonos-api-docs/blob/d1a95207f37146f6b49cba3b5ce796f67dcd2fa8/docs/documentation.json#L1-L2

You can still use your action, which is great for checking, but this small step would allow all addon developers to use the schema files and have much less faults in their addon configuration.

Check if slug has hyphens instead of underscores (and warn if either?)

While developing an addon, I noticed that a slug with a hyphen seemed to break bashio, and reading the addon docs more carefully, an underscore needs to be converted to hyphen for intra-addon comms (as DNS). If these both are true, perhaps this linter should fail either character (or better regex the slug as all lowercase ascii or something?)

Error: 'IPC_LOCK' is not one of ...

Comparing the following two code passages, it seems action-addon-linter is incorrectly displaying an error in case an addon is specifying IPC_LOCK in the privileged section of its config.json:

"DAC_READ_SEARCH",
"NET_ADMIN",
"SYS_ADMIN",
"SYS_MODULE",
"SYS_NICE",
"SYS_PTRACE",
"SYS_RAWIO",
"SYS_RESOURCE",
"SYS_TIME"

https://github.com/home-assistant/supervisor/blob/main/supervisor/docker/const.py#L8-L17

Or do I miss something regarding IPC_LOCK here?

YAML Tab Error

Hey @frenck,

i just started to use your linter and got the following error. I don't know how to get rid of it:

yaml.scanner.ScannerError: while scanning for the next token
found character '\t' that cannot start any token
  in "diyhue/config.json", line 2, column 1

I tested it on this file:
https://github.com/MaxBec/hassio-diyHue/blob/master/diyhue/config.json

Here is the produced error output:
https://github.com/MaxBec/hassio-diyHue/runs/2225768951?check_suite_focus=true

Kind Regards,
Max

Docker image digest SHA not valid in build.json

As my addon is a little bit dirty made, I need to supply the image SHA in the build.json. Otherwise, the multi-arch builder uses the same base image for all arches.

Error: {'armhf': 'thomx/fr24feed-piaware:1.18.0@sha256:c21ad18c64a9d6d4f96706fe7504e0b762ecff01f5c71b00bff0a191c0857e14', 'armv7': 'thomx/fr24feed-piaware:1.18.0@sha256:f20d215e40f19dfad24d0f70c070fd89617f38335e82cd713b40c215e7ea2fac', 'aarch64': 'thomx/fr24feed-piaware:1.18.0@sha256:0bf6fb89e0fa983270c36fa8d953ea49b4c3d99a43ec5cc0b178bce7cd2712bc', 'amd64': 'thomx/fr24feed-piaware:1.18.0@sha256:44e5331926921285d6e33ad0bf5a51eea1fb63f2b5b52668591cece6f79bb9c4'} is not valid under any of the given schemas

Besides the ugliness of my addon, shouldn't the regex allow using images by its SHA?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

dockerfile
src/Dockerfile
  • python 3.12-alpine
github-actions
.github/workflows/additional-tags.yaml
  • actions/checkout v4.1.6
  • vweevers/additional-tags-action v2.0.0
.github/workflows/labels.yaml
  • actions/checkout v4.1.6
  • micnncim/action-label-syncer v1.3.0
.github/workflows/lint.yaml
  • actions/checkout v4.1.6
  • frenck/action-yamllint v1.5
  • actions/checkout v4.1.6
  • actions/checkout v4.1.6
  • creyD/prettier_action v4.3
.github/workflows/lock.yaml
  • dessant/lock-threads v5.0.1
.github/workflows/release-drafter.yaml
  • release-drafter/release-drafter v6.0.0
.github/workflows/stale.yaml
  • actions/stale v9.0.0
pip_requirements
src/requirements.txt
  • jsonschema ==4.22.0
  • pyyaml ==6.0.1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.