Skip to content

Commit

Permalink
some cleanup, adding beginnings of Builder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Jan 16, 2025
1 parent de28e24 commit 617c2d8
Show file tree
Hide file tree
Showing 24 changed files with 320 additions and 195 deletions.
70 changes: 70 additions & 0 deletions .github/actions/bootstrap/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: 'Bootstrap'
description: 'Bootstraps the GHA runner for Builder tests'

inputs:
php-version:
required: true
description: 'PHP version to use for tests'

runs:
using: composite
steps:
- name: 'Define vars'
id: vars
shell: bash -e {0}
# language=sh
run: |
_phpunit_version=
case "${{ inputs.php-version }}" in
8.1) _phpunit_version='10.5' ;;
8.2) _phpunit_version='11.1' ;;
8.3) _phpunit_version='11.1' ;;
8.4) _phpunit_version='11.1' ;;
*) echo "Unsupported PHP version: ${{ inputs.php-version }}" && exit 1 ;;
esac
echo "phpunit-version=${_phpunit_version}" >> $GITHUB_OUTPUT
- name: 'Install PHP'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
extensions: libxml simplexml json zip
ini-values: precision=20

- name: 'Install jq'
uses: dcarbone/install-jq-action@v3
with:
force: true

- name: 'Set composer dep versions'
# language=sh
run: |
tmpf="$(mktemp)"
jq -rcM '."require-dev"."phpunit/phpunit" = "^${{ steps.vars.outputs.phpunit-version }}"' composer.json > "${tmpf}"
mv "${tmpf}" composer.json
- name: 'Get composer cache directory'
id: composer-cache
# language=sh
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: 'Init composer dep cache'
id: cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: "composer-${{ runner.os }}-${{ inputs.php-version }}-${{ steps.vars.outputs.phpunit-version }}-${{ hashFiles('composer.lock') }}"

- name: 'Install composer deps'
# language=sh
run: |
rm composer.lock
composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: 'Save composer dep cache'
if: steps.cache.outputs.cache-hit != 'true' && steps.cache.outputs.cache-hit != true
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: "composer-${{ runner.os }}-${{ inputs.php-version }}-${{ steps.vars.outputs.phpunit-version }}-${{ hashFiles('composer.lock') }}"
106 changes: 26 additions & 80 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ on:
- 'phpunit.xml'

jobs:
builder-tests:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
name: 'Builder Tests - PHP ${{ matrix.php-version }}'
steps:
- uses: actions/checkout@v4
- name: 'Bootstrap'
uses: ./.github/actions/bootstrap
with:
php-version: ${{ matrix.php-version }}
- name: 'Run tests'
# language=sh
run: ./vendor/bin/phpunit -c 'phpunit/Builder.xml'

load-fhir-source:
runs-on: ubuntu-22.04
strategy:
Expand All @@ -38,29 +59,17 @@ jobs:
- 'R4'
- 'R4B'
- 'R5'

name: 'Download ${{ matrix.test-target }} Source'
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/load-fhir-xsd
with:
version: '${{ matrix.test-target }}'


# load-fhir-validator:
# runs-on: ubuntu-22.04
# name: 'Download FHIR Validator'
# steps:
# - uses: actions/checkout@v4
#
# - uses: ./.github/actions/load-fhir-validator

run:
runs-on: ubuntu-22.04
needs:
- load-fhir-source
# - load-fhir-validator
strategy:
fail-fast: false
matrix:
Expand All @@ -77,82 +86,19 @@ jobs:
- 'R4'
- 'R4B'
- 'R5'
include:
- php-version: '8.1'
phpunit-version: '10.5'
- php-version: '8.2'
phpunit-version: '11.1'
- php-version: '8.3'
phpunit-version: '11.1'
- php-version: '8.4'
phpunit-version: '11.1'

name: '${{ matrix.test-target }} - PHP ${{ matrix.php-version }} - PHPUnit ${{ matrix.phpunit-version }}'
steps:
- name: 'Check the stuff out'
uses: actions/checkout@v4

- uses: actions/checkout@v4
- name: 'Bootstrap'
uses: ./.github/actions/bootstrap
with:
php-version: ${{ matrix.php-version }}
- name: 'Load FHIR ${{ matrix.test-target }} Source'
id: fhir-source
if: matrix.test-target != 'Core'
uses: ./.github/actions/load-fhir-xsd
with:
version: '${{ matrix.test-target }}'

# - name: 'Install FHIR validator'
# uses: ./.github/actions/load-fhir-validator

- name: 'Install PHP'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: libxml simplexml json zip
ini-values: precision=20

- name: 'Install jq'
uses: dcarbone/install-jq-action@v3
with:
force: true

- name: 'Set Composer Dep Versions'
# language=sh
run: |
tmpf="$(mktemp)"
jq -rcM '."require-dev"."phpunit/phpunit" = "^${{ matrix.phpunit-version }}"' composer.json > "${tmpf}"
mv "${tmpf}" composer.json
- name: 'Get Composer Cache Directory'
id: composer-cache
# language=sh
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: 'Init composer dep cache'
id: cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.phpunit-version }}-${{ hashFiles('composer.lock') }}"

- name: 'Install Composer deps'
# language=sh
run: |
rm composer.lock
composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: 'Save composer dep cache'
if: steps.cache.outputs.cache-hit != 'true' && steps.cache.outputs.cache-hit != true
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.phpunit-version }}-${{ hashFiles('composer.lock') }}"

# - name: 'Install Java'
# uses: actions/setup-java@v4
# with:
# distribution: 'zulu'
# java-version: 18

- name: 'Run tests'
# language=sh
run: |
Expand Down
7 changes: 1 addition & 6 deletions bin/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'name' => 'DSTU1',

// Namespace to generate classes into. This is nested under the value provided to rootNamespace.
'namespace' => 'Versions\\DSTU1',
'namespace' => 'DSTU1',

// Local path to un-compressed source schema files for this version
'schemaPath' => __DIR__ . '/../input/DSTU1',
Expand All @@ -64,27 +64,22 @@
[
'name' => 'DSTU2',
'schemaPath' => __DIR__ . '/../input/DSTU2',
'namespace' => 'Versions\\DSTU2',
],
[
'name' => 'STU3',
'schemaPath' => __DIR__ . '/../input/STU3',
'namespace' => 'Versions\\STU3',
],
[
'name' => 'R4',
'schemaPath' => __DIR__ . '/../input/R4',
'namespace' => 'Versions\\R4',
],
[
'name' => 'R4B',
'schemaPath' => __DIR__ . '/../input/R4B',
'namespace' => 'Versions\\R4B',
],
[
'name' => 'R5',
'schemaPath' => __DIR__ . '/../input/R5',
'namespace' => 'Versions\\R5',
],
],
];
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
},
"require-dev": {
"phpunit/phpunit": "^10.5 || ^11.0",
"monolog/monolog": "^3.2.0"
"monolog/monolog": "^3.2.0",
"spatie/temporary-directory": "^1.0"
},
"replace": {
"php-fhir/parser": "*",
Expand All @@ -53,6 +54,11 @@
"DCarbone\\PHPFHIR\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"DCarbone\\PHPFHIRTests\\": "tests/"
}
},
"suggest": {
"ext-zip": "To enable unzipping of downloaded source files"
}
Expand Down
Loading

0 comments on commit 617c2d8

Please sign in to comment.