Skip to content

if correct site ID is missing die #19

if correct site ID is missing die

if correct site ID is missing die #19

##
# OpenEMR has two different kinds of tests:
# - "Isolated tests": Tests that run without secondary services, a data layer or significant initialization requirements
# - "Tests": Tests that require a database and initialization before they can run or pass.
# This workflow runs the kind that does not require initialization.
name: Isolated Tests
on:
push:
branches:
- master
- rel-*
pull_request:
branches:
- master
- rel-*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'pull_request' && github.event.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
isolated-tests:
runs-on: ubuntu-24.04
strategy:
matrix:
php-version:
- '8.2'
- '8.3'
- '8.4'
- '8.5'
- '8.6'
name: PHP ${{ matrix.php-version }} - Isolated Tests
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
php-version: ${{ matrix.php-version }}
- name: Get composer cache directory
id: composer-cache
run: |
{
printf 'dir='
composer config cache-files-dir
} >> $GITHUB_OUTPUT
- name: Composer Cache
uses: actions/cache/restore@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.configurations.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.configurations.php }}-
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run isolated tests with coverage
run: |
vendor/bin/phpunit -c phpunit-isolated.xml \
--coverage-clover=clover.xml \
--coverage-filter=apis \
--coverage-filter=gacl \
--coverage-filter=interface \
--coverage-filter=library \
--coverage-filter=modules \
--coverage-filter=oauth2 \
--coverage-filter=portal \
--coverage-filter=sites \
--coverage-filter=src \
--coverage-filter=tests \
--coverage-html=htmlcov \
--log-junit=junit.xml \
--testdox
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: junit.xml
flags: isolated,php${{ matrix.php-version }}
report_type: test_results
- name: Hide test results from subsequent uploads
if: ${{ !cancelled() && hashFiles('junit.xml') != '' }}
run: mv junit.xml junit.saved-test-data
- name: Unhide test results for GitHub upload
if: ${{ !cancelled() && hashFiles('junit.saved-test-data') != '' }}
run: mv junit.saved-test-data junit.xml
- name: Upload JUnit test results to GitHub
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v6
with:
name: junit-isolated-tests-php-${{ matrix.php-version }}
path: junit.xml
- name: Check if coverage files exist
if: ${{ !cancelled() }}
id: check-files
run: |
echo "clover_exists=$(test -f clover.xml && echo true || echo false)" >> $GITHUB_OUTPUT
echo "htmlcov_exists=$(test -d ./htmlcov && echo true || echo false)" >> $GITHUB_OUTPUT
- name: Upload clover coverage report to GitHub
if: ${{ steps.check-files.outputs.clover_exists == 'true' && !cancelled() }}
uses: actions/upload-artifact@v6
with:
name: coverage-clover-isolated-tests-php-${{ matrix.php-version }}
path: |
clover.xml
- name: Upload html coverage report to GitHub
if: ${{ steps.check-files.outputs.htmlcov_exists == 'true' && !cancelled() }}
uses: actions/upload-artifact@v6
with:
name: coverage-html-isolated-tests-php-${{ matrix.php-version }}
path: |
htmlcov
- name: Upload coverage reports to Codecov
if: ${{ steps.check-files.outputs.clover_exists == 'true' && !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: clover.xml
flags: isolated,php${{ matrix.php-version }}