2024-04-10 21:25:41 +02:00
name : Run Tests
on :
push :
branches : '*'
pull_request :
branches : '*'
jobs :
2024-04-11 00:42:58 +02:00
vitest :
2024-04-10 21:25:41 +02:00
runs-on : ubuntu-latest
2024-04-25 06:06:29 +02:00
if: > # Conditional to limit runs : checks if it's NOT a push to a branch with an open PR
2024-04-25 05:31:39 +02:00
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name != github.repository
2024-04-10 21:25:41 +02:00
container :
2024-04-10 22:07:30 +02:00
image : refringe/spt-build-node:1.0.7
2024-04-10 21:25:41 +02:00
steps :
2024-04-25 06:06:29 +02:00
- name : Clone
run : |
2024-04-25 07:27:52 +02:00
# For pull request events, checkout using GITHUB_SHA
# For push events, checkout using GITHUB_REF_NAME
if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then
REF=${GITHUB_SHA}
else
REF=${GITHUB_REF_NAME}
fi
2024-04-25 07:34:35 +02:00
rm -rf /workspace/SPT-AKI/Server/current
git clone https://dev.sp-tarkov.com/${{ github.repository }}.git /workspace/SPT-AKI/Server/current
2024-04-25 07:27:52 +02:00
2024-04-25 07:34:35 +02:00
cd /workspace/SPT-AKI/Server/current
2024-04-25 07:27:52 +02:00
git checkout $REF
env :
GITHUB_SHA : ${{ github.sha }}
GITHUB_REF_NAME : ${{ github.ref_name }}
GITHUB_EVENT_NAME : ${{ github.event_name }}
2024-04-25 06:06:29 +02:00
shell : bash
2024-04-25 05:31:39 +02:00
2024-04-25 05:42:17 +02:00
- name : Pull LFS Files
run : |
2024-04-25 07:34:35 +02:00
cd /workspace/SPT-AKI/Server/current && ls -lah
2024-04-25 06:27:18 +02:00
git lfs pull && git lfs ls-files
2024-04-25 05:42:17 +02:00
shell : bash
2024-04-25 05:31:39 +02:00
- name : Cache NPM Dependencies
id : cache-npm-dependencies
uses : actions/cache@v4
with :
2024-04-25 07:34:35 +02:00
path : /workspace/SPT-AKI/Server/current/project/node_modules
key : npm-dependencies-${{ hashFiles('/workspace/SPT-AKI/Server/current/project/package.json') }}
2024-04-25 05:31:39 +02:00
- name : Install NPM Dependencies
if : steps.cache-npm-dependencies.outputs.cache-hit != 'true'
run : |
2024-04-25 07:34:35 +02:00
cd /workspace/SPT-AKI/Server/current/project
rm -rf /workspace/SPT-AKI/Server/current/project/node_modules
2024-04-25 05:31:39 +02:00
npm install
shell : bash
- name : Run Tests
id : run-tests
run : |
2024-04-25 07:34:35 +02:00
cd /workspace/SPT-AKI/Server/current/project
2024-04-25 05:31:39 +02:00
npm run test
shell : bash
- name : Fix Instructions
if : failure() && steps.run-tests.outcome == 'failure'
run : |
echo -e "Automated tests have failed. This could point to an issue with the committed code, or an updated test that has yet to be updated. Please look into resolving these test failures. The testing suite has a GUI to aid in writing tests. You can launch this by running the following command from within the 'project' directory.\n\nnpm run test:ui\n"
echo -e "A test written today is a bug prevented tomorrow.™"
shell : bash