Skip to content

Commit

Permalink
chore: fix run tests script
Browse files Browse the repository at this point in the history
  • Loading branch information
alon-dotan-starkware committed Jul 19, 2024
1 parent 2ee497d commit 4947510
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,19 @@ jobs:
- run: scripts/clippy.sh

run-tests:
if: github.event_name == 'pull_request'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
# We need to handle 2 cases,
# One is PR (all changes squashed into one merge commit, so the diff will be HEAD..HEAD^1),
# and the other is a push (all changes in the branch,
# so the diff will be HEAD..'last commit on the parent branch',
# since each push can include several commits).
# in a pull request, we need 2 commits, the commit the pr born from on the target branch, and the merge one,
# in pull we need the entire history.
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- uses: dtolnay/rust-toolchain@stable
- uses: Noelware/setup-protoc@1.1.0
- uses: Swatinem/rust-cache@v2
Expand All @@ -96,12 +106,26 @@ jobs:
- env:
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
- name: "Run tests"
- name: "Run tests pull request"
# See comments above.
if: github.event_name == 'pull_request'
run: |
python3 -m venv ci
ci/bin/pip install -r scripts/requirements.txt
ci/bin/python scripts/run_tests.py --changes_only --commit_id HEAD^1
ci/bin/python scripts/run_tests.py --changes_only --features concurrency --commit_id HEAD^1
env:
SEED: 0

- name: "Run tests on push"
# See comments above.
if: github.event_name == 'push'
# TODO: Better support for running tests on push.
run: |
python3 -m venv ci
ci/bin/pip install -r scripts/requirements.txt
ci/bin/python scripts/run_tests.py --changes_only --commit_id ${{ github.event.pull_request.base.sha }}
ci/bin/python scripts/run_tests.py --changes_only --features concurrency --commit_id ${{ github.event.pull_request.base.sha }}
ci/bin/python scripts/run_tests.py
ci/bin/python scripts/run_tests.py --features concurrency
env:
SEED: 0

Expand Down
2 changes: 1 addition & 1 deletion scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_local_changes(repo_path, commit_id: Optional[str]) -> List[str]:
print(f"unable to validate {repo_path} as a git repo.")
raise

return [c.a_path for c in repo.head.commit.diff(None)]
return [c.a_path for c in repo.head.commit.diff(commit_id)]


def get_modified_packages(files: List[str]) -> Set[str]:
Expand Down

0 comments on commit 4947510

Please sign in to comment.