A GitHub Action for running unit tests in a Kscript project
This action will run the unit tests in a Kscript project using another helper kscript file for running tests from the command line without IntelliJ.
Required The path to the *.kts
file under test in your Github Project.
The kscript version to be used in the action.
Default value: '3.1.0'
The JDK to be used in the action
Default value: '11.0.10.hs-adpt'
The Kotlin version to be used in the action
Default value: '1.4.31'
Set to 'false'
to not fail the process if a unit test were to fail and a unit test parser is to be used such as the JUnit report Github action. The unit test results will be available to parse from the build/
folder.
Default value: 'true'
The kscript-action depends on the actions/checkout as this will checkout out your project into a repository the script is looking for to run the tests from.
There is also an example kscript project that showcases this action for any pull requests made against the main
branch.
on:
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
name: Run tests in kscript project
steps:
- name: Checkout the project into the container
uses: actions/checkout@v2.3.4
- name: Run testing script to generate mock IDEA project and run gradle test
id: hello
uses: plusmobileapps/kscript-action@v1.2
with:
kts-file: 'star-wars-char-enum.kts'
kscript-version: '3.0.2'
When using a unit test parser in the workflow such as JUnit report Github action, use the fail-on-failure
parameter to not fail your workflow if a test were to fail. This will give the unit test parser a chance actually attempt to parse the unit tests.
jobs:
test:
runs-on: ubuntu-latest
name: Run tests in kscript project
steps:
- name: Checkout the project into the container
uses: actions/checkout@v2.3.4
- name: Run testing script to generate mock IDEA project and run gradle test
id: hello
uses: plusmobileapps/kscript-action@v1.2
with:
kts-file: 'star-wars-char-enum.kts'
kscript-version: '3.0.2'
kotlin-version: '1.4.21'
fail-on-failure: 'false'
- name: Publish Test Report
uses: mikepenz/action-junit-report@v2
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
fail_on_failure: 'true'
require_tests: 'true'