-
Notifications
You must be signed in to change notification settings - Fork 212
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 dirty git tree after running CI jobs #9804
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
ef0027c
to
c58c5dc
Compare
f51b4a8
to
3411ddc
Compare
f390344
to
1d7851e
Compare
1d7851e
to
712e7d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way we can have some manual tests of this change, maybe as a PR stacked on top of this that creates a dirty file on purpose?
# Fail if `git status` reports anything other than the following: | ||
# * an untracked endo-sha.txt from above | ||
# * work tree files that have been staged without further changes | ||
# (e.g., package.json or yarn.lock) as indicated by the Y position | ||
# in "XY PATH" being a space |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure we keep this explanation (with an update) around
fi | ||
# Refs: https://github.com/orgs/community/discussions/45342 | ||
- name: Validate Git Tree in Root Directory | ||
if: inputs.path == '.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused, why do we need to condition on inputs.path
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file path can be either .
or ./agoric-sdk
, which makes it difficult to determine which composite action is being used. Previously, we could specify the path using the working-directory
parameter, but this no longer works properly because we now call a separate composite action.
Another option was to concatenate the path value with .github/actions/with-post-step
, but it does not work with the uses
keyword.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I totally missed the different uses
path. I think it's another reason to use an off-the-shelf action for this, no relative path to deal with.
@@ -0,0 +1,22 @@ | |||
// Ref: https://github.com/pyTooling/Actions/blob/main/with-post-step/main.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use an off the shelf action instead of vendoring something in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about which actions to use. After your suggestion, I checked out run-and-post-run-action, action-post-run, and pytooling actions. I ended up choosing pytooling. Thanks for the help :)
if: inputs.path == '.' | ||
uses: ./.github/actions/with-post-step | ||
with: | ||
main: echo "Checking Git tree for changes in the root directory..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to maintain a check after build and before the test runs too. No need to run the test if the tree is dirty to start with.
83f94c5
to
3dacff0
Compare
d250b2f
to
24c19b4
Compare
# - Files ending with 'junit.xml' | ||
# - The untracked file 'endo-sha.txt' | ||
# This setup ensures the Git status only flags unexpected modifications or untracked files outside these specified exceptions. | ||
changes=$(git status --porcelain | grep -vE 'junit.xml$' | grep -vE '^\?\? endo-sha.txt$') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be maximally strict, and if it is using separate grep
invocations, it might as well improve readability by avoiding regular expressions where possible:
changes=$(git status --porcelain | grep -vE 'junit.xml$' | grep -vE '^\?\? endo-sha.txt$') | |
changes=$(git status --porcelain | grep -vE '/junit\.xml$' | grep -vFx '?? endo-sha.txt') |
# Navigate to the specified directory | ||
cd $1 | ||
# Set verbose execution | ||
set -x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ensure directory visibility as well.
# Navigate to the specified directory | |
cd $1 | |
# Set verbose execution | |
set -x | |
# Set verbose execution | |
set -x | |
# Navigate to the specified directory | |
cd $1 |
# Fail if git status detects changes, ignoring: | ||
# - Files ending with 'junit.xml' | ||
# - The untracked file 'endo-sha.txt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These exceptions should be explained.
# Fail if git status detects changes, ignoring: | |
# - Files ending with 'junit.xml' | |
# - The untracked file 'endo-sha.txt' | |
# Fail if git status detects changes, ignoring: | |
# - Files ending with 'junit.xml' (cf. scripts/ci-collect-testruns.sh, invoked by ../post-test/action.yml) | |
# - The untracked file 'endo-sha.txt' (cf. ./action.yml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gibson042 Thanks a lot for these handy suggestions. I've made the changes. :)
24c19b4
to
e924275
Compare
@mhofman, we have some failing jobs: https://github.com/Agoric/agoric-sdk/actions/runs/10198519556/job/28213610832?pr=9804 Should we ignore these files by adding a regex for them? |
I think it means you've uncovered some case where we have some missing entries in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failing tests likely indicate we're missing some git ignore entries, and I think it should be the likely fix.
I think junit.xml
should also be ignore instead of excluded from the check. I think we made an exception for endo-sha.txt
, but I don't remember the exact reason. Possibly because it is staged for some of the flows, but I don't know why we couldn't have forced git add in that case. Maybe @michaelfig can shed some lights.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use secure bash escaping, and verify that CI passes.
with: | ||
main: | | ||
bash ${{ inputs.path }}/.github/actions/restore-node/check-git-status.sh ${{ inputs.path }} | ||
post: | | ||
bash ${{ inputs.path }}/.github/actions/restore-node/check-git-status.sh ${{ inputs.path }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use defensive shell escaping in case somebody else copies and pastes this code.
with: | |
main: | | |
bash ${{ inputs.path }}/.github/actions/restore-node/check-git-status.sh ${{ inputs.path }} | |
post: | | |
bash ${{ inputs.path }}/.github/actions/restore-node/check-git-status.sh ${{ inputs.path }} | |
with: | |
main: | | |
bash "$SRC/.github/actions/restore-node/check-git-status.sh" "$SRC" | |
post: | | |
bash "$SRC/.github/actions/restore-node/check-git-status.sh" "$SRC" | |
env: | |
SRC: ${{ inputs.path }} |
# Set verbose execution | ||
set -x | ||
# Navigate to the specified directory | ||
cd $1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, too.
cd $1 | |
cd "$1" || exit $? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestions!
I know you suggested using |
I'm wondering if we tried simply adding I know we Even if we needed to support stash, we could do |
I'm pretty sure we didn't do that.
I only see it in our |
b46c189
to
019fb85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -15,6 +15,7 @@ upgrade-test-scripts | |||
# same for each proposal, an independent project | |||
proposals/*/.pnp.* | |||
proposals/*/.yarn/* | |||
proposals/a:upgrade-next/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this one, but if you are, I'm still willing to approve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still in the process of understanding this, as it appears to be intermittent. Sometimes artifacts are generated when the associated workflow runs, and other times they are not.
019fb85
to
6c0f6cf
Compare
@@ -15,6 +15,7 @@ upgrade-test-scripts | |||
# same for each proposal, an independent project | |||
proposals/*/.pnp.* | |||
proposals/*/.yarn/* | |||
proposals/a:upgrade-next/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's definitely too broad. Please revert and use a targeted ignore file inside the proposals/a:upgrade-next
folder
You should only have to ignore the generated files.
refs: #5140