Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ jobs:
fi
working-directory: ./cmd/river

- name: river unknown command (expect failure)
run: |
if ./river not-a-command; then
echo "expected non-zero exit code" && exit 1
fi
working-directory: ./cmd/river

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tested locally as well:

$ go run . migrate-up
Error: required flag(s) "database-url" not set
Usage:
  river migrate-up [flags]

Flags:
      --database-url postgres://...   URL of the database to migrate (should look like postgres://...
      --dry-run                       print information on migrations, but don't apply them
  -h, --help                          help for migrate-up
      --max-steps int                 maximum number of steps to migrate
      --show-sql                      show SQL of each migration
      --target-version int            target version to migrate to (final state includes this version, but none after it)

Global Flags:
      --debug     output maximum logging verbosity (debug level)
  -v, --verbose   output additional logging verbosity (info level)

exit status 1

$ echo $?
1


golangci:
name: lint
runs-on: ubuntu-latest
Expand Down
10 changes: 6 additions & 4 deletions cmd/river/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,12 @@ migrations that need to be run, but without running them.
rootCmd.AddCommand(cmd)
}

// Cobra will already print an error on an uknown command, and there aren't
// really any other important top-level error cases to worry about as far as
// I can tell, so ignore a returned error here so we don't double print it.
_ = rootCmd.Execute()
if err := rootCmd.Execute(); err != nil {
// Cobra will already print an error on problems like an unknown command
// or missing required flag. Set an exit status of 1 on error, but don't
// print it again.
os.Exit(1)
}
}

func openDBPool(ctx context.Context, databaseURL string) (*pgxpool.Pool, error) {
Expand Down