CI with make/docker-compose
这个提交包含在:
父节点
d8879c73d7
当前提交
587d918cf2
|
@ -0,0 +1,5 @@
|
|||
Makefile
|
||||
Dockerfile
|
||||
docker-compose*
|
||||
coverage
|
||||
.git*
|
|
@ -0,0 +1,64 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
continue-on-error: ${{ matrix.experimental }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- mediawiki_version: 1.35
|
||||
semantic_mediawiki_version: 4.1.1
|
||||
approved_revs_version: 1.8.1
|
||||
database_type: mysql
|
||||
coverage: true
|
||||
experimental: false
|
||||
- mediawiki_version: 1.35
|
||||
semantic_mediawiki_version: 4.1.1
|
||||
approved_revs_version: 1.8.1
|
||||
database_type: sqlite
|
||||
coverage: false
|
||||
experimental: false
|
||||
- mediawiki_version: 1.38
|
||||
semantic_mediawiki_version: dev-master
|
||||
approved_revs_version: master
|
||||
database_type: sqlite
|
||||
coverage: false
|
||||
experimental: true
|
||||
|
||||
env:
|
||||
MW_VERSION: ${{ matrix.mediawiki_version }}
|
||||
SMW_VERSION: ${{ matrix.semantic_mediawiki_version }}
|
||||
AR_VERSION: ${{ matrix.approved_revs_version }}
|
||||
DB_TYPE: ${{ matrix.database_type }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Run tests
|
||||
run: make ci
|
||||
if: matrix.coverage == false
|
||||
|
||||
- name: Run tests with coverage
|
||||
run: make ci-coverage
|
||||
if: matrix.coverage == true
|
||||
|
||||
- name: Clean up after CI
|
||||
if: always()
|
||||
run: make destroy
|
||||
|
||||
- name: Upload code coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
files: coverage/php/coverage.xml
|
||||
if: matrix.coverage == true
|
|
@ -1,124 +0,0 @@
|
|||
---
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
continue-on-error: ${{ matrix.experimental }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- mediawiki_version: 1.35
|
||||
database_type: mysql
|
||||
semantic_mediawiki_version: 4.1.0
|
||||
coverage: true
|
||||
experimental: false
|
||||
- mediawiki_version: 1.35
|
||||
database_type: sqlite
|
||||
semantic_mediawiki_version: 4.1.0
|
||||
coverage: false
|
||||
experimental: false
|
||||
- mediawiki_version: 1.38
|
||||
database_type: sqlite
|
||||
semantic_mediawiki_version: dev-master
|
||||
coverage: false
|
||||
experimental: true
|
||||
- mediawiki_version: 1.39
|
||||
database_type: sqlite
|
||||
semantic_mediawiki_version: dev-master
|
||||
coverage: false
|
||||
experimental: true
|
||||
- mediawiki_version: 1.39
|
||||
database_type: mysql
|
||||
semantic_mediawiki_version: dev-master
|
||||
coverage: false
|
||||
experimental: true
|
||||
|
||||
services:
|
||||
some-mysql:
|
||||
image: mariadb:latest
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: database
|
||||
options: --name mysql --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10
|
||||
|
||||
container:
|
||||
image: gesinn/docker-mediawiki-${{ matrix.database_type }}:${{ matrix.mediawiki_version }}
|
||||
options: --link some-mysql:mysql
|
||||
|
||||
env:
|
||||
EXT_NAME: SemanticExtraSpecialProperties
|
||||
MW_INST_PATH: /var/www/html
|
||||
MW_DB_PATH: /var/www/data
|
||||
MW_EXT_PATH: /var/www/html/extensions
|
||||
|
||||
steps:
|
||||
- name: Get MySQL from dump
|
||||
working-directory: ${{ env.MW_INST_PATH }}
|
||||
run: bash restore-database.sh
|
||||
if: matrix.database_type == 'mysql'
|
||||
|
||||
- name: Install SemanticMediaWiki
|
||||
run: |
|
||||
COMPOSER=composer.local.json composer require --update-with-dependencies --working-dir ${{ env.MW_INST_PATH }} mediawiki/semantic-media-wiki ${{ matrix.semantic_mediawiki_version }}
|
||||
composer update --working-dir ${{ env.MW_INST_PATH }}
|
||||
echo "enableSemantics( 'localhost' );" >> ${{ env.MW_INST_PATH }}/LocalSettings.php
|
||||
|
||||
- name: Enable SemanticMediaWiki
|
||||
run: |
|
||||
echo "wfLoadExtension( 'SemanticMediaWiki' );" >> ${{ env.MW_INST_PATH }}/LocalSettings.php
|
||||
|
||||
- name: Run update
|
||||
run: |
|
||||
php ${{ env.MW_INST_PATH }}/maintenance/update.php --skip-external-dependencies --quick
|
||||
|
||||
- name: Checkout SemanticExtraSpecialProperties
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: ${{ env.EXT_NAME }}
|
||||
|
||||
# Setting actions/checkout@v2 path to env.MW_EXT_PATH fails with "Repository path '/var/www/html/extensions' is not under ..."
|
||||
# See also open PR https://github.com/actions/checkout/pull/388
|
||||
- name: Move SemanticExtraSpecialProperties
|
||||
run: |
|
||||
mkdir -p ${{ env.MW_EXT_PATH }}
|
||||
mv ${{ env.EXT_NAME }} ${{ env.MW_EXT_PATH }}
|
||||
|
||||
- name: Install SemanticExtraSpecialProperties
|
||||
run: |
|
||||
COMPOSER=composer.local.json composer require --no-update --working-dir ${{ env.MW_INST_PATH }} mediawiki/semantic-extra-special-properties @dev
|
||||
COMPOSER=composer.local.json composer config repositories.semantic-extra-special-properties '{"type": "path", "url": "extensions/SemanticExtraSpecialProperties"}' --working-dir ${{ env.MW_INST_PATH }}
|
||||
composer update --working-dir ${{ env.MW_INST_PATH }}
|
||||
echo "wfLoadExtension( '${{ env.EXT_NAME }}' );" >> ${{ env.MW_INST_PATH }}/LocalSettings.php
|
||||
tail -n5 ${{ env.MW_INST_PATH }}/LocalSettings.php
|
||||
php ${{ env.MW_INST_PATH }}/maintenance/update.php --quick
|
||||
|
||||
- name: Run Tests
|
||||
run: >
|
||||
php ${{ env.MW_INST_PATH }}/tests/phpunit/phpunit.php
|
||||
--configuration ${{ env.MW_EXT_PATH }}/${{ env.EXT_NAME }}
|
||||
--testdox
|
||||
if: matrix.coverage == false
|
||||
|
||||
- name: Run Tests With Coverage
|
||||
run: >
|
||||
php ${{ env.MW_INST_PATH }}/tests/phpunit/phpunit.php
|
||||
--configuration ${{ env.MW_EXT_PATH }}/${{ env.EXT_NAME }}
|
||||
--testdox
|
||||
--coverage-clover ${{ env.MW_INST_PATH }}/docs/coverage.xml
|
||||
if: matrix.coverage == true
|
||||
|
||||
- name: Upload code coverage
|
||||
uses: codecov/codecov-action@v2
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ${{ env.MW_INST_PATH }}/docs/coverage.xml
|
||||
if: matrix.coverage == true
|
|
@ -9,4 +9,7 @@ composer.lock
|
|||
composer.phar
|
||||
|
||||
vendor/
|
||||
extensions/
|
||||
extensions/
|
||||
coverage/
|
||||
docker-compose.override*
|
||||
.phpunit.result.cache
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
ARG MW_VERSION
|
||||
FROM gesinn/docker-mediawiki-sqlite:${MW_VERSION}
|
||||
|
||||
RUN rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini && \
|
||||
sed -i s/80/8080/g /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && \
|
||||
# To be able to persist configuration and data via docker volumes
|
||||
mkdir -p /data/sqlite /data/config /data/log && chown -R www-data. /data && \
|
||||
rm -f LocalSettings.php && ln -s /data/config/LocalSettings.php
|
||||
|
||||
ENV EXTENSION=SemanticExtraSpecialProperties
|
||||
COPY composer*.json /var/www/html/extensions/$EXTENSION/
|
||||
|
||||
ARG SMW_VERSION
|
||||
ARG AR_VERSION
|
||||
RUN curl -L https://github.com/wikimedia/mediawiki-extensions-ApprovedRevs/tarball/${AR_VERSION} \
|
||||
| tar xz --strip-components 1 --one-top-level=extensions/ApprovedRevs && \
|
||||
COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-media-wiki ${SMW_VERSION} && \
|
||||
COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-extra-special-properties @dev && \
|
||||
COMPOSER=composer.local.json composer config repositories.semantic-extra-special-properties \
|
||||
'{"type": "path", "url": "extensions/${EXTENSION}"}' && \
|
||||
composer update
|
||||
|
||||
COPY . /var/www/html/extensions/$EXTENSION
|
||||
|
||||
# Create file containing PHP code to setup extension; to be appended to LocalSettings.php
|
||||
RUN echo \
|
||||
'$wgDBerrorLog = "/data/log/dberror.log";\n' \
|
||||
'$wgDebugLogGroups["exception"] = "/data/log/exception.log";\n' \
|
||||
'if (file_exists( "$IP/LocalSettings.Pre.php" )) require_once( "$IP/LocalSettings.Pre.php" );\n' \
|
||||
'$smwgConfigFileDir = "/data/config";\n' \
|
||||
'wfLoadExtension( "SemanticMediaWiki" );\n' \
|
||||
'enableSemantics( $wgServer );\n' \
|
||||
'wfLoadExtension( "ApprovedRevs" );\n' \
|
||||
'$egApprovedRevsAutomaticApprovals = false;\n' \
|
||||
"wfLoadExtension( '$EXTENSION' );\n" \
|
||||
'$sespgEnabledPropertyList[] = "_CUSER";\n' \
|
||||
'$sespgEnabledPropertyList[] = "_REVID";\n' \
|
||||
'$sespgEnabledPropertyList[] = "_SUBP";\n' \
|
||||
'$sespgEnabledPropertyList[] = "_APPROVED";\n' \
|
||||
'$sespgEnabledPropertyList[] = "_APPROVEDBY";\n' \
|
||||
'$sespgEnabledPropertyList[] = "_APPROVEDDATE";\n' \
|
||||
'$sespgEnabledPropertyList[] = "_APPROVEDSTATUS";\n' \
|
||||
'if (file_exists( "$IP/LocalSettings.Post.php" )) require_once( "$IP/LocalSettings.Post.php" );\n' \
|
||||
>> __setup_extension__
|
|
@ -0,0 +1,105 @@
|
|||
EXTENSION := SemanticExtraSpecialProperties
|
||||
|
||||
MW_VERSION ?= 1.35
|
||||
SMW_VERSION ?= 4.1.1
|
||||
AR_VERSION ?= 1.8.1
|
||||
|
||||
IMAGE_VERSION := $(MW_VERSION)-$(SMW_VERSION)-$(AR_VERSION)
|
||||
BUILD_ARGS := \
|
||||
--build-arg MW_VERSION=$(MW_VERSION) \
|
||||
--build-arg SMW_VERSION=$(SMW_VERSION) \
|
||||
--build-arg AR_VERSION=$(AR_VERSION)
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
DB_TYPE ?= sqlite
|
||||
extension := $(shell echo $(EXTENSION) | tr A-Z a-z})
|
||||
IMAGE_NAME := $(extension):test-$(IMAGE_VERSION)
|
||||
EXTENSION_FOLDER := /var/www/html/extensions/${EXTENSION}
|
||||
|
||||
compose = IMAGE_NAME=$(IMAGE_NAME) EXTENSION_FOLDER=$(EXTENSION_FOLDER) docker-compose $(COMPOSE_ARGS)
|
||||
compose-run = $(compose) run -T --rm
|
||||
compose-exec-wiki = $(compose) exec -T wiki
|
||||
|
||||
show-current-target = @echo; echo "======= $@ ========"
|
||||
|
||||
.PHONY: ci
|
||||
ci: install
|
||||
$(show-current-target)
|
||||
$(compose-exec-wiki) bash -c "cd $(EXTENSION_FOLDER) && composer test"
|
||||
|
||||
.PHONY: ci-coverage
|
||||
ci-coverage: install
|
||||
$(show-current-target)
|
||||
$(compose-exec-wiki) bash -c "cd $(EXTENSION_FOLDER) && composer test-coverage"
|
||||
|
||||
.PHONY: install
|
||||
install: destroy up .install
|
||||
|
||||
.PHONY: up
|
||||
up: .init .build .up
|
||||
|
||||
.PHONY: down
|
||||
down: .init .down
|
||||
|
||||
.PHONY: destroy
|
||||
destroy: .init .destroy
|
||||
|
||||
.PHONY: bash
|
||||
bash: .init
|
||||
$(show-current-target)
|
||||
$(compose) exec wiki bash -c "cd $(EXTENSION_FOLDER) && bash"
|
||||
|
||||
.PHONY: show-logs
|
||||
show-logs: .init
|
||||
$(show-current-target)
|
||||
$(compose) logs -f || true
|
||||
|
||||
.PHONY: .build
|
||||
.build:
|
||||
$(show-current-target)
|
||||
$(compose) build $(BUILD_ARGS) wiki
|
||||
|
||||
.PHONY: .up
|
||||
.up:
|
||||
$(show-current-target)
|
||||
$(compose) up -d
|
||||
|
||||
.PHONY: .install
|
||||
.install: .wait-for-db
|
||||
$(show-current-target)
|
||||
$(compose-exec-wiki) bash -c "sudo -u www-data \
|
||||
php maintenance/install.php \
|
||||
--pass=wiki4everyone --server=http://localhost:8080 --scriptpath='' \
|
||||
--dbname=wiki --dbuser=wiki --dbpass=wiki $(WIKI_DB_CONFIG) wiki WikiSysop && \
|
||||
cat __setup_extension__ >> LocalSettings.php && \
|
||||
sudo -u www-data php maintenance/update.php --skip-external-dependencies --quick \
|
||||
"
|
||||
|
||||
.PHONY: .down
|
||||
.down:
|
||||
$(show-current-target)
|
||||
$(compose) down
|
||||
|
||||
.PHONY: .destroy
|
||||
.destroy:
|
||||
$(show-current-target)
|
||||
$(compose) down -v
|
||||
|
||||
.PHONY: .wait-for-db
|
||||
.wait-for-db:
|
||||
$(show-current-target)
|
||||
ifneq ($(DB_TYPE), sqlite)
|
||||
$(compose-run) wait-for $(DB_TYPE):3306 -t 120
|
||||
endif
|
||||
|
||||
.PHONY: .init
|
||||
.init:
|
||||
$(show-current-target)
|
||||
ifeq ($(DB_TYPE), mysql)
|
||||
$(eval COMPOSE_ARGS = --project-name $(extension)-mysql --profile mysql)
|
||||
$(eval WIKI_DB_CONFIG = --dbtype=mysql --dbserver=mysql --installdbuser=root --installdbpass=database)
|
||||
else
|
||||
$(eval COMPOSE_ARGS = --project-name $(extension)-sqlite)
|
||||
$(eval WIKI_DB_CONFIG = --dbtype=sqlite --dbpath=/data/sqlite)
|
||||
endif
|
||||
@echo "COMPOSE_ARGS: $(COMPOSE_ARGS)"
|
|
@ -61,7 +61,14 @@
|
|||
"process-timeout": 0
|
||||
},
|
||||
"scripts": {
|
||||
"phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist",
|
||||
"test": [
|
||||
"@phpunit"
|
||||
],
|
||||
"test-coverage": [
|
||||
"@phpunit-coverage"
|
||||
],
|
||||
"phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox",
|
||||
"phpunit-coverage": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox --coverage-text --coverage-html coverage/php --coverage-clover coverage/php/coverage.xml",
|
||||
"phpdbg": "phpdbg -qrr ../../tests/phpunit/phpunit.php -c phpunit.xml.dist"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
services:
|
||||
wiki:
|
||||
build: .
|
||||
image: ${IMAGE_NAME}
|
||||
volumes:
|
||||
- ./coverage:${EXTENSION_FOLDER}/coverage
|
||||
|
||||
mysql:
|
||||
image: mysql:5
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=database
|
||||
profiles:
|
||||
- mysql
|
||||
|
||||
wait-for:
|
||||
image: mintel/docker-wait-for-it
|
||||
profiles:
|
||||
- no-up
|
正在加载...
在新工单中引用