Skip to content

Commit

Permalink
Merge pull request #200 from UUDigitalHumanitieslab/feature/ci
Browse files Browse the repository at this point in the history
Tests using GitHub Actions
  • Loading branch information
tijmenbaarda authored Aug 14, 2024
2 parents ad458a8 + c2fdc41 commit 112b3e0
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 5 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Tests

on:
workflow_dispatch:
push:
branches:
- 'develop'
- 'main'
- 'release/**'
- 'feature/ci'
pull_request:
branches:
- 'develop'
- 'main'

jobs:
test-backend:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.12"]

services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: edpop
POSTGRES_PASSWORD: edpop
POSTGRES_USER: edpopuser
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Download and run Blazegraph
run: |
wget https://github.com/blazegraph/database/releases/download/BLAZEGRAPH_2_1_6_RC/blazegraph.jar
java -jar blazegraph.jar &
sleep 5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install Python packages
run: |
python -m pip install --upgrade pip
pip install -r backend/requirements.txt
pip install -r backend/requirements-test.txt
- name: Test with pytest
run: |
cd backend && pytest
test-frontend:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
cache-dependency-path: './frontend/package-lock.json'
- name: Install frontend dependencies
run: |
cd frontend
npm ci
- name: Run frontend tests
run: |
cd frontend
npm run test
28 changes: 23 additions & 5 deletions frontend/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Generated on Wed Oct 05 2022 17:04:26 GMT+0200 (Central European Summer Time)

module.exports = function(config) {
config.set({
const configuration = {

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
Expand Down Expand Up @@ -93,14 +93,32 @@ module.exports = function(config) {

// start these browsers
// available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher
browsers: [],
browsers: ['ChromeHeadless'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser instances should be started simultaneously
concurrency: Infinity
})
}
concurrency: Infinity,

customLaunchers: {
ChromeHeadless: {
base: 'Chrome',
flags: [
'--headless',
'--remote-debugging-port=9222',
],
}
},

};

if (process.env.CI) {
configuration.browsers = ['ChromeHeadless'];
configuration.singleRun = true;
}

config.set(configuration);
};
49 changes: 49 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"bootstrap": "^3.4.1",
"jquery": "^3.6.1",
"jscookie": "^1.1.0",
"karma-chrome-launcher": "^3.2.0",
"lodash": "^4.17.21",
"popper.js": "^1.16.1",
"select2": "^4.0.13",
Expand Down

0 comments on commit 112b3e0

Please sign in to comment.