Skip to content

Run unit tests

Run unit tests #54

Workflow file for this run

name: Run unit tests
on:
push:
workflow_dispatch:
jobs:
RunTests-MacOSX-x86-64:
runs-on: macos-latest
env:
WOLFRAM_SYSTEM_ID: MacOSX-x86-64
WOLFRAMENGINE_CACHE_KEY: WolframEngine-A
WOLFRAMENGINE_INSTALLATION_DIRECTORY: "/Applications/Wolfram Engine.app"
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Cache/restore Wolfram Engine install
id: cache-restore
uses: actions/cache@v3
with:
path: ${{ env.WOLFRAMENGINE_INSTALLATION_DIRECTORY }}
key: wolframengine-${{ env.WOLFRAM_SYSTEM_ID }}-${{ env.WOLFRAMENGINE_CACHE_KEY }}
- name: Install Wolfram Engine
if: steps.cache-restore.outputs.cache-hit != 'true'
run: |
echo 'Installing Wolfram Engine...'
brew install --cask wolfram-engine
echo 'Installed Wolfram Engine.'
- name: Run unit tests
env:
WOLFRAMENGINE_EXECUTABLES_DIRECTORY: "${{ env.WOLFRAMENGINE_INSTALLATION_DIRECTORY }}/Contents/Resources/Wolfram Player.app/Contents/MacOS"
WOLFRAMSCRIPT_ENTITLEMENTID: ${{ secrets.WOLFRAM_LICENSE_ENTITLEMENT_ID }}
WOLFRAMSCRIPT_KERNELPATH: "${{ env.WOLFRAMENGINE_INSTALLATION_DIRECTORY }}/Contents/MacOS/WolframKernel"
run: |
export PATH="${{ env.WOLFRAMENGINE_EXECUTABLES_DIRECTORY }}:$PATH"
wolframscript -debug -verbose -script ./Tests/AllTests.wls
- name: Produce test report
id: testreport
uses: dorny/test-reporter@v1
if: always()
with:
name: Unit tests
path: TestReport.xml
reporter: jest-junit
fail-on-error: true
- name: Extract branch name
if: always()
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_OUTPUT
id: extract_branch
- name: Checkout gh-pages branch
uses: actions/checkout@v3
if: always()
with:
ref: gh-pages
path: gh-pages
- name: Generate the badge SVG image
uses: emibcn/[email protected]
id: badge
if: always()
with:
label: 'tests'
status: "${{ steps.testreport.outputs.passed }} passed, ${{ steps.testreport.outputs.failed }} failed, ${{ steps.testreport.outputs.skipped }} skipped"
color: ${{
steps.testreport.outputs.failed == 0 && 'green' ||
steps.testreport.outputs.failed > 0 && 'red' ||
'yellow' }}
path: gh-pages/testresult.svg
- name: Commit badge
if: always()
env:
BRANCH: ${{ steps.extract_branch.outputs.branch }}
FILE: 'testresult.svg'
working-directory: ./gh-pages
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
mkdir -p "badges/${BRANCH}"
mv "${FILE}" "badges/${BRANCH}"
git add "badges/${BRANCH}/${FILE}"
git commit -m "Add/Update badge" || true
- name: Push badge commit
uses: ad-m/github-push-action@master
if: always()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
directory: gh-pages