-
Notifications
You must be signed in to change notification settings - Fork 881
ci: fix test-migrations target when main branch is not present locally #13306
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
Conversation
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.
Additionally, git rev-parse produces a slightly cryptic error message when the ref specified does not exit.
I didn't notice any significant difference between the commands. 🤔
@@ -797,8 +797,11 @@ test-postgres: test-postgres-docker | |||
test-migrations: test-postgres-docker | |||
echo "--- test migrations" | |||
set -euo pipefail | |||
COMMIT_FROM=$(shell git rev-parse --short HEAD) | |||
COMMIT_TO=$(shell git rev-parse --short main) | |||
COMMIT_FROM=$(shell git log -1 --format='%h' HEAD) |
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.
Why short-form, btw? I guess it's more human friendly, but the long-form is more robust.
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 was initially worried about exceeding the maximum name length of a database name, but it looks like we're under the 63 byte limit even with the long identifier.
COMMIT_FROM=$(shell git rev-parse --short HEAD) | ||
COMMIT_TO=$(shell git rev-parse --short main) | ||
COMMIT_FROM=$(shell git log -1 --format='%h' HEAD) | ||
echo "COMMIT_FROM=$${COMMIT_FROM}" |
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.
Pro-tip: declare
is pretty nice (declare -p COMMIT_FROM COMMIT_TO
. Not necessarily for here, but future reference.
I think it's way clearer:
I suppose we could also just read |
https://github.com/coder/coder/actions/runs/8989166240/job/24691648877 appears to have failed because the local reference to
main
was not present. Additionally,git rev-parse
produces a slightly cryptic error message when the ref specified does not exit.To validate this, I deleted the
main
branch locally and observed the same error before the change. After the change, this works as intended.