Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cypress #1479

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 98 additions & 79 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,103 @@ name: CI
on: [push, pull_request, workflow_dispatch]

jobs:
build-test:
runs-on: ubuntu-latest
permissions:
packages: write
timeout-minutes: 10
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php_version: ["8.0", "8.1"]
experimental: [false]
include:
- php_version: "8.2"
experimental: true
# build-test:
# runs-on: ubuntu-latest
# permissions:
# packages: write
# timeout-minutes: 10
# continue-on-error: ${{ matrix.experimental }}
# strategy:
# fail-fast: false
# matrix:
# php_version: ["8.0", "8.1"]
# experimental: [false]
# include:
# - php_version: "8.2"
# experimental: true
#
# steps:
# - name: Check out repository code
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
#
# - name: Cache Fuseki installation
# uses: actions/cache@v3
# with:
# path: tests/apache-jena-fuseki-*
# key: fuseki-${{ hashFiles('tests/init_fuseki.sh') }}
#
# - name: Start up Fuseki
# run: cd tests; sh ./init_fuseki.sh
#
# - name: Cache Composer dependencies
# uses: actions/cache@v3
# with:
# path: |
# /tmp/composer-cache
# vendor
# components
# key: ${{ runner.os }}-php${{ matrix.php_version}}-skosmos3-${{ hashFiles('**/composer.json') }}
# restore-keys: |
# ${{ runner.os }}-php${{ matrix.php_version}}-skosmos3-
#
# - name: Install Composer dependencies
# uses: php-actions/composer@v6
# with:
# php_version: ${{ matrix.php_version }}
# php_extensions: gettext intl xsl pcov
#
# - name: Install Node
# uses: actions/setup-node@v3
# with:
# node-version: 16.x
#
# - name: Install JavaScript dependencies
# run: npm install
#
# - name: Check PHP code style
# run: ./vendor/bin/php-cs-fixer fix src --diff --dry-run
#
# - name: Check JavaScript code style
# run: cd resource/js; npx standard *.js
#
# - name: Run PHPUnit tests
# uses: php-actions/phpunit@v3
# env:
# LANGUAGE: fr
# with:
# version: 9.5
# php_version: ${{ matrix.php_version }}
# php_extensions: gettext intl xsl pcov
# memory_limit: 512M
# configuration: phpunit.xml
#
# - name: Publish code coverage to Code Climate
# uses: paambaati/[email protected]
# env:
# CC_TEST_REPORTER_ID: fb98170a5c7ea9cc2bbab19ff26268335e6a11a4f8267ca935e5e8ff4624886c
# with:
# prefix: /app
#
# - name: Publish code coverage to Codecov
# uses: codecov/codecov-action@v3
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabling just to run CI a bit faster. Will add it back later.


cypress-run:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Cache Fuseki installation
uses: actions/cache@v3
with:
path: tests/apache-jena-fuseki-*
key: fuseki-${{ hashFiles('tests/init_fuseki.sh') }}

- name: Start up Fuseki
run: cd tests; sh ./init_fuseki.sh

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: |
/tmp/composer-cache
vendor
components
key: ${{ runner.os }}-php${{ matrix.php_version}}-skosmos3-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php${{ matrix.php_version}}-skosmos3-

- name: Install Composer dependencies
uses: php-actions/composer@v6
with:
php_version: ${{ matrix.php_version }}
php_extensions: gettext intl xsl pcov

- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Install JavaScript dependencies
run: npm install

- name: Check PHP code style
run: ./vendor/bin/php-cs-fixer fix src --diff --dry-run

- name: Check JavaScript code style
run: cd resource/js; npx standard *.js

- name: Run PHPUnit tests
uses: php-actions/phpunit@v3
env:
LANGUAGE: fr
with:
version: 9.5
php_version: ${{ matrix.php_version }}
php_extensions: gettext intl xsl pcov
memory_limit: 512M
configuration: phpunit.xml

- name: Publish code coverage to Code Climate
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: fb98170a5c7ea9cc2bbab19ff26268335e6a11a4f8267ca935e5e8ff4624886c
with:
prefix: /app

- name: Publish code coverage to Codecov
uses: codecov/codecov-action@v3
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
cache: yarn
- name: Install
run: yarn install
- name: Start Skosmos
run: cd dockerfiles && docker compose up -d
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here before we run the tests, we can have a step that loads datasets, if necessary.

Startup of Skosmos is taking ~2.5 minutes on GH Actions with Docker Compose. So the overall execution for Cypress is quite good for now.

- name: Test
run: yarn run test:e2e
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost/Skosmos',
baseUrl: 'http://localhost:9090/',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can pass that via command line too. If most devs will use their own localhost/Skosmos instead of docker or 9090, that might make more sense. Changed here as that was the simplest to get the Cypress tests executed.

setupNodeEvents(on, config) {
// implement node event listeners here
},
Expand Down
26 changes: 17 additions & 9 deletions dockerfiles/README.md
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore these dockerfiles modified here. I just cherry-picked from #1477

Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,27 @@ without Docker Compose, you can try the following command before loading your
vocabulary data. It starts a container in the same way our other example with
the `docker-compose` command.

docker run --name fuseki -ti --rm \
--env "ADMIN_PASSWORD=admin" --env "JVM_ARGS=-Xmx2g" \
-p 3030:3030 \
--mount type=bind,src=$(pwd)/config/skosmos.ttl,dst=/fuseki/configuration/skosmos.ttl \
stain/jena-fuseki
export JENA_4_VERSION=4.8.0

docker build -t jena-fuseki:$JENA_4_VERSION \
--build-arg JENA_VERSION=$JENA_4_VERSION \
--no-cache dockerfiles/jena-fuseki2-docker

docker run --name fuseki --rm -ti \
-v $(pwd)/config/skosmos.ttl:/fuseki/skosmos.ttl \
-e "JAVA_OPTIONS=-Xmx2g -Xms1g" \
-p 3030:3030 \
jena-fuseki:$JENA_4_VERSION \
--config=/fuseki/skosmos.ttl

curl -XPOST http://localhost:3030/skosmos/query -d "query=SELECT ?a WHERE { ?a ?b ?c }"

## Running with docker-compose

The `docker-compose` provided configuration will prepare three containers.
The first one called `skosmos-fuseki`, which uses the `stain/jena-fuseki`
image for Jena, and starts a container with 2 GB of memory and `admin` as
the user and password. The `docker-compose` service name of this container
is `fuseki`.
The first one called `skosmos-fuseki`, which uses the Apache Jena
image for Fuseki, and starts a container with 2 GB of memory. The
`docker-compose` service name of this container is `fuseki`.

The second container is the `fuseki-cache`, a Varnish Cache container. It sits
between the `skosmos-fuseki` and the `skosmos-web` (more on this below). The
Expand Down
92 changes: 40 additions & 52 deletions dockerfiles/config/skosmos.ttl
Original file line number Diff line number Diff line change
@@ -1,85 +1,73 @@
@prefix : <http://base/#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix tdb2: <http://jena.apache.org/2016/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix tdb2: <http://jena.apache.org/2016/tdb#> .
@prefix text: <http://jena.apache.org/text#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .

ja:DatasetTxnMem rdfs:subClassOf ja:RDFDataset .
ja:MemoryDataset rdfs:subClassOf ja:RDFDataset .
ja:RDFDatasetOne rdfs:subClassOf ja:RDFDataset .
ja:RDFDatasetSink rdfs:subClassOf ja:RDFDataset .
ja:RDFDatasetZero rdfs:subClassOf ja:RDFDataset .

tdb2:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb2:DatasetTDB2 rdfs:subClassOf ja:RDFDataset .

tdb2:GraphTDB rdfs:subClassOf ja:Model .
tdb2:GraphTDB2 rdfs:subClassOf ja:Model .

<http://jena.hpl.hp.com/2008/tdb#DatasetTDB>
rdfs:subClassOf ja:RDFDataset .

<http://jena.hpl.hp.com/2008/tdb#GraphTDB>
rdfs:subClassOf ja:Model .

text:TextDataset
rdfs:subClassOf ja:RDFDataset .
[] rdf:type fuseki:Server ;
fuseki:services (
:skosmos_service
)
.

:service_tdb_all a fuseki:Service ;
rdfs:label "TDB2+text skosmos" ;
fuseki:dataset :text_dataset ;
fuseki:name "skosmos" ;
fuseki:serviceQuery "query" , "" , "sparql" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:serviceReadQuads "" ;
:skosmos_service rdf:type fuseki:Service ;
rdfs:label "TDB2+text skosmos" ;
fuseki:name "skosmos" ;
fuseki:serviceQuery "query" , "" , "sparql" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:serviceReadQuads "" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceReadWriteQuads "" ;
fuseki:serviceUpdate "" , "update" ;
fuseki:serviceUpload "upload" .
fuseki:serviceReadWriteQuads "" ;
fuseki:serviceUpdate "" , "update" ;
fuseki:serviceUpload "upload" ;
fuseki:dataset :text_dataset
.

:text_dataset a text:TextDataset ;
text:dataset :tdb_dataset_readwrite ;
text:index :index_lucene .
:text_dataset rdf:type text:TextDataset ;
text:dataset :tdb_dataset_readwrite ;
text:index <#indexLucene>
.

:tdb_dataset_readwrite
a tdb2:DatasetTDB2 ;
# tdb2:unionDefaultGraph true ;
tdb2:location "/fuseki/databases/skosmos" .
:tdb_dataset_readwrite rdf:type tdb2:DatasetTDB2 ;
tdb2:location "/fuseki/databases/skosmos" ;
# tdb2:unionDefaultGraph true ;
.

:index_lucene a text:TextIndexLucene ;
text:directory <file:/fuseki/databases/skosmos/text> ;
text:entityMap :entity_map ;
text:storeValues true .
<#indexLucene> rdf:type text:TextIndexLucene ;
text:directory <file:/fuseki/databases/skosmos/text> ;
text:entityMap <#entMap> ;
text:storeValues true
.

# Text index configuration for Skosmos
:entity_map a text:EntityMap ;
text:entityField "uri" ;
text:graphField "graph" ;
<#entMap> rdf:type text:EntityMap ;
text:defaultField "pref" ;
text:entityField "uri" ;
text:uidField "uid" ;
text:langField "lang" ;
text:graphField "graph" ;
text:map (
# skos:prefLabel
[ text:field "pref" ;
text:predicate skos:prefLabel ;
text:analyzer [ a text:LowerCaseKeywordAnalyzer ]
text:analyzer [ rdf:type text:LowerCaseKeywordAnalyzer ]
]
# skos:altLabel
[ text:field "alt" ;
text:predicate skos:altLabel ;
text:analyzer [ a text:LowerCaseKeywordAnalyzer ]
text:analyzer [ rdf:type text:LowerCaseKeywordAnalyzer ]
]
# skos:hiddenLabel
[ text:field "hidden" ;
text:predicate skos:hiddenLabel ;
text:analyzer [ a text:LowerCaseKeywordAnalyzer ]
text:analyzer [ rdf:type text:LowerCaseKeywordAnalyzer ]
]
# skos:notation
[ text:field "notation" ;
text:predicate skos:notation ;
text:analyzer [ a text:LowerCaseKeywordAnalyzer ]
text:analyzer [ rdf:type text:LowerCaseKeywordAnalyzer ]
]
) .
)
.
Loading