-
-
Notifications
You must be signed in to change notification settings - Fork 509
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
[no-release-notes] add dolt ci init and destroy #8517
base: main
Are you sure you want to change the base?
Conversation
00506fe
to
1ac8b47
Compare
1ac8b47
to
0157405
Compare
@coffeegoddd DOLT
|
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.
Looks good. Nothing major, but some suggestions for additional tests as well as a few things I think would help tidy up the changes or make it easier for future code readers.
I didn't think much about the specific table structure/design – I think I remember that being reviewed in a doc a while back. Let me know if you are looking for feedback on that, too, and I'm happy to spend a little time thinking about it.
run dolt sql -q "select * from dolt_ci_workflows;" | ||
[ "$status" -eq 0 ] |
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.
(minor) If you only want to test that a command exits cleanly, without an error code, you can omit the run
command just execute the dolt
command directly. If it returns an error status, then the test will fail, without you needing to explicitly test the $status
var. Not a big deal, but could help shrink down this function a lot.
} | ||
|
||
var verr errhand.VerboseError | ||
err = schema.DestroyDoltCITables(sqlCtx, db, queryist.Query, name, email) |
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 package name schema
seems a little too broad/general; when first reading it, I didn't know it was specific to dolt CI. This is likely to be confusing for future code readers since we already have widely used schema
package referenced in the code, so I'd pick a different name, preferably something specific to dolt CI.
One ideas is to move the contents of dolt_ci/schema
into dolt_ci
and use that as the package name. It looks like dolt_ci
is currently empty, except for the schema
subdirectory, so that would simplify the directory structure and make the package name more explicit/obvious for code readers to quickly understand.
skip "session ctx in shell is not the same as session in server" | ||
fi | ||
} | ||
|
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.
Might be worth adding a test for the case where dolt ci init
is called on a database that has already been initialized, and check for the dolt ci has already been initialized
error message.
// HasDoltCIPrefix returns a boolean whether or not the provided string is prefixed with the DoltCINamespace. Users should | ||
// not be able to create tables in this reserved namespace. |
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.
Another good, quick test would be to try and create a user table with the dolt_ci_
prefix and assert that it results in an error.
// todo: find way to make these writable by the dolt process | ||
// todo: but not by user |
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 haven't dug into this, but my gut says adding these tables to the writable system tables list is going to make it hard to prevent users from writing to them. It seems like leaving them out of here and having another code path that writes to them might be what you need to achieve this.
Not a big deal for the initial version of this, just brainstorming ideas here for future iterations.
{ | ||
Name: "select * from dolt_ci_workflows;", | ||
SetUpScript: []string{ | ||
"insert into dolt_ci_workflows values" + |
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.
Looks like these new Go tests are failing in CI because the dolt_ci_workflows
table doesn't exist yet. Perhaps the RunDoltCIConfigTests
function below needs to call the schema create action function that the CLI uses to initialize these tables first?
"github.com/dolthub/dolt/go/store/datas" | ||
) | ||
|
||
var ExpectedDoltCITablesOrdered = []doltdb.TableName{ |
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.
Looks like several exported vars/functions probably don't need to be exported and would be better to keep them encapsulated in this namespace to prevent them from showing up as options for use outside this package. For example, ExpectedDoltCITablesOrderd
could be unexported since it's only used in this file.
I'll tag a few others I noticed in this file, but would be good to take a quick check through and lowercase as much as we can.
doltdb.TableName{Name: doltdb.WorkflowSavedQueryStepExpectedRowColumnResultsTableName}, | ||
} | ||
|
||
type QueryFunc func(ctx *sql.Context, query string) (sql.Schema, sql.RowIter, *sql.QueryFlags, error) |
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.
QueryFunc
seems like it could be changed to queryFunc
since it's not used outside of this package. That'll help prevent this from coming up as an option for other people, too, since it shouldn't be used anywhere else it seems like.
Also... perhaps less so with un-exported functions/types/etc, but I generally think if you're taking the time to define a type, you should help out future code readers and give it a quick doc string to document intent.
} | ||
|
||
func commitCIDestroy(ctx *sql.Context, queryFunc QueryFunc, commiterName, commiterEmail string) error { | ||
return sqlWriteQuery(ctx, queryFunc, fmt.Sprintf("CALL DOLT_COMMIT('-Am' 'Successfully destroyed Dolt CI', '--author', '%s <%s>');", commiterName, commiterEmail)) |
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 is potentially a little sneaky – if a user has other outstanding changes to their tables or even new tables they've just created, then the -A
flag will automatically stage all of them and include them in the commit. This should probably be careful to only stage the affected CI tables. This would be another good test to add, too – both for the init and destroy cases.
In the init
code path below in CreateDoltCITables
, it looks like this problem doesn't exist – it only stages the Dolt CI tables, so it won't add any user changes that happen to be in the workspace.
|
||
var ExpectedDoltCITablesOrdered = []doltdb.TableName{ | ||
doltdb.TableName{Name: doltdb.WorkflowsTableName}, | ||
doltdb.TableName{Name: doltdb.WorkflowEventsTableName}, |
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.
(minor) since this is already in a slice of type doltdb.TableName
you can omit the type name on these lines and make the code a little easier to read:
doltdb.TableName{Name: doltdb.WorkflowEventsTableName}, | |
{Name: doltdb.WorkflowEventsTableName}, |
This PR adds hidden commands for creating and destroying Dolt CI tables, which will be used for continuous integration on DoltHub/DoltLab.
Currently, when the hidden dolt ci commands are run, they will create/destroy all dolt ci tables and create a new dolt commit. However, this commit does not produce a diff.
These CI tables are currently alterable, so user's can change their contents and schema. Ideally, these would only be alterable/writeable by dolt itself, but we have no such interface for that.
Currently, the method
CreateDoltCITables
uses the approach of creating the tables against the root value. I didn't think to pass thequeryist.Query
method down until I createdDestroyDoltCITables
, so it's possible that's the preferred approach?