-
Notifications
You must be signed in to change notification settings - Fork 254
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
atlas fmt check only #2785
Comments
Also, is there an easy way to check formatting (and validity) on the Atlas config (e.g., |
One thing that does work is % atlas schema apply --dry-run --to file://foo.hcl --url "docker://postgres/15/dev?search_path=public" If that succeeds the config should be valid, and if not, it will fail with an error. However, it would nice to be able to catch completely invalid HCL further left schema "public" {
comment = "standard public schema"
}
table "foo" {
schema = schema.doesnotexist
column "bar" {
null = asdfasdf
type = character_varying(60)
} It seems it should be possible for |
Side note, in case it's helpful to anyone; here's how I implemented this in GitHub actions for now, since there is no such command: jobs:
atlas:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ariga/setup-atlas@v0
# Work around lack of a -check flag or similar for "atlas schema fmt"
# https://dev.to/mbjelac/github-action-output-to-if-expression-and-how-to-test-it-531i
- name: Check that schemas are formatted correctly via atlas schema fmt
run: echo "modified=$(atlas schema fmt)" >> $GITHUB_OUTPUT
id: fmt
- name: Fail if schema is not formatted via atlas schema fmt
if: steps.fmt.outputs.modified != null
run: |
echo "Unformatted files modified: ${{ steps.fmt.outputs.modified }}" >&2
echo "Use atlas schema fmt to fix this." >&2
exit 1 |
For, e.g.,
atlas schema fmt
, currently, it seems to exit 0 whether files are modified or not:Would it be possible to either exit non-0 when files are modified, or have a
--check
flag, similar to Terraform's-check
flag, that just checks whether files would be modified and exits non-0 if they would be?While it's certainly possible to see if there is output or not, it would be nice to be able to have a simple way to check if formatting is needed (for example, in CI checks)
The text was updated successfully, but these errors were encountered: