Skip to content

Tests

Tests #62

Workflow file for this run

name: Tests
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
tests:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
timeout-minutes: 40
strategy:
matrix:
php: ['8.1', '8.2', '8.3']
steps:
- name: Checkout Akaunting
timeout-minutes: 1
uses: actions/checkout@v4
with:
repository: akaunting/akaunting
- name: Checkout module to tmp path
timeout-minutes: 1
uses: actions/checkout@v4
with:
path: tmp-path-for-module
- id: set_var
timeout-minutes: 1
run: |
content=`cat ./tmp-path-for-module/module.json`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of optional handling for multi line json
echo "::set-output name=moduleJson::$content"
- name: Create module folder name which is PascalCase
timeout-minutes: 1
run: |
MODULE_FOLDER_NAME=$(echo -n ${{fromJson(steps.set_var.outputs.moduleJson).alias}} | sed -r 's/(^|-)([a-z])/\U\2/g')
echo "MODULE_FOLDER_NAME=${MODULE_FOLDER_NAME}" >> $GITHUB_ENV
- name: Checkout module
timeout-minutes: 1
uses: actions/checkout@v4
with:
path: modules/${{ env.MODULE_FOLDER_NAME }}
- name: Download the extra modules
timeout-minutes: 10
run: |
for k in $(jq -r '."extra-modules" | keys | .[]' tmp-path-for-module/module.json); do
modName=$(echo -n $k | sed -r 's/(^|-)([a-z])/\U\2/g')
mkdir -p modules/$modName
git clone https://${{ secrets.AKAUNTING_OFFICIAL_TOKEN }}:[email protected]/akaunting/module-${k}.git modules/$modName
done
- name: Remove the tmp folder
timeout-minutes: 1
run: rm -rf tmp-path-for-module
- name: Cache Composer
timeout-minutes: 1
uses: actions/cache@v4
with:
path: ~/.composer/cache/files
key: php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
timeout-minutes: 1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: bcmath, ctype, dom, fileinfo, intl, gd, json, mbstring, pdo, pdo_sqlite, openssl, sqlite, xml, zip
coverage: none
- name: Copy .env
timeout-minutes: 1
run: cp .env.testing .env
- name: Install Composer
timeout-minutes: 5
run: cd "modules/${{ env.MODULE_FOLDER_NAME }}" ; composer test ; cd ../.. ; composer test
- name: Execute tests
timeout-minutes: 30
run: php artisan test --parallel