Commit 53814115 authored by Addshore's avatar Addshore 🏄
Browse files

Merge branch gitlab/main into github/dev

parents 6d0c204f 365e0bc3
......@@ -4,7 +4,19 @@
...
## [https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210907.1 v0.1.0-dev-addshore.20210907.1]
## [v0.1.0-dev-addshore.20210909.1](https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210909.1)
* `mw update`: Stop printing update success release notes twice
* `mw dev docker-compose` no longet breaks if passed no arguments
* `mw dev mediawiki`: Switch default MediaWiki PHP version to 7.3
* `mw dev mediawiki`: Include `php-ast` in MediaWiki container
* `mw dev mediawiki`: Output details of username, password and domain of MediaWiki site after install
* `mw dev mediawiki`: Nicer error from MediaWiki if no DB exists when loading a site
* `mw dev mediawiki install`: now requires that you specify a `--dbtype`
* DEV: `make`: Fix generation of staticfiles using make
## [v0.1.0-dev-addshore.20210907.1](https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210907.1)
* Enable updates from releases.wikimedia.org
* Fix segfaults caused by xdebug and `xdebug.var_display_max_` -1 values. ([phabricator](https://phabricator.wikimedia.org/T288363))
......@@ -12,20 +24,20 @@
* MediaWiki no longer has `ini_set( 'xdebug.var_display_max_children', -1 );` set
* MediaWiki no longer has `ini_set( 'xdebug.var_display_max_data', -1 );` set
## [https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210806.1 v0.1.0-dev-addshore.20210806.1]
## [v0.1.0-dev-addshore.20210806.1](https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210806.1)
* Fix mysql server db check complaining about Countable ([phabricator](https://phabricator.wikimedia.org/T287695))
* Prepare for releases from releases.wikimedia.org
* Take backups of LocalSettings incase they get lost
* Create a user .composer directory if it doesn't exist ([phabricator](https://phabricator.wikimedia.org/T288309))
## [https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210714.1 v0.1.0-dev-addshore.20210714.1]
## [v0.1.0-dev-addshore.20210714.1](https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210714.1)
* Replace docker command with mwdd functionality
* Introduce a dev alias for use with your main development environment command
* Introduced basic cli configuration and config command
## [https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210703.1 v0.1.0-dev-addshore.20210703.1]
## [v0.1.0-dev-addshore.20210703.1](https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210703.1)
* Improve updater output
* mwdd
......@@ -34,13 +46,13 @@
** Fix most --user options for most exec commands
** Remove duplicate phpunit command
## [https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210627.1 v0.1.0-dev-addshore.20210627.1]
## [v0.1.0-dev-addshore.20210627.1](https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210627.1)
[https://github.com/addshore/mwcli/compare/v0.1.0-dev-addshore.20210524.1...v0.1.0-dev-addshore.20210627.1 Commits]
* mwdd: Use docker-compose 3.7 file versions
* mwdd: Use stretch-php72-fpm:3.0.0 image for MediaWiki, which fixed XDebug issues
## v0.1.0-dev-addshore.20210524.1
## [v0.1.0-dev-addshore.20210524.1](https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210524.1)
[https://github.com/addshore/mwcli/compare/v0.1.0-dev-addshore.20210523.2...v0.1.0-dev-addshore.20210524.1 Commits]
* Allow users to choose if they update or not
......@@ -50,7 +62,7 @@
* mwdd: Internally use maintenance/checkComposerLockUpToDate.php
* mwdd: Add exec commands for all services
## v0.1.0-dev-addshore.20210523.2
## [v0.1.0-dev-addshore.20210523.2](https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210523.2)
[https://github.com/addshore/mwcli/compare/v0.1.0-dev-addshore.20210523.1...v0.1.0-dev-addshore.20210523.2 Commits]
......
......@@ -38,10 +38,10 @@ release:
install: all
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go install -v $(GO_PACKAGES)
generate: internal/mwdd/files/files.go
generate: generate-staticfiles
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go generate $(GO_PACKAGES)
internal/mwdd/files/files.go: static/mwdd/*
generate-staticfiles:
rm -f internal/mwdd/files/files.go || true
./bin/staticfiles -o internal/mwdd/files/files.go static/mwdd/
......@@ -66,4 +66,4 @@ lint:
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go vet -composites=false $(GO_PACKAGES)
.PHONY: install release
.PHONY: all get build release install generate generate-staticfiles clean test unit lint
......@@ -52,5 +52,5 @@ Execute the binary from any directory with `~/go/src/gerrit.wikimedia.org/r/medi
## Support
- Documentation: [Cli page on mediawiki.org](https://www.mediawiki.org/wiki/Cli)
- Phabricator: [#MediaWiki-Docker](https://phabricator.wikimedia.org/project/view/4585/)
- Phabricator: [#mwcli](https://phabricator.wikimedia.org/project/view/5331/)
- IRC: `#mediawiki`
......@@ -28,10 +28,21 @@ var mwddDockerComposeCmd = &cobra.Command{
Aliases: []string{"dc"},
Run: func(cmd *cobra.Command, args []string) {
mwdd.DefaultForUser().EnsureReady()
// This could be simpiler if the mwdd.DockerComposeCommand function just took a list of strings...
command := ""
if len(args) >= 1 {
command = args[0]
}
commandArgs := []string{}
if len(args) > 1 {
commandArgs = args[1:]
}
mwdd.DefaultForUser().DockerComposeTTY(
mwdd.DockerComposeCommand{
Command: args[0],
CommandArguments: args[1:],
Command: command,
CommandArguments: commandArgs,
HandlerOptions: exec.HandlerOptions{
Verbosity: Verbosity,
},
......
......@@ -200,6 +200,14 @@ var mwddMediawikiInstallCmd = &cobra.Command{
Short: "Installs a new MediaWiki site using install.php",
Aliases: []string{"i"},
Run: func(cmd *cobra.Command, args []string) {
// Make it harder for people to fall over https://phabricator.wikimedia.org/T287654 for now
if DbType != "sqlite" && DbType != "mysql" && DbType != "postgres" {
fmt.Println("You must specify a valid dbtype (mysql, postgres, sqlite)")
os.Exit(1)
}
// TODO check that the required DB services is running? OR start it up?
mediawiki, _ := mediawiki.ForDirectory(mwdd.DefaultForUser().Env().Get("MEDIAWIKI_VOLUMES_CODE"))
if !mediawiki.LocalSettingsIsPresent() {
prompt := promptui.Prompt{
......@@ -256,9 +264,8 @@ var mwddMediawikiInstallCmd = &cobra.Command{
if err == nil {
mwdd.DefaultForUser().DockerExec(mwdd.DockerExecCommand{
DockerComposeService: "mediawiki",
// --ignore-platform-reqs is currently used as only PHP7.2 is provided and some things need higher
Command: []string{"composer", "install", "--ignore-platform-reqs", "--no-interaction"},
User: User,
Command: []string{"composer", "install", "--ignore-platform-reqs", "--no-interaction"},
User: User,
})
} else {
fmt.Println("Can't install without up to date composer dependencies")
......@@ -286,19 +293,23 @@ var mwddMediawikiInstallCmd = &cobra.Command{
"/var/www/html/w/LocalSettings.php.mwdd.tmp",
}, exec.HandlerOptions{}, "root")
var serverLink string = "http://" + DbName + ".mediawiki.mwdd.localhost:" + mwdd.DefaultForUser().Env().Get("PORT")
const adminUser string = "admin"
const adminPass string = "mwddpassword"
// Do a DB type dependant install, writing the output LocalSettings.php to /tmp
if DbType == "sqlite" {
mwdd.DefaultForUser().Exec("mediawiki", []string{
"php",
"/var/www/html/w/maintenance/install.php",
"--confpath", "/tmp",
"--server", "http://" + DbName + ".mediawiki.mwdd.localhost:" + mwdd.DefaultForUser().Env().Get("PORT"),
"--server", serverLink,
"--dbtype", DbType,
"--dbname", DbName,
"--lang", "en",
"--pass", "mwddpassword",
"--pass", adminPass,
"docker-" + DbName,
"admin",
adminUser,
}, exec.HandlerOptions{}, "nobody")
}
if DbType == "mysql" {
......@@ -318,16 +329,16 @@ var mwddMediawikiInstallCmd = &cobra.Command{
"php",
"/var/www/html/w/maintenance/install.php",
"--confpath", "/tmp",
"--server", "http://" + DbName + ".mediawiki.mwdd.localhost:" + mwdd.DefaultForUser().Env().Get("PORT"),
"--server", serverLink,
"--dbtype", DbType,
"--dbuser", "root",
"--dbpass", "toor",
"--dbname", DbName,
"--dbserver", DbType,
"--lang", "en",
"--pass", "mwddpassword",
"--pass", adminPass,
"docker-" + DbName,
"admin",
adminUser,
}, exec.HandlerOptions{}, "nobody")
}
......@@ -345,6 +356,19 @@ var mwddMediawikiInstallCmd = &cobra.Command{
"--wiki", DbName,
"--quick",
}, exec.HandlerOptions{}, "nobody")
fmt.Println("")
fmt.Println("***************************************")
fmt.Println("Installation successfull 🎉")
fmt.Println("User: " + adminUser)
fmt.Println("Pass: " + adminPass)
fmt.Println("Link: " + serverLink)
fmt.Println("***************************************")
// TODO remove once https://phabricator.wikimedia.org/T287654 is solved
if DbType == "sqlite" {
fmt.Println("WARNING: The sqlite development environemtn currently suffers an issue, https://phabricator.wikimedia.org/T287654")
}
},
}
......@@ -462,7 +486,7 @@ func init() {
mwddMediawikiCmd.AddCommand(mwddMediawikiResumeCmd)
mwddMediawikiCmd.AddCommand(mwddMediawikiInstallCmd)
mwddMediawikiInstallCmd.Flags().StringVarP(&DbName, "dbname", "", "default", "Name of the database to install (must be accepted by MediaWiki, stick to letters and numbers)")
mwddMediawikiInstallCmd.Flags().StringVarP(&DbType, "dbtype", "", "sqlite", "Type of database to install (sqlite, mysql, postgres)")
mwddMediawikiInstallCmd.Flags().StringVarP(&DbType, "dbtype", "", "", "Type of database to install (mysql, postgres, sqlite)")
mwddMediawikiCmd.AddCommand(mwddMediawikiComposerCmd)
mwddMediawikiComposerCmd.Flags().StringVarP(&User, "user", "u", mwdd.UserAndGroupForDockerExecution(), "User to run as, defaults to current OS user uid:gid")
mwddMediawikiCmd.AddCommand(mwddMediawikiPhpunitCmd)
......
......@@ -95,8 +95,8 @@ func UpdateFromAddshore(currentVersion string, gitSummary string, verboseOutput
}
updateSuccess, updateMessage := UpdateFromAddshoreTo(*nextRelease, verboseOutput)
fmt.Println(updateMessage)
if !updateSuccess {
fmt.Println(updateMessage)
os.Exit(1)
}
return updateSuccess, updateMessage
......
......@@ -3,7 +3,7 @@ version: '3.7'
services:
mediawiki:
image: "${MEDIAWIKI_IMAGE:-docker-registry.wikimedia.org/dev/stretch-php72-fpm:3.0.0}"
image: "${MEDIAWIKI_IMAGE:-docker-registry.wikimedia.org/dev/stretch-php73-fpm:3.0.0}"
entrypoint: "/mwdd/entrypoint.sh"
volumes:
- ./wait-for-it.sh:/wait-for-it.sh:ro
......
......@@ -49,11 +49,15 @@ $mwddServices = [
################################
# MWDD Database
################################
// TODO cache the DB existance checks somehow so as not to run on every request...
// Figure out if we are using sqlite, or if this should be mysql..?
if( file_exists( $IP . '/data/' . $dockerDb . '.sqlite' ) ) {
$dockerDbType = 'sqlite';
} else {
// TODO cache this check somehow so that we don't need a query every time...
}
// Figure out if we are using mysql
if(!isset($dockerDbType)){
try{
$mysqlPdo = new PDO(
"mysql:host=mysql;dbname=" . $dockerDb,
......@@ -72,14 +76,34 @@ if( file_exists( $IP . '/data/' . $dockerDb . '.sqlite' ) ) {
$dockerDbType = 'mysql';
}
} catch ( Exception $e ) {
// TODO set the timeout on connection to be much shorter, so that when mysql doesnt exist, it doenst hang for a while
// do nothing
}
// If no other magic detection happened, we must be in postgres (or some generic error state)
if(!isset($dockerDbType)){
}
// Figure out if we are using postgres
if(!isset($dockerDbType)){
$pvars = [
'dbname' => $dockerDb,
'user' => 'root',
'password' => 'toor',
'host' => 'postgres',
];
$pconnString = '';
foreach ( $pvars as $name => $value ) {
$pconnString .= "$name='" . str_replace( "'", "\\'", $value ) . "' ";
}
$postgresConn = @pg_connect( $pconnString . ' connect_timeout=1', PGSQL_CONNECT_FORCE_NEW );
if($postgresConn !== false){
$dockerDbType = 'postgres';
}
}
// Otherwise something must be wrong
if(!isset($dockerDbType)){
die("Is your database running and wiki database created / installed?");
}
$wgDBname = $dockerDb;
if( $dockerDbType === 'sqlite' ) {
......
......@@ -5,5 +5,5 @@
chmod 777 /var/www/html/w/images/docker
# Then execute the regular entrypoint
# https://gerrit.wikimedia.org/r/plugins/gitiles/releng/dev-images/+/refs/heads/master/dockerfiles/stretch-php72-fpm/Dockerfile.template#32
# https://gerrit.wikimedia.org/r/plugins/gitiles/releng/dev-images/+/refs/heads/master/dockerfiles/stretch-php73-fpm/Dockerfile.template#32
/php_entrypoint.sh $@
......@@ -17,7 +17,7 @@ if [[ ! -f mediawiki/.gitlab-ci.cache.20210809-02 ]]; then
mkdir mediawiki/vendor
tar -xf vendor.tar.gz -C mediawiki/vendor
rm -r *.tar.gz
docker run --rm -v $PWD/mediawiki:/app -w /app --entrypoint=composer docker-registry.wikimedia.org/dev/stretch-php72-fpm:3.0.0 install --ignore-platform-reqs --no-interaction
docker run --rm -v $PWD/mediawiki:/app -w /app --entrypoint=composer docker-registry.wikimedia.org/dev/stretch-php73-fpm:3.0.0 install --ignore-platform-reqs --no-interaction
touch mediawiki/.gitlab-ci.cache.20210809-02
fi
......
......@@ -14,12 +14,10 @@ trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT
# Validate the basic stuff
./bin/mw docker docker-compose ps
./bin/mw docker env list
# TODO enable logo check again once the page no longer shown "Unable to connect to PostgreSQL server"
#CURL=$(curl -s -L -N http://default.mediawiki.mwdd.localhost:8080) && echo $CURL && echo $CURL | grep -q "The MediaWiki logo"
CURL=$(curl -s -L -N http://default.mediawiki.mwdd.localhost:8080) && echo $CURL && echo $CURL | grep -q "Unable to connect to PostgreSQL server"
CURL=$(curl -s -L -N http://default.mediawiki.mwdd.localhost:8080) && echo $CURL && echo $CURL | grep -q "Is your database running and wiki database created"
# Install sqlite & check
./bin/mw docker mediawiki install
./bin/mw docker mediawiki install --dbtype sqlite
CURL=$(curl -s -L -N http://default.mediawiki.mwdd.localhost:8080) && echo $CURL && echo $CURL | grep -q "MediaWiki has been installed"
# docker-compose: Make sure it appears to work
......
......@@ -13,9 +13,7 @@ trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT
# Create: Validate the basic stuff
./bin/mw docker docker-compose ps
# TODO enable logo check again once the page no longer shown "Unable to connect to PostgreSQL server"
#CURL=$(curl -s -L -N http://default.mediawiki.mwdd.localhost:8080) && echo $CURL && echo $CURL | grep -q "The MediaWiki logo"
CURL=$(curl -s -L -N http://default.mediawiki.mwdd.localhost:8080) && echo $CURL && echo $CURL | grep -q "Unable to connect to PostgreSQL server"
CURL=$(curl -s -L -N http://default.mediawiki.mwdd.localhost:8080) && echo $CURL && echo $CURL | grep -q "Is your database running and wiki database created"
# Turn on all of the services
./bin/mw docker mysql-replica create
......@@ -26,7 +24,7 @@ CURL=$(curl -s -L -N http://default.mediawiki.mwdd.localhost:8080) && echo $CURL
# Install everything (mysql, postgres, sqlite)
./bin/mw docker mediawiki install --dbname mysqlwiki --dbtype mysql
./bin/mw docker mediawiki install --dbname postgreswiki --dbtype postgres
./bin/mw docker mediawiki install
./bin/mw docker mediawiki install --dbtype sqlite
# Check the DB tools (phpmyadmin, adminer)
CURL=$(curl -s -L -N http://phpmyadmin.mwdd.localhost:8080) && echo $CURL && echo $CURL | grep -q "Open new phpMyAdmin window"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment