Skip to content

Commit b747d83

Browse files
committed
Initial implementation of util script & tests
1 parent 459521f commit b747d83

36 files changed

+395
-1
lines changed

.github/workflows/main.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
run-checks:
11+
strategy:
12+
matrix:
13+
python-version: ['3.8', '3.9', '3.10', '3.11']
14+
test-os: [ubuntu-latest]
15+
16+
runs-on: ${{ matrix.test-os }}
17+
defaults:
18+
run:
19+
shell: bash
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Check dependency-free runtime
25+
run: |
26+
base=$PWD
27+
cd $(mktemp --directory)
28+
echo foo > foo.out
29+
python3 $base/validate-generated-files.py --files foo.out -- bash -c 'echo foo > foo.out'
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
cache: pip
36+
cache-dependency-path: '**/requirements.txt'
37+
38+
- name: Install test dependencies
39+
run: pip install -r script/requirements-dev.txt
40+
41+
- name: Lint
42+
run: ./script/linting/lint
43+
44+
- name: Typecheck
45+
run: ./script/typing/check
46+
47+
- name: Test
48+
run: ./run-tests

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
# validate-generated-files
2-
Action to validate generated files stored in a repository
2+
3+
A GitHub Action to validate generated files stored in a repository.
4+
5+
This is typically useful in contexts where, for one reason or another, generated
6+
files are stored in a version control repository alongside their inputs.
7+
8+
This Action is implemented in Python 3, which must be available within the
9+
runner environment.

run-tests

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
python3 $(dirname $0)/tests.py "$@"

script/check

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
cd $(dirname $0)/..
4+
5+
./run-tests
6+
result=$?
7+
8+
./script/linting/lint
9+
result=$((result | $?))
10+
11+
./script/typing/check
12+
result=$((result | $?))
13+
14+
exit $result

script/linting/lint

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
if [ -z "$FLAKE8" ]; then
3+
FLAKE8=flake8
4+
fi
5+
exec "$FLAKE8" validate-generated-files.py tests.py "$@"

script/linting/requirements.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Need 3.8 for fixes around typing comments
2+
flake8>=3.8
3+
flake8-bugbear
4+
flake8-builtins
5+
flake8-commas
6+
flake8-comprehensions
7+
flake8-debugger
8+
flake8-fixme
9+
flake8-isort
10+
flake8-noqa
11+
flake8-tuple
12+
13+
isort
14+
15+
# flake8-commas has an implicit dependency on pkg_resources
16+
setuptools

script/requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-r linting/requirements.txt
2+
-r typing/requirements.txt

script/typing/check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
if [ -z "$MYPY" ]; then
3+
MYPY=mypy
4+
fi
5+
exec "$MYPY" validate-generated-files.py tests.py

script/typing/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Version for enable_error_code = ignore-without-code
2+
mypy>=0.940

setup.cfg

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
[flake8]
2+
exclude =
3+
.eggs,
4+
.git,
5+
.pybuild,
6+
__pycache__,
7+
build,
8+
script
9+
ignore =
10+
# Don't require set comprehensions
11+
C401
12+
# W503 and W504 conflict; ignore the one that disagrees with recent PEP8.
13+
W503
14+
15+
# try to keep it below 85, but this allows us to push it a bit when needed.
16+
max_line_length = 95
17+
18+
noqa-require-code = true
19+
20+
21+
[isort]
22+
atomic = True
23+
balanced_wrapping = True
24+
combine_as_imports = True
25+
include_trailing_comma = True
26+
length_sort = True
27+
multi_line_output = 3
28+
order_by_type = False
29+
30+
default_section = THIRDPARTY
31+
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
32+
33+
34+
[mypy]
35+
strict = True
36+
37+
disallow_any_explicit = True
38+
disallow_any_generics = True
39+
disallow_subclassing_any = True
40+
41+
disallow_untyped_defs = True
42+
check_untyped_defs = True
43+
disallow_untyped_decorators = True
44+
45+
no_implicit_optional = True
46+
strict_optional = True
47+
48+
warn_redundant_casts = True
49+
warn_unused_ignores = True
50+
warn_return_any = True
51+
warn_unreachable = True
52+
53+
implicit_reexport = False
54+
strict_equality = True
55+
56+
scripts_are_modules = True
57+
warn_unused_configs = True
58+
59+
show_error_codes = True
60+
enable_error_code = ignore-without-code

0 commit comments

Comments
 (0)