Skip to content

Run unit tests on pull request #16

Run unit tests on pull request

Run unit tests on pull request #16

name: Run unit tests on pull request
on:
pull_request:
branches: [ 'main' ]
workflow_dispatch:
jobs:
run-unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract statements file
run: |
unzip ./test/statements.nq.zip -d ./test/
- name: Run GraphDB
run: docker compose -f "graph-db/docker-compose.yml" up -d --build
- name: Wait for GraphDB to be ready
run: |
until curl -s http://127.0.0.1:7200/rest/repositories > /dev/null; do
echo "Waiting for GraphDB to start..."
sleep 5
done
- name: Import repository configuration
run: |
curl 'http://127.0.0.1:7200/rest/repositories' \
--header 'Content-Type: multipart/form-data' \
--form 'config=@"./test/config.ttl"'
- name: Import repository data
run: |
curl 'http://127.0.0.1:7200/repositories/artsdata/statements' \
--header 'Content-Type: application/n-quads' \
--data-binary '@./test/statements.nq'
- name: Create index
run: |
for file in ./src/sparql/index/*.sparql; do
curl -X POST -H "Content-Type: application/sparql-update" --data-binary @"$file" "http://localhost:7200/repositories/artsdata/statements"
done
- name: Update env to point to local graphdb
run: |
sed -i 's|^ARTSDATA_ENDPOINT=.*|ARTSDATA_ENDPOINT="http://127.0.0.1:7200/"|' .env
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 16.20.1
- name: Install dependencies
run: npm install
- name: Run unit tests
run: npm test
restrict-merging:
name: restrict-merging
runs-on: ubuntu-latest
needs: run-unit-tests
steps:
- name: Check unit test status
run: |
if [ ${{ needs.run-unit-tests.result }} != 'success' ]; then
exit 1
else
exit 0
fi