Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start adding linter #8

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
27 changes: 27 additions & 0 deletions .github/scripts/lint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import sys
import yaml
import requests


KEY_SET = set(['owner', 'name', 'branch', 'docs'])


def lint(yml):
# Assert corrrect keys
assert set(yml.keys()) == KEY_SET

# Get the docs URL assert 200
response = requests.get(yml['docs'])
assert response.status_code == 200

# Put together the owner/name:branch
# ...Do something with it


if __name__ == "__main__":
files = sys.argv[1:]

for file in files:
with open(file, 'r') as fh:
yml = yaml.safe_load(fh)
lint(yml)
43 changes: 43 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: lint-pr

# Run on PR
on:
# Possible to only run on PR that modifies plugins?
pull_request:
# branches:
# - 'main'
# paths:
# - '/plugins/**'

# Checkout
jobs:
lint:
permissions:
contents: read

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

# Get new/changed files?
# Not positive this works yet
- name: Added Files
run: echo "DIFF=`git diff --name-only --diff-filter=A HEAD~ HEAD`" >> $GITHUB_ENV

# Lint all added files
- name: Lint
run: python .github/scripts/lint.py $DIFF


# Lint all files in plugins
# If anything outside of plugins is changed then fail?

# Grab the target repo and validate it?
# Description?
# README?
# Env files?

Loading