SemanticMediaWiki / SemanticResultFormats

Provides additional visualizations (result formats) for Semantic MediaWiki
https://www.semantic-mediawiki.org/wiki/Extension:Semantic_Result_Formats
Other
45 stars 75 forks source link

Use the canonical MW_INSTALL_PATH #691

Closed hexmode closed 2 years ago

hexmode commented 2 years ago

Enable local test runs more easily with containers.

codecov-commenter commented 2 years ago

Codecov Report

Merging #691 (69ddbc8) into master (598c269) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #691   +/-   ##
=========================================
  Coverage     36.00%   36.00%           
  Complexity     2044     2044           
=========================================
  Files            75       75           
  Lines          7213     7213           
=========================================
  Hits           2597     2597           
  Misses         4616     4616           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 598c269...69ddbc8. Read the comment docs.

gesinn-it-gea commented 2 years ago

@hexmode @JeroenDeDauw how about using a layered Docker approach instead of a Makefile. With "layered approach" I mean Docker images that are build like onion rings. A first layer is already in production: https://github.com/gesinn-it/docker-mediawiki. This builds on top of the official MediaWiki Docker and simply installs MW, Composer and other required pieces. Adding additional layers building on top of gesinn-it/docker-mediawiki is super simple like adding SMW.

This would:

The Makefile feels like the time before we started using reusable installer scripts for Travis. It is a massive maintenance effort due to code duplication. It increases build time before being ready to test.

@gesinn-it-wam please share your experience using a layered Docker approach here.

gesinn-it-wam commented 2 years ago

The Makefile does not build a docker image containing all the required parts but only uses the MediaWiki base image and builds the container on top of it for every run (saving previous work on its own). I think that a more 'docker-style' approach could save some lines and time in the Makefile: Based on the docker image already used in the github workflow, I currently test (and debug) extensions using Dockerfiles of the form

ARG MW_VERSION=1.35
ARG SMW_VERSION=dev-master
ARG MERMAID_VERSION=dev-master
ARG SRF_VERSION=dev-master

FROM gesinn/docker-mediawiki:$MW_VERSION

RUN COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-media-wiki $SMW_VERSION && \
    echo 'enableSemantics( "localhost" );' >> LocalSettings.php && \
    COMPOSER=composer.local.json composer require --no-update mediawiki/mermaid $MERMAID_VERSION && \
    echo 'wfLoadExtension( "Mermaid" );' >> LocalSettings.php && \
    COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-result-formats $SRF_VERSION && \
    echo 'wfLoadExtension( "SemanticResultFormats" );' >> LocalSettings.php && \
    composer update && \
    php maintenance/update.php --quick

RUN echo ';zend_extension=opcache.so' >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini && \
    echo ";zend_extension=xdebug" > /usr/local/etc/php/conf.d/99-xdebug.ini

COPY . extensions/SemanticResultFormats

CMD ["bash", "-c", "php tests/phpunit/phpunit.php --testdox -c extensions/SemanticResultFormats"]

Put it to the root of the extension folder and run the tests by

docker build . --tag srf && docker run --rm srf

The advantage is that most layers of the resulting docker image are built only once; even the COPY command only has to be executed, if there are changes to the folder. There is space for improvements and variations, of course:

Depending on the problem at hand, I use combinations of all the possibilities.

JeroenDeDauw commented 2 years ago

https://github.com/gesinn-it/docker-mediawiki

@gesinn-it-gea I recommend renaming that repo to make it very clear those are images aimed at dev/test, not production.

JeroenDeDauw commented 2 years ago

The makefile indeed looks like a maintenance liability.

https://github.com/ProfessionalWiki/ExternalContent/ has my currently preferred approach. Same test scripts used locally and on CI. Freedom to use own local docker setup. No docker image dependency on GH Actions, instead setup step caching, resulting in typical execution time of ~3 sec.

hexmode commented 2 years ago

I'm going to re-submit this with just the first commit. I will address the Makefile concerns in another PR.