mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-03 07:04:07 +01:00
* [ADD] GitHub action workflow for testing and coverage.
Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
97
.github/workflows/feature.yaml
vendored
Normal file
97
.github/workflows/feature.yaml
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
name: Feature Build & Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- '!*' # Do not execute on tags
|
||||
paths:
|
||||
- lib/*
|
||||
- app/*
|
||||
- tests/*
|
||||
- '*.json'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '!*.MD'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ ubuntu-latest ]
|
||||
php: [ '7.4', '8' ]
|
||||
name: Build & Test ${{ matrix.php }}/${{ matrix.platform }}
|
||||
runs-on: ${{ matrix.platform }}
|
||||
env:
|
||||
DB_SERVER: mariadb
|
||||
DB_NAME: syspass
|
||||
DB_USER: syspass
|
||||
DB_PASS: syspass
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:10.3
|
||||
env:
|
||||
MYSQL_USER: ${{ env.DB_USER }}
|
||||
MYSQL_PASSWORD: ${{ env.DB_PASS }}
|
||||
MYSQL_DATABASE: ${{ env.DB_NAME }}
|
||||
MYSQL_ROOT_PASSWORD: ${{ env.DB_PASS }}
|
||||
ports:
|
||||
- 3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Setup PHP with tools
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: mbstring, intl, gd, ldap, gettext, pdo_mysql
|
||||
tools: phpunit
|
||||
coverage: xdebug
|
||||
env:
|
||||
fail-fast: true
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
composer install \
|
||||
--prefer-dist \
|
||||
--ignore-platform-reqs \
|
||||
--no-interaction \
|
||||
--no-plugins \
|
||||
--no-scripts \
|
||||
--prefer-dist
|
||||
|
||||
- name: Setup database
|
||||
env:
|
||||
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
MYSQL_OPTS="-h ${DB_SERVER} -P ${DB_PORT} -u ${DB_USER} -p${DB_PASS}"
|
||||
|
||||
mysql ${MYSQL_OPTS} -e 'DROP DATABASE IF EXISTS `'"$DB_NAME"'`;'
|
||||
mysql ${MYSQL_OPTS} -e 'CREATE DATABASE `'"$DB_NAME"'` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;'
|
||||
mysql ${MYSQL_OPTS} ${$DB_NAME} < ./schemas/dbstructure.sql
|
||||
|
||||
- uses: paambaati/codeclimate-action@v2.2.4
|
||||
env:
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
|
||||
XDEBUG_MODE: coverage
|
||||
with:
|
||||
coverageCommand: ./vendor/bin/phpunit -c ./tests/phpunit.xml --testsuite core
|
||||
coverageLocations: ./tests/_output/coverage-clover.xml:clover
|
||||
Reference in New Issue
Block a user