2020-05-31 12:36:09 +00:00
|
|
|
name: Tests
|
2022-10-26 03:30:37 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
workflow_dispatch:
|
2020-05-31 12:36:09 +00:00
|
|
|
|
|
|
|
jobs:
|
2021-10-01 22:41:54 +00:00
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
Composer:
|
|
|
|
runs-on: ubuntu-latest
|
2024-05-04 10:40:44 +00:00
|
|
|
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#handling-failures
|
|
|
|
continue-on-error: ${{ matrix.experimental }}
|
2024-05-04 11:07:53 +00:00
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-09-05 11:13:01 +00:00
|
|
|
uses: actions/checkout@v4
|
2020-05-31 12:36:09 +00:00
|
|
|
- name: Validate composer.json and composer.lock
|
|
|
|
run: composer validate
|
|
|
|
- name: Install dependencies
|
2021-05-30 07:17:23 +00:00
|
|
|
run: composer install --prefer-dist --no-dev
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
PHPunit:
|
2024-05-04 06:49:43 +00:00
|
|
|
name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }}
|
2020-05-31 13:53:57 +00:00
|
|
|
runs-on: ubuntu-latest
|
2024-05-04 06:49:43 +00:00
|
|
|
continue-on-error: ${{ matrix.experimental }}
|
2020-05-31 12:36:09 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-05-04 06:49:43 +00:00
|
|
|
php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
|
|
|
|
experimental: [false]
|
2024-05-04 10:16:37 +00:00
|
|
|
include:
|
2024-05-04 06:49:43 +00:00
|
|
|
- php-versions: '8.4' # development release, things can break
|
2024-05-04 10:16:37 +00:00
|
|
|
experimental: true
|
2021-10-01 22:38:21 +00:00
|
|
|
env:
|
|
|
|
extensions: gd, sqlite3
|
2021-10-01 23:01:24 +00:00
|
|
|
extensions-cache-key-name: phpextensions
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
steps:
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2021-10-01 22:41:54 +00:00
|
|
|
# let's get started!
|
2020-05-31 12:36:09 +00:00
|
|
|
- name: Checkout
|
2023-09-05 11:13:01 +00:00
|
|
|
uses: actions/checkout@v4
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2021-10-01 22:38:21 +00:00
|
|
|
# cache PHP extensions
|
|
|
|
- name: Setup cache environment
|
|
|
|
id: extcache
|
|
|
|
uses: shivammathur/cache-extensions@v1
|
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php-versions }}
|
|
|
|
extensions: ${{ env.extensions }}
|
2021-10-01 23:01:24 +00:00
|
|
|
key: ${{ runner.os }}-${{ env.extensions-cache-key }}
|
2021-10-01 22:38:21 +00:00
|
|
|
|
|
|
|
- name: Cache extensions
|
2024-01-18 11:21:35 +00:00
|
|
|
uses: actions/cache@v4
|
2021-10-01 22:38:21 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.extcache.outputs.dir }}
|
|
|
|
key: ${{ steps.extcache.outputs.key }}
|
2021-10-01 23:01:24 +00:00
|
|
|
restore-keys: ${{ runner.os }}-${{ env.extensions-cache-key }}
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
- name: Setup PHP
|
2020-05-31 13:53:57 +00:00
|
|
|
uses: shivammathur/setup-php@v2
|
2020-05-31 12:36:09 +00:00
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php-versions }}
|
2021-10-01 22:38:21 +00:00
|
|
|
extensions: ${{ env.extensions }}
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2021-10-01 23:07:57 +00:00
|
|
|
# Setup GitHub CI PHP problem matchers
|
|
|
|
# https://github.com/shivammathur/setup-php#problem-matchers
|
|
|
|
- name: Setup problem matchers for PHP
|
2022-10-25 04:53:26 +00:00
|
|
|
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
|
|
|
|
2021-10-01 23:07:57 +00:00
|
|
|
- name: Setup problem matchers for PHPUnit
|
|
|
|
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2021-10-01 22:27:57 +00:00
|
|
|
# composer cache
|
2020-05-31 13:10:30 +00:00
|
|
|
- name: Remove composer lock
|
|
|
|
run: rm composer.lock
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2021-10-01 22:27:57 +00:00
|
|
|
- name: Get composer cache directory
|
|
|
|
id: composer-cache
|
2022-10-26 03:51:36 +00:00
|
|
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
2021-10-01 22:27:57 +00:00
|
|
|
# http://man7.org/linux/man-pages/man1/date.1.html
|
|
|
|
# https://github.com/actions/cache#creating-a-cache-key
|
|
|
|
- name: Get Date
|
|
|
|
id: get-date
|
2022-10-26 03:51:36 +00:00
|
|
|
run: echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
|
2021-10-01 22:27:57 +00:00
|
|
|
shell: bash
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2021-10-01 22:27:57 +00:00
|
|
|
- name: Cache dependencies
|
2024-01-18 11:21:35 +00:00
|
|
|
uses: actions/cache@v4
|
2021-10-01 22:27:57 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
2021-10-01 22:32:57 +00:00
|
|
|
key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }}
|
2021-10-01 22:29:48 +00:00
|
|
|
restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2021-10-01 23:12:08 +00:00
|
|
|
# composer installation
|
2024-05-09 17:33:50 +00:00
|
|
|
- name: Unset platform requirement
|
|
|
|
run: composer config --unset platform
|
|
|
|
|
2020-05-31 12:45:25 +00:00
|
|
|
- name: Setup PHPunit
|
|
|
|
run: composer install -n
|
2021-10-01 23:12:08 +00:00
|
|
|
|
2021-05-28 20:39:50 +00:00
|
|
|
- name: Install Google Cloud Storage
|
|
|
|
run: composer require google/cloud-storage
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2021-10-01 22:27:57 +00:00
|
|
|
# testing
|
2020-05-31 12:42:11 +00:00
|
|
|
- name: Run unit tests
|
2024-05-04 11:07:53 +00:00
|
|
|
run: ../vendor/bin/phpunit --no-coverage --log-junit results.xml
|
2020-05-31 12:42:11 +00:00
|
|
|
working-directory: tst
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2024-05-04 11:07:53 +00:00
|
|
|
- name: Upload Test Results
|
|
|
|
if: always()
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: Test Results (PHP ${{ matrix.php-versions }})
|
|
|
|
path: tst/results.xml
|
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
Mocha:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
- name: Checkout
|
2023-09-05 11:13:01 +00:00
|
|
|
uses: actions/checkout@v4
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
- name: Setup Node
|
2023-10-24 11:05:40 +00:00
|
|
|
uses: actions/setup-node@v4
|
2020-05-31 12:36:09 +00:00
|
|
|
with:
|
2023-10-24 17:03:47 +00:00
|
|
|
node-version: '20'
|
2021-10-01 22:55:08 +00:00
|
|
|
cache: 'npm'
|
2022-07-09 15:00:45 +00:00
|
|
|
cache-dependency-path: 'js/package-lock.json'
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
- name: Setup Mocha
|
|
|
|
run: npm install -g mocha
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
- name: Setup Node modules
|
2022-07-09 14:48:21 +00:00
|
|
|
run: npm ci
|
2020-05-31 12:42:11 +00:00
|
|
|
working-directory: js
|
2022-10-25 04:53:26 +00:00
|
|
|
|
2020-05-31 12:36:09 +00:00
|
|
|
- name: Run unit tests
|
2024-05-04 11:14:25 +00:00
|
|
|
run: npm run ci-test
|
2020-05-31 12:42:11 +00:00
|
|
|
working-directory: js
|
2024-05-04 11:07:53 +00:00
|
|
|
|
|
|
|
- name: Upload Test Results
|
|
|
|
if: always()
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: Test Results (Mocha)
|
2024-05-04 11:13:22 +00:00
|
|
|
path: js/mocha-results.xml
|
2024-05-04 11:21:57 +00:00
|
|
|
|
|
|
|
event_file:
|
|
|
|
name: "Event File"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Upload
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: Event File
|
|
|
|
path: ${{ github.event_path }}
|
2024-05-04 11:07:53 +00:00
|
|
|
|