Skip to content

Commit

Permalink
Rudimentary CI (just formatting checks for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm committed Sep 29, 2023
1 parent db71667 commit 2503bc7
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI
on: [push]
env:
PYTHON_VER: python3.9 # 3.9 is default on Amazon Linux 2023

jobs:
Lint-Python:
runs-on: ubuntu-22.04 # latest at time of writing
steps:
- name: Checkout Sources
uses: actions/checkout@v4

- name: Lint
run: $PYTHON_VER -m pip install -r scripts/requirements.txt
run: $PYTHON_VER -m scripts/lint-python.py
4 changes: 2 additions & 2 deletions runners/s3-benchrunner-crt-java/scripts/install-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ def run(cmd_args: list[str]):
run(['sudo', 'dnf', 'install', '-y',
'git',
'maven',
'cmake', # for building aws-crt-java
'gcc', # for building aws-crt-java
'cmake', # for building aws-crt-java
'gcc', # for building aws-crt-java
])
53 changes: 53 additions & 0 deletions scripts/lint-python.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
import argparse
from pathlib import Path
import subprocess
import sys

PARSER = argparse.ArgumentParser(
description="Check formatting and type hints in python scripts")


def run(cmd_args: list[str]):
print(f'> {subprocess.list2cmdline(cmd_args)}')
result = subprocess.run(cmd_args)
if result.returncode != 0:
exit('FAILED')


def get_script_dirs() -> list[str]:
dirs = []
root = Path(__file__).parent.parent

# add this scripts/ dir
dirs.append(root.joinpath('scripts'))

# add each runner's scripts/ dir
for runner_child in root.joinpath('runners').iterdir():
if runner_child.is_dir():
runner_scripts = runner_child.joinpath('scripts')
if runner_scripts.is_dir():
dirs.append(runner_scripts)

return [str(i) for i in dirs]


def check_formatting(dirs: list[str]):
cmd_args = [sys.executable, '-m', 'autopep8',
'--recursive', '--diff', '--exit-code']
cmd_args.extend(dirs)
run(cmd_args)


def check_typing(dirs: list[str]):
# run mypy on each script dir separately,
# so it doesn't complain about there being multiple build.py files
for dir in dirs:
run([sys.executable, '-m', 'mypy', dir])


if __name__ == '__main__':
args = PARSER.parse_args()
script_dirs = get_script_dirs()
check_formatting(script_dirs)
check_typing(script_dirs)
4 changes: 2 additions & 2 deletions scripts/prep-benchmark-files.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import argparse
import botocore
import boto3
import botocore # type: ignore
import boto3 # type: ignore
import concurrent.futures
from dataclasses import dataclass
import io
Expand Down
1 change: 1 addition & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
boto3
autopep8 # for code formatting
mypy # for type checking

0 comments on commit 2503bc7

Please sign in to comment.