2020-05-31 20:36:09 +08:00
|
|
|
name: Tests
|
|
|
|
on: [push]
|
|
|
|
|
|
|
|
jobs:
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2020-05-31 20:36:09 +08:00
|
|
|
Composer:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-06-10 11:02:26 +08:00
|
|
|
uses: actions/checkout@v3
|
2020-05-31 20:36:09 +08:00
|
|
|
- name: Validate composer.json and composer.lock
|
|
|
|
run: composer validate
|
|
|
|
- name: Install dependencies
|
2021-05-30 15:17:23 +08:00
|
|
|
run: composer install --prefer-dist --no-dev
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2020-05-31 20:36:09 +08:00
|
|
|
PHPunit:
|
2020-05-31 21:53:57 +08:00
|
|
|
runs-on: ubuntu-latest
|
2020-05-31 20:36:09 +08:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-06-02 02:50:38 +08:00
|
|
|
php-versions: ['7.3', '7.4', '8.0', '8.1']
|
2020-05-31 20:36:09 +08:00
|
|
|
name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }}
|
2021-10-02 06:38:21 +08:00
|
|
|
env:
|
|
|
|
extensions: gd, sqlite3
|
2021-10-02 07:01:24 +08:00
|
|
|
extensions-cache-key-name: phpextensions
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2020-05-31 20:36:09 +08:00
|
|
|
steps:
|
2021-10-02 06:41:54 +08:00
|
|
|
|
|
|
|
# let's get started!
|
2020-05-31 20:36:09 +08:00
|
|
|
- name: Checkout
|
2022-06-10 11:02:26 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-10-02 06:27:57 +08:00
|
|
|
|
2021-10-02 06:38:21 +08: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-02 07:01:24 +08:00
|
|
|
key: ${{ runner.os }}-${{ env.extensions-cache-key }}
|
2021-10-02 06:38:21 +08:00
|
|
|
|
|
|
|
- name: Cache extensions
|
2022-06-10 10:59:25 +08:00
|
|
|
uses: actions/cache@v3
|
2021-10-02 06:38:21 +08:00
|
|
|
with:
|
|
|
|
path: ${{ steps.extcache.outputs.dir }}
|
|
|
|
key: ${{ steps.extcache.outputs.key }}
|
2021-10-02 07:01:24 +08:00
|
|
|
restore-keys: ${{ runner.os }}-${{ env.extensions-cache-key }}
|
2021-10-02 06:38:21 +08:00
|
|
|
|
2020-05-31 20:36:09 +08:00
|
|
|
- name: Setup PHP
|
2020-05-31 21:53:57 +08:00
|
|
|
uses: shivammathur/setup-php@v2
|
2020-05-31 20:36:09 +08:00
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php-versions }}
|
2021-10-02 06:38:21 +08:00
|
|
|
extensions: ${{ env.extensions }}
|
2021-10-02 07:07:57 +08:00
|
|
|
|
|
|
|
# Setup GitHub CI PHP problem matchers
|
|
|
|
# https://github.com/shivammathur/setup-php#problem-matchers
|
|
|
|
- name: Setup problem matchers for PHP
|
|
|
|
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
|
|
|
|
|
|
|
- name: Setup problem matchers for PHPUnit
|
|
|
|
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
2021-10-02 06:27:57 +08:00
|
|
|
|
|
|
|
# composer cache
|
2020-05-31 21:10:30 +08:00
|
|
|
- name: Remove composer lock
|
|
|
|
run: rm composer.lock
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2021-10-02 06:27:57 +08:00
|
|
|
- name: Get composer cache directory
|
|
|
|
id: composer-cache
|
|
|
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2021-10-02 06:27:57 +08: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
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
|
|
|
|
shell: bash
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2021-10-02 06:27:57 +08:00
|
|
|
- name: Cache dependencies
|
2022-06-10 10:59:25 +08:00
|
|
|
uses: actions/cache@v3
|
2021-10-02 06:27:57 +08:00
|
|
|
with:
|
|
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
2021-10-02 06:32:57 +08:00
|
|
|
key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }}
|
2021-10-02 06:29:48 +08:00
|
|
|
restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-
|
2021-10-02 06:27:57 +08:00
|
|
|
|
2021-10-02 07:12:08 +08:00
|
|
|
# composer installation
|
2020-05-31 20:45:25 +08:00
|
|
|
- name: Setup PHPunit
|
|
|
|
run: composer install -n
|
2021-10-02 07:12:08 +08:00
|
|
|
|
2021-05-29 04:39:50 +08:00
|
|
|
- name: Install Google Cloud Storage
|
|
|
|
run: composer require google/cloud-storage
|
2021-10-02 06:27:57 +08:00
|
|
|
|
|
|
|
# testing
|
2020-05-31 20:42:11 +08:00
|
|
|
- name: Run unit tests
|
2020-05-31 21:24:10 +08:00
|
|
|
run: ../vendor/bin/phpunit --no-coverage
|
2020-05-31 20:42:11 +08:00
|
|
|
working-directory: tst
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2020-05-31 20:36:09 +08:00
|
|
|
Mocha:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2020-05-31 20:36:09 +08:00
|
|
|
- name: Checkout
|
2022-06-10 11:02:26 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2020-05-31 20:36:09 +08:00
|
|
|
- name: Setup Node
|
2022-06-10 10:59:15 +08:00
|
|
|
uses: actions/setup-node@v3
|
2020-05-31 20:36:09 +08:00
|
|
|
with:
|
2022-07-10 06:13:47 +08:00
|
|
|
node-version: '16'
|
2021-10-02 06:55:08 +08:00
|
|
|
cache: 'npm'
|
2022-07-09 23:00:45 +08:00
|
|
|
cache-dependency-path: 'js/package-lock.json'
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2020-05-31 20:36:09 +08:00
|
|
|
- name: Setup Mocha
|
|
|
|
run: npm install -g mocha
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2020-05-31 20:36:09 +08:00
|
|
|
- name: Setup Node modules
|
2022-07-09 22:48:21 +08:00
|
|
|
run: npm ci
|
2020-05-31 20:42:11 +08:00
|
|
|
working-directory: js
|
2021-10-02 06:41:54 +08:00
|
|
|
|
2020-05-31 20:36:09 +08:00
|
|
|
- name: Run unit tests
|
2022-07-09 23:04:28 +08:00
|
|
|
run: npm test
|
2020-05-31 20:42:11 +08:00
|
|
|
working-directory: js
|
|
|
|
|