diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb269e0..acbff0f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,19 +27,19 @@ jobs: python3-requests python3-semantic_version python3-specfile - task: lint + task: PATH=${PATH}:/github/home/.local/bin make -f Makefile lint - dependencies: > black python3-isort shfmt - task: fmt-travis + task: make -f Makefile fmt-travis - dependencies: > yamllint - task: yamllint + task: make -f Makefile yamllint - dependencies: > findutils ShellCheck - task: shellcheck + task: make -f Makefile shellcheck runs-on: ubuntu-latest container: fedora:41 # CURRENT DEVELOPMENT ENVIRONMENT steps: @@ -48,6 +48,9 @@ jobs: run: > dnf install -y make + pip ${{ matrix.dependencies }} + - name: Install pyright + run: pip install --user pyright - name: Run test - run: make -f Makefile ${{ matrix.task }} + run: ${{ matrix.task }} diff --git a/Makefile b/Makefile index 210b30f..41a99ce 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ lint: pylint ./dependency_management/* --disable=R0801 pylint ./misc_scripts/*.py --disable=R0801 pylint ./release_management/*.py --disable=R0801 + pyright .PHONY: fmt fmt: diff --git a/misc_scripts/batch_cancel.py b/misc_scripts/batch_cancel.py deleted file mode 100755 index 147d246..0000000 --- a/misc_scripts/batch_cancel.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python3 -""" -Script for batch cancelling Github Actions CI jobs. -""" - -# isort: STDLIB -import itertools -import os -import sys -from getpass import getpass - -# isort: THIRDPARTY -from github import Github - - -def main(): - """ - Main function - """ - if len(sys.argv) < 4: - print(f"USAGE: {sys.argv[0]} ") - print( - "GITHUB_ORG_OR_USER: Github user or organization in which the repo is located" - ) - print("GITHUB_REPO: Name of the Github repo") - print("PR_USER: Name of the user who opened the PR") - raise RuntimeError("Three positional arguments are required") - user = sys.argv[1] - repo = sys.argv[2] - actions_user = sys.argv[3] - - api_key = os.environ.get("GITHUB_API_KEY") - if api_key is None: - api_key = getpass("Github API key: ") - - github = Github(api_key) - repo = github.get_repo(f"{user}/{repo}") - runs = itertools.chain( - repo.get_workflow_runs(actor=actions_user, status="queued"), - repo.get_workflow_runs(actor=actions_user, status="in_progress"), - ) - for run in runs: - run.cancel() - - -if __name__ == "__main__": - try: - main() - except Exception as err: # pylint: disable=broad-except - print(err) - sys.exit(1) diff --git a/misc_scripts/thin_metadata_size_viz.py b/misc_scripts/thin_metadata_size_viz.py index 475b338..c406a58 100755 --- a/misc_scripts/thin_metadata_size_viz.py +++ b/misc_scripts/thin_metadata_size_viz.py @@ -51,7 +51,7 @@ def gen_parser(): return parser -def build_arrays(block_size, values): +def build_arrays(block_size, values): # pylint: disable=too-many-locals """ Build three matrices of values where the z_values are the result of running thin_metadata_size on the x and y values. @@ -73,8 +73,20 @@ def build_arrays(block_size, values): f"--max-thins={num_thins}", "-n", ] - with subprocess.Popen(command, stdout=subprocess.PIPE) as proc: - result = int(proc.stdout.readline().decode("utf-8").strip()) + with subprocess.Popen( + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) as proc: + try: + result = int( + proc.stdout.readline() # pyright: ignore [ reportOptionalMemberAccess ] + .decode("utf-8") + .strip() + ) + except ValueError as err: + error_message = ( + proc.stderr.readline() # pyright: ignore [ reportOptionalMemberAccess ] + ) + raise RuntimeError(error_message.decode("utf-8")) from err x_row.append(pool_size) y_row.append(num_thins) z_row.append(result) @@ -100,7 +112,9 @@ def plot_figure(x_inputs, y_inputs, z_inputs): ylabel="Number of thin devices", zlabel="Metadata size", ) - axes.plot_wireframe(x_inputs, y_inputs, z_inputs) + axes.plot_wireframe( # pyright: ignore [ reportAttributeAccessIssue ] + x_inputs, y_inputs, z_inputs + ) return fig diff --git a/release_management/_utils.py b/release_management/_utils.py index cd3b9d3..950c129 100755 --- a/release_management/_utils.py +++ b/release_management/_utils.py @@ -60,7 +60,11 @@ def calc_release_suffix(): """ command = ["git", "rev-parse", "--short=8", "HEAD"] with subprocess.Popen(command, stdout=subprocess.PIPE) as proc: - commit_hash = proc.stdout.readline().strip().decode("utf-8") + commit_hash = ( + proc.stdout.readline() # pyright: ignore [ reportOptionalMemberAccess ] + .strip() + .decode("utf-8") + ) return f"{datetime.today():%Y%m%d%H%M}git{commit_hash}" @@ -95,15 +99,28 @@ def get_python_package_info(name): """ command = ["python3", "setup.py", "--name"] with subprocess.Popen(command, stdout=subprocess.PIPE) as proc: - assert proc.stdout.readline().strip().decode("utf-8") == name + assert ( + proc.stdout.readline() # pyright: ignore [ reportOptionalMemberAccess ] + .strip() + .decode("utf-8") + == name + ) command = ["python3", "setup.py", "--version"] with subprocess.Popen(command, stdout=subprocess.PIPE) as proc: - release_version = proc.stdout.readline().strip().decode("utf-8") + release_version = ( + proc.stdout.readline() # pyright: ignore [ reportOptionalMemberAccess ] + .strip() + .decode("utf-8") + ) command = ["python3", "setup.py", "--url"] with subprocess.Popen(command, stdout=subprocess.PIPE) as proc: - github_url = proc.stdout.readline().strip().decode("utf-8") + github_url = ( + proc.stdout.readline() # pyright: ignore [ reportOptionalMemberAccess ] + .strip() + .decode("utf-8") + ) github_repo = urlparse(github_url) assert github_repo.netloc == "github.com", "specified repo is not on GitHub" @@ -144,7 +161,9 @@ def verify_tag(tag): """ command = ["git", "tag", "--points-at"] with subprocess.Popen(command, stdout=subprocess.PIPE) as proc: - tag_str = proc.stdout.readline() + tag_str = ( + proc.stdout.readline() # pyright: ignore [ reportOptionalMemberAccess ] + ) return tag_str.decode("utf-8").rstrip() == tag @@ -171,7 +190,9 @@ def get_branch(): """ command = ["git", "branch", "--show-current"] with subprocess.Popen(command, stdout=subprocess.PIPE) as proc: - branch_str = proc.stdout.readline() + branch_str = ( + proc.stdout.readline() # pyright: ignore [ reportOptionalMemberAccess ] + ) return branch_str.decode("utf-8").rstrip()