-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1443c13
commit 37f177c
Showing
5 changed files
with
98 additions
and
35 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,23 @@ | ||
name: Check changes | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.7 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install jsonschema | ||
- name: Check changes | ||
run: | | ||
./test-pr.py |
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,23 @@ | ||
name: Check full list | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.7 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install jsonschema | ||
- name: Check full list | ||
run: | | ||
./tools/check-list.py |
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import os | ||
import re | ||
import shlex | ||
import sys | ||
import urllib.request | ||
|
||
|
||
def main(): | ||
with open(os.environ['GITHUB_EVENT_PATH']) as f: | ||
event = json.load(f) | ||
|
||
url = 'https://api.github.com/repos/{}/pulls/{}/files'.format( | ||
os.environ['GITHUB_REPOSITORY'], | ||
event['pull_request']['number'], | ||
) | ||
|
||
r = urllib.request.Request(url, headers={'Accept': 'application/json'}) | ||
f = urllib.request.urlopen(r) | ||
files = json.load(f) | ||
files = [x['filename'] for x in files] | ||
|
||
addons_changed = [] | ||
schema_changed = False | ||
checker_changed = False | ||
for fname in files: | ||
match = re.match(r'^addons/([^/]+)\.json$', fname) | ||
if match: | ||
addons_changed.append(match.group(1)) | ||
elif re.match(r'^schema/.+$', fname): | ||
schema_changed = True | ||
elif fname == 'tools/check-list.py': | ||
checker_changed = True | ||
|
||
if schema_changed or checker_changed: | ||
return os.system('./tools/check-list.py') | ||
|
||
if len(addons_changed) > 0: | ||
return os.system('./tools/check-list.py {}'.format( | ||
' '.join([shlex.quote(a) for a in addons_changed])) | ||
) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
# Sometimes, check-list.py returns 256. Apparently, sys.exit() will only | ||
# accept 0-255, so we have to adjust. Weird. | ||
if main() > 0: | ||
sys.exit(1) |