From df56f309192e6e91fd1a41b6a331fa1630854b75 Mon Sep 17 00:00:00 2001 From: "Matheus T. dos Santos" Date: Fri, 30 Aug 2024 20:49:35 -0300 Subject: [PATCH] ci: remove commit check CI's action Signed-off-by: Matheus T. dos Santos --- .github/commit_checks.py | 76 ----------------------------- .github/workflows/commit-checks.yml | 20 -------- 2 files changed, 96 deletions(-) delete mode 100644 .github/commit_checks.py delete mode 100644 .github/workflows/commit-checks.yml diff --git a/.github/commit_checks.py b/.github/commit_checks.py deleted file mode 100644 index 5e89dae..0000000 --- a/.github/commit_checks.py +++ /dev/null @@ -1,76 +0,0 @@ -""" - :file: commit_checks.py - :author: Paulo Santos (pauloroberto.santos@edge.ufal.br) - :brief: Realiza a verificação do histórico de commits. - :version: 0.1 - :date: 29-04-2024 - - :copyright: Copyright (c) 2024 -""" - -import argparse -import subprocess -import sys - - -def main() -> int: - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("-s", "--srcb", metavar="sbranch", help="Source branch to compare.") - parser.add_argument("-t", "--tgtb", metavar="tbranch", help="Target branch to compare.", - default="origin/main") - - source_branch = str(parser.parse_args().srcb) - target_branch = str(parser.parse_args().tgtb) - - if source_branch == "None": - print("\nSource branch is empty.") - return -1 - - invocation = f"git rev-list --count --left-right {target_branch}...{source_branch}" - - try: - out = subprocess.check_output(invocation, shell=True) - behind, ahead = [int(dist) for dist in out.decode("utf-8").rsplit("\t", maxsplit=1)] - except Exception as e: - print(f"\nError to check the history: {e}") - return -1 - - if behind > 0: - print(f"\nThere are {behind} commits to be included in PR using rebase to main.\n") - - return 1 - - if ahead > COMMIT_LIMIT: - print(f"\nThere are {ahead} commits to be added, divide PR to have less than {COMMIT_LIMIT + 1} commits.") - - return 1 - - print(f"\nHistory is updated. ({ahead} commits ahead)") - - invocation = f"git describe --all --first-parent {source_branch}~1 --abbrev=0" - - try: - out = subprocess.check_output(invocation, shell=True) - parent_head = out.decode("utf-8").split("/")[-1].strip() - except Exception as e: - print(f"\nError to check the history: {e}") - - return -1 - - if parent_head != "main": - print( - f"\nThe branch has its origin on `{parent_head}`, resolve `{parent_head}` first. (the branch must have " - f"origin on main)") - - return 1 - - print("\nThe branch has its origin on main.") - - return 0 - - -if __name__ == "__main__": - COMMIT_LIMIT = 15 - check_status = main() - - sys.exit(check_status) diff --git a/.github/workflows/commit-checks.yml b/.github/workflows/commit-checks.yml deleted file mode 100644 index 63345e0..0000000 --- a/.github/workflows/commit-checks.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: commit-checks - -on: - pull_request: - branches: [ "main" ] - -jobs: - commit-check: - name: Check the branch base commit - runs-on: ubuntu-latest - steps: - - name: Checkout para a branch a ser testada. - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - - - name: Verifica os commits temporal e posicionalmente. - run: | - python .github/commit_checks.py -s origin/"${{github.head_ref}}"