Hi Ivan,
We have a bunch of Jenkins jobs that build RPMs for our Sqitch projects. As part of the RPM building, the %check section of the RPM spec file looks like this:
%check
psql -U postgres -c 'DROP DATABASE IF EXISTS configuration_test'
createdb -U postgres configuration_test
sqitch deploy db:pg://postgres@/configuration_test
pg_prove -U postgres -d configuration_test test/*.sql
sqitch revert db:pg://postgres@/configuration_test
dropdb -U postgres configuration_test
So it makes sure the deploy works, that all the unit tests pass, and the revert works. Works quite well. You could also just do this in a script block in Jenkins or in the relevant sections of a .travis.yml. Just need to make sure you have a database server you can use. Or write a shell script that does it and just call that.
HTH,
David
In a context of continuous integration or continuous delivery. How can I integrate sqitch with these tools?Use cases, flow tips, are welcome.
--Thank U.
You received this message because you are subscribed to the Google Groups "Sqitch Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqitch-users...@googlegroups.com.
To post to this group, send email to sqitch...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Amazing tool, thanks for your patience when I wrote a couple of things for Sqitch. Using it successfully at a new company and have a couple of things to chime in with.
> psql -U postgres -c 'DROP DATABASE IF EXISTS configuration_test'
> createdb -U postgres configuration_test
> sqitch deploy db:pg://postgres@/configuration_test
> pg_prove -U postgres -d configuration_test test/*.sql
> sqitch revert db:pg://postgres@/configuration_test
> dropdb -U postgres configuration_test
I appreciate this response was five years ago so things might have changed since then, but I've also added another `sqitch deploy` after the revert.
This catches occurrences where users miss adding to the revert properly (or not at all) as deploying over entities that still exist fails.
I've also recently had to add a change to the CI job to prevent people adding Sqitch changes out-of-order which affected deployment on production. This was caused by a dev with a long lived branch sneaking in a MR that I didn't vet with changes before the end of the plan.
It's not foolproof but it looks like:
- fetch target branch
- check out just the plan from that branch
- deploy from that plan
- check out source plan (git revert to tip)
- deploy from that plan
This helps catch stray changes working their way into the wrong position in the plan based on latest sqitch plan (that might be in production).
It's not fool proof as there's nothing stopping someone from creating a MR a week ago that passed at the time but the plan has changed since then, but other processes should kick in then to try and prevent that.
Cheers,
Paul
Yeah, it would run when the source branch goes into the target branch too, but if this is `master` the CI job would fail, but there's nothing stopping a deploy happy infrastructure bod from deploying the latest and greatest. So kind of process thing - where I am currently at least.
Hmm. I should probably check to see if gitlab supports periodically rerunning the CI jobs for MRs that are still open. Seems like a sensible feature so surely it exists. *reads*