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

Switch to GitHub Actions CI #1163

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1251f0c
Remove Travis CI configuration file (not needed for GitHub Actions)
osma May 20, 2021
f44f46b
add barebones GitHub Actions CI configuration
osma May 20, 2021
d6d846a
Add required PHP extensions
osma May 20, 2021
ee6f13b
Declare PHP extensions already for Composer step
osma May 20, 2021
1c15140
Try to install Fuseki under GH Actions
osma May 20, 2021
6a4c421
Use PHPUnit 8.5.x under GH Actions
osma May 20, 2021
c902687
specify PHP version & extensions also for PHPUnit step
osma May 20, 2021
8b44e40
add --quiet option to fuseki wget command, to avoid spamming output
osma May 20, 2021
e750e6e
Use wget in non-verbose mode, so errors are still printed (instead of…
osma May 20, 2021
9866213
reduce verbosity of tar command that uncompresses fuseki
osma May 20, 2021
e0558f5
Use Fuseki as a service container
osma May 20, 2021
85b8962
fix ci.yml syntax
osma May 20, 2021
75b49fa
Add test script/command to composer.json for use by CI action
osma May 20, 2021
d1fd2b6
avoid using container based php-actions
osma May 20, 2021
a484aae
drop strict composer validation as it won't pass anyway
osma May 20, 2021
701c1f2
Support setting SPARQL endpoint URL via environment variable
osma May 25, 2021
71b21f6
ensure the SKOSMOS_SPARQL_ENDPOINT envvar is always set when running …
osma May 25, 2021
bc51d96
Merge branch 'feature-sparql-endpoint-envvar' into issue1147-github-a…
osma May 25, 2021
626b926
Revert "drop strict composer validation as it won't pass anyway"
osma May 25, 2021
19e0aec
Revert "avoid using container based php-actions"
osma May 25, 2021
9d5cb14
specify Fuseki endpoint URL via environment variable
osma May 25, 2021
97e1bc8
Use osma/phpunit action (forked from php-actions/phpunit) with host n…
osma May 25, 2021
c60703e
fix ci.yml syntax for ports (doh)
osma May 25, 2021
e5bb8f7
fix syntax again
osma May 25, 2021
cc5806f
use the correct version of osma/phpunit
osma May 25, 2021
d778877
use v2-network-host
osma May 25, 2021
2974297
Use osma/phpunit@v2-network-host-debug for more debugging info
osma May 25, 2021
57b1987
use the init_fuseki.sh script instead of a service container
osma May 25, 2021
6b81cb8
run tests in parallel on PHP versions 7.2, 7.3 and 7.4
osma May 26, 2021
7178089
Cache Composer dependencies to speed up builds
osma May 26, 2021
be59bdb
Different way of caching Composer dependencies (we don't have compose…
osma May 26, 2021
3f9ce1b
fix syntax
osma May 26, 2021
37170ec
Attempt to cache Fuseki installation
osma May 26, 2021
94ed814
Enable PCOV extension for code coverage information
osma May 26, 2021
b2fdf68
disable fail-fast to avoid one failed job canceling the others
osma May 26, 2021
fe3a40f
Increase memory_limit to 512M for PHPUnit tests (128M isn't enough wi…
osma May 26, 2021
b2a3f53
publish coverage report to Code Climate
osma May 26, 2021
fe791af
set a prefix for the Code Climate reporter step to fix(?) path issues
osma May 26, 2021
9138e3c
enable debugging on codeclimate reporter and try to fix path issue w/…
osma May 26, 2021
92dc7f6
Test if prefix /app would help solve Code Climate path issue
osma May 26, 2021
100a20e
Disable Code Climate debug since it's now working
osma May 26, 2021
b614155
Publish code coverage to Codecov
osma May 26, 2021
33408f7
Disable verbose setting for Codecov as it's now working
osma May 26, 2021
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
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

on: [push]

jobs:
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
php_version: [7.2, 7.3, 7.4]
fail-fast: false

steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Cache Fuseki installation
uses: actions/cache@v2
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@v2
with:
path: |
/tmp/composer-cache
vendor
key: ${{ runner.os }}-php${{ matrix.php_version}}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php${{ matrix.php_version}}-

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

- name: Run PHPUnit tests
uses: osma/phpunit@v2-network-host-debug
with:
version: 8.5
php_version: ${{ matrix.php_version }}
php_extensions: gettext intl xsl pcov
memory_limit: 512M

- name: Publish code coverage to Code Climate
uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: fb98170a5c7ea9cc2bbab19ff26268335e6a11a4f8267ca935e5e8ff4624886c
with:
prefix: /app

- name: Publish code coverage to Codecov
uses: codecov/codecov-action@v1
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,8 @@
},
"autoload": {
"classmap": ["controller/", "model/", "model/sparql/"]
},
"scripts": {
"test": "vendor/bin/phpunit"
}
}
2 changes: 2 additions & 0 deletions model/GlobalConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ public function getDefaultEndpoint()
$endpoint = $this->resource->get('skosmos:sparqlEndpoint');
if ($endpoint) {
return $endpoint->getUri();
} elseif (getenv('SKOSMOS_SPARQL_ENDPOINT')) {
return getenv('SKOSMOS_SPARQL_ENDPOINT');
} else {
return 'http://localhost:3030/ds/sparql';
}
Expand Down
9 changes: 8 additions & 1 deletion model/Vocabulary.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ public function getConfig()
*/
public function getEndpoint()
{
return $this->resource->get('void:sparqlEndpoint')->getUri();
$endpoint = $this->resource->get('void:sparqlEndpoint');
if ($endpoint) {
return $endpoint->getUri();
} elseif (getenv('SKOSMOS_SPARQL_ENDPOINT')) {
return getenv('SKOSMOS_SPARQL_ENDPOINT');
} else {
return 'http://localhost:3030/ds/sparql';
}
}

/**
Expand Down
43 changes: 22 additions & 21 deletions tests/GenericSparqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@ protected function setUp() : void
$this->vocab = $this->model->getVocabulary('test');
$this->graph = $this->vocab->getGraph();
$this->params = $this->getMockBuilder('ConceptSearchParameters')->disableOriginalConstructor()->getMock();
$this->sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $this->graph, $this->model);
$this->endpoint = getenv('SKOSMOS_SPARQL_ENDPOINT');
$this->sparql = new GenericSparql($this->endpoint, $this->graph, $this->model);
}

/**
* @covers GenericSparql::__construct
*/
public function testConstructor() {
$gs = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $this->graph, $this->model);
$gs = new GenericSparql($this->endpoint, $this->graph, $this->model);
$this->assertInstanceOf('GenericSparql', $gs);
}

/**
* @covers GenericSparql::getGraph
*/
public function testGetGraph() {
$gs = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $this->graph, $this->model);
$gs = new GenericSparql($this->endpoint, $this->graph, $this->model);
$this->assertEquals($this->graph, $gs->getGraph());
}

Expand Down Expand Up @@ -200,7 +201,7 @@ public function testQueryConceptsAlphabeticalLimitAndOffset() {
public function testQualifiedNotationAlphabeticalList() {
$voc = $this->model->getVocabulary('test-qualified-notation');
$res = new EasyRdf\Resource("http://www.w3.org/2004/02/skos/core#notation");
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $voc->getGraph(), $this->model);
$sparql = new GenericSparql($this->endpoint, $voc->getGraph(), $this->model);

$actual = $sparql->queryConceptsAlphabetical("a", "en", null, null, null, false, $res);

Expand Down Expand Up @@ -271,7 +272,7 @@ public function testQualifiedNotationAlphabeticalList() {
public function testQualifiedBroaderAlphabeticalList() {
$voc = $this->model->getVocabulary('test-qualified-broader');
$res = new EasyRdf\Resource("http://www.w3.org/2004/02/skos/core#broader");
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $voc->getGraph(), $this->model);
$sparql = new GenericSparql($this->endpoint, $voc->getGraph(), $this->model);

$actual = $sparql->queryConceptsAlphabetical("a", "en", null, null, null, false, $res);

Expand Down Expand Up @@ -391,7 +392,7 @@ public function testQueryConceptsAlphabeticalFull() {
*/
public function testQueryConceptInfoWithMultipleVocabs()
{
$this->sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', '?graph', $this->model);
$this->sparql = new GenericSparql($this->endpoint, '?graph', $this->model);
$voc2 = $this->model->getVocabulary('test');
$voc3 = $this->model->getVocabulary('dates');
$voc4 = $this->model->getVocabulary('groups');
Expand All @@ -413,7 +414,7 @@ public function testQueryConceptInfoWithMultipleVocabs()
*/
public function testQueryConceptInfoWithAllVocabs()
{
$this->sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', '?graph', $this->model);
$this->sparql = new GenericSparql($this->endpoint, '?graph', $this->model);
$actual = $this->sparql->queryConceptInfo(array('http://www.skosmos.skos/test/ta121', 'http://www.skosmos.skos/groups/ta111'), null, null, 'en');
$this->assertInstanceOf('Concept', $actual[0]);
$this->assertEquals('http://www.skosmos.skos/test/ta121', $actual[0]->getUri());
Expand Down Expand Up @@ -490,7 +491,7 @@ public function testQueryConceptScheme()
{
$actual = $this->sparql->queryConceptScheme('http://www.skosmos.skos/test/conceptscheme');
$this->assertInstanceOf('EasyRdf\Graph', $actual);
$this->assertEquals('http://localhost:13030/skosmos-test/sparql', $actual->getUri());
$this->assertEquals($this->endpoint, $actual->getUri());
}

/**
Expand All @@ -514,7 +515,7 @@ public function testQueryConceptSchemes()
*/
public function testQueryConceptSchemesSubject()
{
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', 'http://www.skosmos.skos/test-concept-schemes/', $this->model);
$sparql = new GenericSparql($this->endpoint, 'http://www.skosmos.skos/test-concept-schemes/', $this->model);

$actual = $sparql->queryConceptSchemes('en');
$expected = array(
Expand Down Expand Up @@ -566,7 +567,7 @@ public function testQueryConceptsMultipleVocabs()
$voc2 = $this->model->getVocabulary('groups');
$this->params->method('getSearchTerm')->will($this->returnValue('Carp'));
$this->params->method('getVocabs')->will($this->returnValue(array($voc, $voc2)));
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', '?graph', $this->model);
$sparql = new GenericSparql($this->endpoint, '?graph', $this->model);
$actual = $sparql->queryConcepts(array($voc, $voc2), null, null, $this->params);
$this->assertEquals(2, sizeof($actual));
$this->assertEquals('http://www.skosmos.skos/groups/ta112', $actual[0]['uri']);
Expand All @@ -589,7 +590,7 @@ public function testQueryConceptsMultipleSchemes()
// returns 3 concepts without the scheme limit, and only 2 with the scheme limit below
$this->params->method('getSearchTerm')->will($this->returnValue('concept*'));
$this->params->method('getSchemeLimit')->will($this->returnValue(array('http://www.skosmos.skos/multiple-schemes/cs1', 'http://www.skosmos.skos/multiple-schemes/cs2')));
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', 'http://www.skosmos.skos/multiple-schemes/', $this->model);
$sparql = new GenericSparql($this->endpoint, 'http://www.skosmos.skos/multiple-schemes/', $this->model);
$actual = $sparql->queryConcepts(array($voc), null, null, $this->params);
$this->assertEquals(2, sizeof($actual));
$this->assertEquals('http://www.skosmos.skos/multiple-schemes/c1-in-cs1', $actual[0]['uri']);
Expand Down Expand Up @@ -1050,7 +1051,7 @@ public function testListConceptGroups()
{
$voc = $this->model->getVocabulary('groups');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$sparql = new GenericSparql($this->endpoint, $graph, $this->model);
$actual = $sparql->ListConceptGroups('http://www.w3.org/2004/02/skos/core#Collection', 'en');
$expected = array (0 => array ('prefLabel' => 'Fish', 'uri' => 'http://www.skosmos.skos/groups/fish', 'hasMembers' => true, 'childGroups' => array('http://www.skosmos.skos/groups/sub')), 1 => array ('prefLabel' => 'Freshwater fish', 'uri' => 'http://www.skosmos.skos/groups/fresh', 'hasMembers' => true), 2 => array ('prefLabel' => 'Saltwater fish', 'uri' => 'http://www.skosmos.skos/groups/salt', 'hasMembers' => true),3 => array ('prefLabel' => 'Submarine-like fish', 'uri' => 'http://www.skosmos.skos/groups/sub', 'hasMembers' => true));
$this->assertEquals($expected, $actual);
Expand All @@ -1065,7 +1066,7 @@ public function testListConceptGroupContentsExcludingDeprecatedConcept()
{
$voc = $this->model->getVocabulary('groups');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$sparql = new GenericSparql($this->endpoint, $graph, $this->model);
$actual = $sparql->ListConceptGroupContents('http://www.w3.org/2004/02/skos/core#Collection', 'http://www.skosmos.skos/groups/salt', 'en');
$this->assertEquals('http://www.skosmos.skos/groups/ta113', $actual[0]['uri']);
$this->assertEquals(1, sizeof($actual));
Expand All @@ -1080,7 +1081,7 @@ public function testListConceptGroupContentsIncludingDeprecatedConcept()
{
$voc = $this->model->getVocabulary('showDeprecated');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$sparql = new GenericSparql($this->endpoint, $graph, $this->model);
$actual = $sparql->ListConceptGroupContents('http://www.w3.org/2004/02/skos/core#Collection', 'http://www.skosmos.skos/groups/salt', 'en', $voc->getConfig()->getShowDeprecated());
$expected = array (
0 => array (
Expand Down Expand Up @@ -1111,7 +1112,7 @@ public function testQueryChangeList()
{
$voc = $this->model->getVocabulary('changes');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$sparql = new GenericSparql($this->endpoint, $graph, $this->model);
$actual = $sparql->queryChangeList('dc:created', 'en', 0, 10);
$order = array();
foreach($actual as $concept) {
Expand All @@ -1129,7 +1130,7 @@ public function testQueryChangeList()
public function testMalformedDates() {
$voc = $this->model->getVocabulary('test');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$sparql = new GenericSparql($this->endpoint, $graph, $this->model);
$result = $sparql->queryChangeList('dc:modified', 'en', 0, 10);
$uris = array();
foreach($result as $concept) {
Expand All @@ -1146,7 +1147,7 @@ public function testLimitSearchToType()
{
$voc = $this->model->getVocabulary('test');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$sparql = new GenericSparql($this->endpoint, $graph, $this->model);
$this->params->method('getSearchTerm')->will($this->returnValue('*'));
$this->params->method('getTypeLimit')->will($this->returnValue(array('mads:Topic')));
$actual = $this->sparql->queryConcepts(array($voc), null, true, $this->params);
Expand Down Expand Up @@ -1186,7 +1187,7 @@ public function testQueryConceptsWithExtraFields()
*/
public function testQuerySuperProperties()
{
$this->sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', '?graph', $this->model);
$this->sparql = new GenericSparql($this->endpoint, '?graph', $this->model);
$actual = $this->sparql->querySuperProperties('http://example.com/myns#property');
$this->assertEquals(1, sizeof($actual));
$expected = array('http://example.com/myns#superProperty');
Expand All @@ -1202,7 +1203,7 @@ public function testQueryAllConceptLabels()
{
$voc = $this->model->getVocabulary('test');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$sparql = new GenericSparql($this->endpoint, $graph, $this->model);

$actual = $sparql->queryAllConceptLabels('http://www.skosmos.skos/test/ta112', 'en');

Expand All @@ -1224,7 +1225,7 @@ public function testQueryAllConceptLabelsNonexistentConcept()
{
$voc = $this->model->getVocabulary('test');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$sparql = new GenericSparql($this->endpoint, $graph, $this->model);

$actual = $sparql->queryAllConceptLabels('http://www.skosmos.skos/test/notfound', 'en');

Expand All @@ -1240,7 +1241,7 @@ public function testQueryAllConceptLabelsNoPrefLabel()
{
$voc = $this->model->getVocabulary('test');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$sparql = new GenericSparql($this->endpoint, $graph, $this->model);

$actual = $sparql->queryAllConceptLabels('http://www.skosmos.skos/test/ta112', 'sv');

Expand Down
2 changes: 1 addition & 1 deletion tests/GlobalConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function setUp() : void

public function testGetDefaultEndpoint()
{
$this->assertEquals("http://localhost:13030/skosmos-test/sparql", $this->config->getDefaultEndpoint());
$this->assertEquals(getenv('SKOSMOS_SPARQL_ENDPOINT'), $this->config->getDefaultEndpoint());
}

public function testGetDefaultSparqlDialect()
Expand Down
11 changes: 6 additions & 5 deletions tests/JenaTextSparqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ protected function setUp() : void
$this->vocab = $this->model->getVocabulary('test');
$this->graph = $this->vocab->getGraph();
$this->params = $this->getMockBuilder('ConceptSearchParameters')->disableOriginalConstructor()->getMock();
$this->sparql = new JenaTextSparql('http://localhost:13030/skosmos-test/sparql', $this->graph, $this->model);
$this->endpoint = getenv('SKOSMOS_SPARQL_ENDPOINT');
$this->sparql = new JenaTextSparql($this->endpoint, $this->graph, $this->model);
}

/**
* @covers JenaTextSparql::__construct
*/
public function testConstructor() {
$gs = new JenaTextSparql('http://localhost:13030/skosmos-test/sparql', $this->graph, $this->model);
$gs = new JenaTextSparql($this->endpoint, $this->graph, $this->model);
$this->assertInstanceOf('JenaTextSparql', $gs);
}

Expand Down Expand Up @@ -117,7 +118,7 @@ public function testQueryConceptsAlphabeticalLimitAndOffset() {
public function testQualifiedNotationAlphabeticalList() {
$voc = $this->model->getVocabulary('test-qualified-notation');
$res = new EasyRdf\Resource("http://www.w3.org/2004/02/skos/core#notation");
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $voc->getGraph(), $this->model);
$sparql = new GenericSparql($this->endpoint, $voc->getGraph(), $this->model);

$actual = $sparql->queryConceptsAlphabetical("a", "en", null, null, null, false, $res);

Expand Down Expand Up @@ -187,7 +188,7 @@ public function testQualifiedNotationAlphabeticalList() {
public function testQualifiedBroaderAlphabeticalList() {
$voc = $this->model->getVocabulary('test-qualified-broader');
$res = new EasyRdf\Resource("http://www.w3.org/2004/02/skos/core#broader");
$sparql = new JenaTextSparql('http://localhost:13030/skosmos-test/sparql', $voc->getGraph(), $this->model);
$sparql = new JenaTextSparql($this->endpoint, $voc->getGraph(), $this->model);

$actual = $sparql->queryConceptsAlphabetical("a", "en", null, null, null, false, $res);

Expand Down Expand Up @@ -358,7 +359,7 @@ public function testQueryConceptsDefaultGraph()
public function testQueryConceptsAlphabeticalOrderBy() {
$vocab = $this->model->getVocabulary('collation');
$graph = $vocab->getGraph();
$sparql = new JenaTextSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$sparql = new JenaTextSparql($this->endpoint, $graph, $this->model);
$actual = $sparql->queryConceptsAlphabetical('t', 'fi');
$expected = array (
0 => array (
Expand Down
8 changes: 8 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<?php

// make sure that a SPARQL endpoint is set by an environment variable
$endpoint = getenv('SKOSMOS_SPARQL_ENDPOINT');
if (!$endpoint) {
// default to Fuseki running on localhost:13030 as provided by init_fuseki.sh
putenv('SKOSMOS_SPARQL_ENDPOINT=http://localhost:13030/skosmos-test/sparql');
}

require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/../model/Model.php');
5 changes: 3 additions & 2 deletions tests/init_fuseki.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ fi

if [ ! -f "apache-jena-fuseki-$FUSEKI_VERSION/fuseki-server" ]; then
echo "fuseki server file not found - downloading it"
wget --output-document=fuseki-dist.tar.gz "$fusekiurl"
tar -zxvf fuseki-dist.tar.gz
wget --no-verbose --output-document=fuseki-dist.tar.gz "$fusekiurl"
echo "uncompressing fuseki distribution"
tar -zxf fuseki-dist.tar.gz
fi

cd "apache-jena-fuseki-$FUSEKI_VERSION"
Expand Down
Loading