Skip to content

Commit

Permalink
chore: fix ci to always compare changes against the target branch (#18)
Browse files Browse the repository at this point in the history
* chore: fix ci to always compare changes against the target branch
  • Loading branch information
alon-dotan-starkware authored Jul 16, 2024
1 parent 1c65e83 commit 6b8f0db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ jobs:
- env:
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
- run: |
- name: "Run tests"
run: |
python3 -m venv ci
ci/bin/pip install -r scripts/requirements.txt
ci/bin/python scripts/run_tests.py --changes_only
ci/bin/python scripts/run_tests.py --changes_only --features concurrency
ci/bin/python scripts/run_tests.py --changes_only --commit_id ${{ github.base_ref }}
ci/bin/python scripts/run_tests.py --changes_only --features concurrency --commit_id ${{ github.base_ref }}
# Keep the name 'udeps' to match original action name, so we don't need to define specific branch
# rules on Github for specific version branches.
Expand Down
12 changes: 8 additions & 4 deletions scripts/run_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/env python3

import argparse
from calendar import c
import re
import subprocess
import os
Expand All @@ -23,7 +24,7 @@ def get_workspace_tree() -> Dict[str, str]:
return tree


def get_local_changes(repo_path) -> List[str]:
def get_local_changes(repo_path, commit_id: Optional[str]) -> List[str]:
os.environ["GIT_PYTHON_REFRESH"] = "quiet" # noqa
repo = Repo(repo_path)
try:
Expand Down Expand Up @@ -60,8 +61,8 @@ def get_package_dependencies(package_name: str) -> Set[str]:
return deps


def run_test(changes_only: bool, features: Optional[str] = None):
local_changes = get_local_changes(".")
def run_test(changes_only: bool, commit_id: Optional[str], features: Optional[str] = None):
local_changes = get_local_changes(".", commit_id=commit_id)
modified_packages = get_modified_packages(local_changes)
args = []
if changes_only:
Expand Down Expand Up @@ -89,12 +90,15 @@ def parse_args() -> argparse.Namespace:
parser.add_argument(
"--features", type=str, help="Which services to deploy. For multi services separate by ','."
)
parser.add_argument(
"--commit_id", type=str, help="GIT commit ID to compare against."
)
return parser.parse_args()


def main():
args = parse_args()
run_test(changes_only=args.changes_only, features=args.features)
run_test(changes_only=args.changes_only, commit_id=args.commit_id, features=args.features)


if __name__ == "__main__":
Expand Down

0 comments on commit 6b8f0db

Please sign in to comment.