Skip to content

Improve Unit Tests GH Action #26

Improve Unit Tests GH Action

Improve Unit Tests GH Action #26

Workflow file for this run

name: Unit Tests
on:
push:
pull_request:
workflow_dispatch:
# used when called manually. 'secrets' are passed in automagically
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
inputs:
COMPOSER_ROOT_VERSION:
description: 'branch alias to use instead of dev-SHA, must have branch-alias in composer.json for root project'
default: 'dev-main'
required: false
type: string
workflow_call:
# used when called by _another_ workflow (not when called on this repo!)
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_call
inputs:
COMPOSER_ROOT_VERSION:
description: 'branch alias to use instead of dev-SHA, must have branch-alias in composer.json for root project'
default: 'dev-main'
required: false
type: string
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Print directory info after checkout
run: ls -lah
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3.12'
tools: cs2pr:1.8.5, composer:2.8.4, phpunit:10.5.40
- name: Output PHP info
run: php -i
- 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"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Composer dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
env:
# use the inputs if supplied (from being called via another workflow), supplied vars, or env as a final fallback
COMPOSER_ROOT_VERSION: ${{ inputs.COMPOSER_ROOT_VERSION || vars.COMPOSER_ROOT_VERSION || env.COMPOSER_ROOT_VERSION }}
run: composer install --no-interaction --no-scripts --ignore-platform-req=php+
- name: Cache built crc64fast-nvme shared library
id: crc64fast-nvme-cache
uses: actions/cache@v4
with:
path: build/crc64fast-nvme
# Use the hash of the Makefile, since the git build version will be in the Makefile
key: ${{ runner.os }}-crc64fast-nvme-${{ hashFiles('build/Makefile') }}
restore-keys: |
${{ runner.os }}-crc64fast-nvme-
- name: Cache built crc32fast-lib-rust shared library
id: crc32fast-lib-rust-cache
uses: actions/cache@v4
with:
path: build/crc32fast-lib-rust
# Use the hash of the Makefile, since the git build version will be in the Makefile
key: ${{ runner.os }}-crc32fast-lib-rust-${{ hashFiles('build/Makefile') }}
restore-keys: |
${{ runner.os }}-crc32fast-lib-rust-
- name: Build crc64fast-nvme shared library
if: steps.crc64fast-nvme-cache.outputs.cache-hit != 'true'
id: build-crc64fast-nvme
run: make build-crc64nvme
- name: Build crc32fast-lib-rust shared library
if: steps.crc32fast-lib-cache.outputs.cache-hit != 'true'
id: build-crc32isohdlc
run: make build-crc32isohdlc
- name: Run PHPUnit
id: run-phpunit
run: phpunit --do-not-cache-result -c phpunit.xml tests/unit 2>/dev/null