Skip to content

Skip build test for non essentials #690 #699

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

Merged
merged 4 commits into from
Mar 11, 2025

Conversation

RayOei
Copy link
Collaborator

@RayOei RayOei commented Mar 3, 2025

Skip the build test step when no executable changes are made.
This will speed up the process when only documents and such are modified. Save on quota too.

This can be improved to more fine grained step, when so desired:

  • skip full build and test when only specific files are changed (global readme for instance)
  • skip build and test but create man pages
  • skip only test

Adresses #690

- name: "Check changes"
# TODO also include skipping build but allow docs to be processed
run: |
if git diff --exit-code --name-only origin/master . ':!.gitignore' ':!docs' ':!*.md' ':!*.txt' ':!*.yml'; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing to origin/master when on a PR will yield big diffs with older PRs.
Diff with common ancestor (see git merge-base) between PR branch and origin/master would be better IMHO. Here you can use the shortcut ...: git diff origin/master...HEAD...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I wanted to make it more fitting for different branches and parents, but forgot to actually do it 😊
More something like git diff --exit-code HEAD^ HEAD

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know Github at all. Maybe they are some variables to get the "base branch" of the PR ?

@RayOei RayOei force-pushed the gh_workflow_skip_build_#690 branch from fc1451b to 40d40cd Compare March 6, 2025 19:00
@@ -20,7 +20,7 @@ jobs:
- name: "Check changes"
# TODO also include skipping build but allow docs to be processed
run: |
if git diff --exit-code --name-only origin/master . ':!.gitignore' ':!docs' ':!*.md' ':!*.txt' ':!*.yml'; then
if git diff --exit-code --name-only HEAD^ HEAD ':!.gitignore' ':!docs' ':!*.md' ':!*.txt' ':!*.yml'; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work on PR that contains multiple commits, but it's better than nothing :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But with that one you could use a determined value for depth, instead of 0

vassilit
vassilit previously approved these changes Mar 6, 2025
@vassilit vassilit dismissed their stale review March 6, 2025 19:15

New commits breaks CoW tests
(Because the CoW tests are not idempotent and depends on the mount-point being used in tmpfs tests)

@RayOei RayOei force-pushed the gh_workflow_skip_build_#690 branch 5 times, most recently from f6c6849 to 77dac8f Compare March 6, 2025 20:08
@RayOei
Copy link
Collaborator Author

RayOei commented Mar 6, 2025

Euuh... I wasn't aware that me tinkering with Github actions on my repo automatically updated the upstream pull request. I would have expected that I would need to conscientiously update it. Not tooooo familiar with Github, tbh.
Either way: yes, I hadn't updated my latest local rebase to include your additions. I was looking for a more logical way of doing things but it seems GHA doesn't support that... alas... (more of a Jenkins person 😁 )
Anyway... please ignore the recent changes. I have moved to a new local branch to test with before I update this one.
I stopped all the running checks (I hope).

@RayOei RayOei force-pushed the gh_workflow_skip_build_#690 branch from 77dac8f to 4f956de Compare March 6, 2025 21:51
@RayOei
Copy link
Collaborator Author

RayOei commented Mar 6, 2025

This git diff --exit-code --name-only origin/$GITHUB_BASE_REF HEAD should allow for diff on any branch.

@vassilit
Copy link
Collaborator

vassilit commented Mar 6, 2025

This git diff --exit-code --name-only origin/$GITHUB_BASE_REF HEAD should allow for diff on any branch.

As long as github actions/checkout is using "origin" as the remote name ;)

- name: "Check need for testing"
# TODO also include skipping build but allow docs to be processed
run: |
if git diff --exit-code --name-only origin/$GITHUB_BASE_REF HEAD ':!.gitignore' ':!docs' ':!*.md' ':!*.txt'; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about origin/$GITHUB_BASE_REF...HEAD ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, tbh. I am accustomed to Jenkins and Bitbucket where I would get the merge result in the PR to test with. So this (the .. equivalent) should be fine. It seems GHA works differently which makes we wonder whether we should also have a check for the intended result before the actual merge is done. It seems we are only testing the branch, which I assume the coder already has tested as well, not bad to repeat but there is less value in that. Digging a bit deeper.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GHA has GITHUB_SHA apparently as the merge commit. Going the check that one.

@RayOei
Copy link
Collaborator Author

RayOei commented Mar 7, 2025

"origin" as the remote name

Yes 😇 I haven't found a variable which returns the full path. So it is a bit 🤞

@RayOei RayOei merged commit bc5e1e2 into sahib:master Mar 11, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants