Skip to content

Commit

Permalink
Cleanup and unify monorepo testing (#40)
Browse files Browse the repository at this point in the history
* Fix wikibase-api integration tests with Dockerfile

* Use phpunit from the monorepo only

This:
 - Removes phpunit commands from composer.json files
   of packages

* Unify package compose scripts and require-devs

the "test" command is always needed as CI runs this in each
package.
Thus the deps also need to be loaded in those packages..!

* Don't add phpunit/phpunit in monorepo merge

(It's already added from packages...)

* Make phpunit commands run in the tests dir

* Manually unify the integration test stuff

* Fix tests/Integration -> tests/integration
  • Loading branch information
addwiki-ci committed Feb 15, 2021
1 parent 3a75525 commit b76e292
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 220 deletions.
10 changes: 10 additions & 0 deletions Dockerfile-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mediawiki:1.35.1

RUN apt-get update && \
apt-get install --yes --no-install-recommends unzip=6.* jq=1.* curl=7.* ca-certificates=202* && \
apt-get clean && rm -rf /var/lib/apt/lists/*

ADD https://raw.githubusercontent.com/wmde/wikibase-docker/262ffef7cc550381309c360e3e92507e85cd8bf6/wikibase/1.35/base/wait-for-it.sh /
ADD build/ /

RUN chmod +x /*.sh
6 changes: 3 additions & 3 deletions build/docker-compose-ci-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
set -x

# Wait for the DB to be ready?
/dc-scripts/wait-for-it.sh $MYSQL_SERVER:3306 -t 300
/wait-for-it.sh $MYSQL_SERVER:3306 -t 300
sleep 1
/dc-scripts/wait-for-it.sh $MYSQL_SERVER:3306 -t 300
/wait-for-it.sh $MYSQL_SERVER:3306 -t 300

# Install MediaWiki
php maintenance/install.php --server="http://localhost:8877" --scriptpath= --dbtype mysql --dbuser $MYSQL_USER --dbpass $MYSQL_PASSWORD --dbserver $MYSQL_SERVER --lang en --dbname $MYSQL_DATABASE --pass LongCIPass123 SiteName CIUser

# Run apache
apache2-foreground
apache2-foreground
5 changes: 1 addition & 4 deletions build/docker-compose-ci-wait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

repo_path=$(dirname $(dirname $(realpath $0)))

# Wait for the port to appear open
$repo_path/build/wait-for-it.sh localhost:8877 -t 300

# Wait for apache to actually be running
for i in {1..30}
do
Expand All @@ -15,4 +12,4 @@ do
break
fi
sleep 1
done
done
178 changes: 0 additions & 178 deletions build/wait-for-it.sh

This file was deleted.

33 changes: 16 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,29 @@
"name": "Addshore"
}
],
"scripts": {
"lint": "parallel-lint . --exclude vendor",
"phpcs": "phpcs -ps",
"fix": "phpcbf",
"phpunit": "phpunit tests",
"phpunit-unit": "phpunit tests/unit",
"phpunit-integration": "phpunit tests/integration",
"test": [
"@lint",
"@phpcs",
"@phpunit"
]
},
"require": {
"php": "^7.2",
"guzzlehttp/guzzle": "~6.0",
"guzzlehttp/promises": "~1.0",
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~9",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"mediawiki/mediawiki-codesniffer": "~35.0",
"phpunit/phpunit": "~9"
"mediawiki/mediawiki-codesniffer": "~35.0"
},
"suggest": {
"etsy/phan": "Allows running static analysis on the package (requires PHP 7+)"
Expand All @@ -30,21 +43,7 @@
},
"autoload-dev": {
"files": [
"tests/Integration/TestEnvironment.php"
]
},
"scripts": {
"lint": "parallel-lint . --exclude vendor",
"phpcs": "phpcs -ps",
"fix": "phpcbf",
"phpunit": "phpunit",
"phpunit-coverage": "phpunit --coverage-clover=coverage.clover",
"phpunit-integration": "phpunit --testsuite integration",
"phpunit-unit": "phpunit --testsuite unit",
"test": [
"@lint",
"@phpcs",
"@phpunit"
"tests/integration/TestEnvironment.php"
]
},
"extra": {
Expand Down
6 changes: 4 additions & 2 deletions docker-compose-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ version: '3'

services:
mediawiki:
image: mediawiki:1.35.1
build:
context: .
dockerfile: Dockerfile-ci
restart: always
entrypoint: /dc-scripts/docker-compose-ci-entrypoint.sh
environment:
Expand All @@ -30,4 +32,4 @@ services:
MYSQL_DATABASE: my_wiki
MYSQL_USER: wikiuser
MYSQL_PASSWORD: example
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
16 changes: 0 additions & 16 deletions phpunit.xml.dist

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b76e292

Please sign in to comment.