-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check commits outside pr #122
Comments
I am not sure what this is about, more details might be needed. |
There are two commits in the log:
While this pr only contains one. @fkirc |
Love the action! I'm experiencing the same problem with commits being referenced outside of the scope of commits of my PR. My PR against Commit lineage: abc123 <- Commit in my PR I have an action configured to run on on a name: My Action
on:
pull_request:
branches:
- develop
workflow_dispatch:
jobs:
skip_check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
paths: '["path/to/my/files/**"]'
cancel_others: 'true' # Cancel in progress run if new matching commit pushed after PR opened
my-job:
name: Some Job Name
needs: skip_check
if: ${{ needs.skip_check.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- name: Do Something
run: |
echo "Doing something" |
I think it might have something to do with the async function backtracePathSkipping(context: WRunContext) {
let commit: ReposGetCommitResponseData | null;
let iterSha: string | null = context.currentRun.commitHash;
let distanceToHEAD = 0;
do {
commit = await fetchCommitDetails(iterSha, context);
if (!commit) {
return;
}
exitIfCommitOutOfScope(commit, context); // <- Proposed new check
exitIfSuccessfulRunExists(commit, context);
if (distanceToHEAD++ >= 50) {
// Should be never reached in practice; we expect that this loop aborts after 1-3 iterations.
core.warning(`Aborted commit-backtracing due to bad performance - Did you push an excessive number of ignored-path-commits?`);
return;
}
iterSha = commit.parents?.length ? commit.parents[0]?.sha : null;
} while (isCommitSkippable(commit, context));
}
/** Exit with shouldSkip:true if the commit is out of the scope of the PR or branch */
function exitIfCommitOutOfScope(commit: ReposGetCommitResponseData, context: WRunContext) {
const outOfScope = null; // TODO: Check commit within the list of commits within the PR or branch
if (outOfScope) {
core.info(`Skip execution because all changes within branch are in ignored or skipped paths`);
exitSuccess({ shouldSkip: true });
}
}
function exitIfSuccessfulRunExists(commit: ReposGetCommitResponseData, context: WRunContext) {
const treeHash = commit.commit.tree.sha;
const matchingRuns = context.olderRuns.filter((run) => run.treeHash === treeHash);
const successfulRun = matchingRuns.find((run) => {
return run.status === 'completed' && run.conclusion === 'success';
});
if (successfulRun) {
core.info(`Skip execution because all changes since ${successfulRun.html_url} are in ignored or skipped paths`);
exitSuccess({ shouldSkip: true });
}
} |
Thanks for the detailed description. If this is what you want, then I believe that the entire backtracking-logic might be unnecessary since it might be easier to look at the PR-diffs (the same PR-diff that you use during manual code-review of PRs). |
Yes, that sounds like the use-case I was after! Something like a quality gate before code is allowed to be merge to trunk |
Alright, I think that I now understand it fully. Nevertheless, I would be willing to merge a PR that implements this behavior for "pull_request"-triggers. |
The proof-chain sounds like a good idea and is probably a better solution than what I was proposing...I feel like I might have been experiencing unexpected scope because it was the first run, but I suspect follow-up runs will sort themselves out. I will keep you posted! |
If someone is still interested in such a feature, please consider funding it. |
See https://github.com/dapr/cli/runs/2970646884?check_suite_focus=true
/cc @fkirc
The text was updated successfully, but these errors were encountered: