Skip to content

Commit 8bf1e98

Browse files
authored
ci,fix: Resolve crash when running samples in PR from fork (#189)
* fix: Forward --changed-samples-only-from argument to diff function * fix: Use SHA instead of a ref * fix: Check out base ref in addition to target * ci: Specify that only changed samples are run
1 parent 44e474c commit 8bf1e98

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

.github/workflows/run-samples.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
# Require manual approval if initiator is not a public member of Azure-Samples
6060
environment: ${{ needs.check-if-external.outputs.environment }}
6161
steps:
62+
- uses: actions/checkout@v4
6263
- uses: actions/checkout@v4
6364
with:
6465
ref: ${{ github.event.pull_request.head.sha || github.ref }}
@@ -81,6 +82,6 @@ jobs:
8182
--parameters principalType=ServicePrincipal \
8283
--parameters principalId="$principalId" \
8384
-o json > deployment.json
84-
- name: Run samples
85+
- name: Run Changed Samples
8586
run:
86-
pytest --changed-samples-only-from ${{ github.base_ref }}
87+
pytest --changed-samples-only-from ${{ github.event.pull_request.base.sha }}

.infra/pytest_plugins/changed_samples/src/pytest_changed_samples/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def get_diff_paths_function(config: pytest.Config) -> Callable[[], Iterable[Path
8484
"""
8585
if config.getoption(opt_var(WORKING_TREE_CHANGES_OPTION)):
8686
return get_all_modified_paths
87-
if config.getoption(opt_var(PR_CHANGES_OPTION)):
88-
return get_branch_diff_paths
87+
if ref := config.getoption(opt_var(PR_CHANGES_OPTION)):
88+
return lambda: get_branch_diff_paths(ref)
8989

9090
return lambda: ()
9191

0 commit comments

Comments
 (0)