Skip to content

Commit 69c2f79

Browse files
authored
Merge pull request #900 from nextcloud/ci/add-oracle
Add OCI ci and make tests not silently failing
2 parents c3012fc + 583af2a commit 69c2f79

13 files changed

Lines changed: 1049 additions & 904 deletions

.github/workflows/phpunit.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,64 @@ jobs:
200200
# - name: PHPUnit integration
201201
# working-directory: apps/${{ env.APP_NAME }}
202202
# run: ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml
203+
204+
oci:
205+
runs-on: ubuntu-latest
206+
207+
strategy:
208+
# do not stop on another job's failure
209+
fail-fast: false
210+
matrix:
211+
php-versions: ['7.4']
212+
databases: ['oci']
213+
214+
name: php${{ matrix.php-versions }}-${{ matrix.databases }}
215+
216+
services:
217+
oracle:
218+
image: deepdiver/docker-oracle-xe-11g # "wnameless/oracle-xe-11g-r2"
219+
ports:
220+
- "1521:1521"
221+
222+
steps:
223+
- name: Checkout server
224+
uses: actions/checkout@v2
225+
with:
226+
repository: nextcloud/server
227+
ref: ${{ env.GITHUB_BASE_REF }}
228+
229+
- name: Checkout submodules
230+
shell: bash
231+
run: |
232+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
233+
git submodule sync --recursive
234+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
235+
236+
- name: Checkout app
237+
uses: actions/checkout@v2
238+
with:
239+
path: apps/${{ env.APP_NAME }}
240+
241+
- name: Set up php ${{ matrix.php-versions }}
242+
uses: shivammathur/setup-php@v2
243+
with:
244+
php-version: "${{ matrix.php-versions }}"
245+
extensions: mbstring, iconv, fileinfo, intl, oci8
246+
tools: phpunit:8.5.2
247+
coverage: none
248+
249+
- name: Set up PHPUnit
250+
working-directory: apps/${{ env.APP_NAME }}
251+
run: composer i
252+
253+
- name: Set up Nextcloud
254+
run: |
255+
mkdir data
256+
./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin
257+
php -f index.php
258+
./occ app:enable --force ${{ env.APP_NAME }}
259+
php -S localhost:8080 &
260+
261+
- name: PHPUnit
262+
working-directory: apps/${{ env.APP_NAME }}/tests
263+
run: ../vendor/phpunit/phpunit/phpunit -c phpunit.xml

lib/Db/CircleRequestBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public function getItemFromRequest(CoreQueryBuilder $qb): Circle {
112112
$circle = $qb->asItem(Circle::class);
113113
} catch (RowNotFoundException $e) {
114114
throw new CircleNotFoundException('Circle not found');
115+
} catch (\Exception $e) {
116+
throw new \Exception($qb->getSQL());
115117
}
116118

117119
return $circle;

lib/Db/CoreQueryBuilder.php

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,29 @@ class CoreQueryBuilder extends ExtendedQueryBuilder {
5656
use TArrayTools;
5757

5858

59-
public const SINGLE = 'single';
60-
public const CIRCLE = 'circle';
61-
public const MEMBER = 'member';
62-
public const MEMBER_COUNT = 'membercount';
63-
public const OWNER = 'owner';
64-
public const FEDERATED_EVENT = 'federatedevent';
65-
public const REMOTE = 'remote';
66-
public const BASED_ON = 'basedon';
67-
public const INITIATOR = 'initiator';
68-
public const DIRECT_INITIATOR = 'initiatordirect';
69-
public const MEMBERSHIPS = 'memberships';
70-
public const CONFIG = 'config';
71-
public const UPSTREAM_MEMBERSHIPS = 'upstreammemberships';
72-
public const INHERITANCE_FROM = 'inheritancefrom';
73-
public const INHERITED_BY = 'inheritedby';
74-
public const INVITED_BY = 'invitedby';
75-
public const MOUNT = 'mount';
76-
public const MOUNTPOINT = 'mountpoint';
77-
public const SHARE = 'share';
78-
public const FILE_CACHE = 'filecache';
79-
public const STORAGES = 'storages';
80-
public const TOKEN = 'token';
81-
public const OPTIONS = 'options';
82-
public const HELPER = 'circleshelper';
59+
public const SINGLE = 'cs';
60+
public const CIRCLE = 'cc';
61+
public const MEMBER = 'mm';
62+
public const OWNER = 'wn';
63+
public const FEDERATED_EVENT = 'ev';
64+
public const REMOTE = 'rm';
65+
public const BASED_ON = 'on';
66+
public const INITIATOR = 'in';
67+
public const DIRECT_INITIATOR = 'di';
68+
public const MEMBERSHIPS = 'ms';
69+
public const CONFIG = 'cf';
70+
public const UPSTREAM_MEMBERSHIPS = 'up';
71+
public const INHERITANCE_FROM = 'ih';
72+
public const INHERITED_BY = 'by';
73+
public const INVITED_BY = 'nv';
74+
public const MOUNT = 'mo';
75+
public const MOUNTPOINT = 'mp';
76+
public const SHARE = 'sh';
77+
public const FILE_CACHE = 'fc';
78+
public const STORAGES = 'st';
79+
public const TOKEN = 'tk';
80+
public const OPTIONS = 'pt';
81+
public const HELPER = 'hp';
8382

8483

8584
public static $SQL_PATH = [
@@ -90,7 +89,6 @@ class CoreQueryBuilder extends ExtendedQueryBuilder {
9089
self::OPTIONS => [
9190
],
9291
self::MEMBER,
93-
self::MEMBER_COUNT,
9492
self::OWNER => [
9593
self::BASED_ON
9694
],

lib/Migration/Version0023Date20211216113101.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,4 @@ class Version0023Date20211216113101 extends SimpleMigrationStep {
4747
*/
4848
public function __construct(IDBConnection $connection) {
4949
}
50-
5150
}

lib/Migration/Version0024Date20220203123901.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
6969
$table = $schema->getTable('circles_token');
7070
$table->changeColumn(
7171
'password', [
72-
'length' => 127
73-
]
72+
'length' => 127
73+
]
7474
);
7575
}
7676

@@ -105,5 +105,4 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
105105

106106
return $schema;
107107
}
108-
109108
}

lib/Migration/Version0024Date20220203123902.php

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,67 +64,66 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
6464
$table = $schema->createTable('circles_event');
6565
$table->addColumn(
6666
'token', 'string', [
67-
'notnull' => false,
68-
'length' => 63,
69-
]
67+
'notnull' => false,
68+
'length' => 63,
69+
]
7070
);
7171
$table->addColumn(
7272
'event', 'text', [
73-
'notnull' => false
74-
]
73+
'notnull' => false
74+
]
7575
);
7676
$table->addColumn(
7777
'result', 'text', [
78-
'notnull' => false
79-
]
78+
'notnull' => false
79+
]
8080
);
8181
$table->addColumn(
8282
'instance', 'string', [
83-
'length' => 255,
84-
'notnull' => false
85-
]
83+
'length' => 255,
84+
'notnull' => false
85+
]
8686
);
8787
$table->addColumn(
8888
'interface', 'integer', [
89-
'notnull' => true,
90-
'length' => 1,
91-
'default' => 0
92-
]
89+
'notnull' => true,
90+
'length' => 1,
91+
'default' => 0
92+
]
9393
);
9494
$table->addColumn(
9595
'severity', 'integer', [
96-
'length' => 3,
97-
'notnull' => false
98-
]
96+
'length' => 3,
97+
'notnull' => false
98+
]
9999
);
100100
$table->addColumn(
101101
'retry', 'integer', [
102-
'length' => 3,
103-
'notnull' => false
104-
]
102+
'length' => 3,
103+
'notnull' => false
104+
]
105105
);
106106
$table->addColumn(
107107
'status', 'integer', [
108-
'length' => 3,
109-
'notnull' => false
110-
]
108+
'length' => 3,
109+
'notnull' => false
110+
]
111111
);
112112
$table->addColumn(
113113
'updated', 'datetime', [
114-
'notnull' => false,
115-
]
114+
'notnull' => false,
115+
]
116116
);
117117
$table->addColumn(
118118
'creation', 'bigint', [
119-
'length' => 14,
120-
'notnull' => false
121-
]
119+
'length' => 14,
120+
'notnull' => false
121+
]
122122
);
123123

124124
$table->setPrimaryKey(['token', 'instance']);
125125
}
126126

127127
return $schema;
128128
}
129-
130129
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
6+
/**
7+
* Circles - Bring cloud-users closer together.
8+
*
9+
* This file is licensed under the Affero General Public License version 3 or
10+
* later. See the COPYING file.
11+
*
12+
* @author Maxence Lange <maxence@artificial-owl.com>
13+
* @copyright 2022
14+
* @license GNU AGPL version 3 or any later version
15+
*
16+
* This program is free software: you can redistribute it and/or modify
17+
* it under the terms of the GNU Affero General Public License as
18+
* published by the Free Software Foundation, either version 3 of the
19+
* License, or (at your option) any later version.
20+
*
21+
* This program is distributed in the hope that it will be useful,
22+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
23+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24+
* GNU Affero General Public License for more details.
25+
*
26+
* You should have received a copy of the GNU Affero General Public License
27+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
28+
*
29+
*/
30+
31+
32+
namespace OCA\Circles\Migration;
33+
34+
use Closure;
35+
use Doctrine\DBAL\Schema\SchemaException;
36+
use OCP\DB\ISchemaWrapper;
37+
use OCP\Migration\IOutput;
38+
use OCP\Migration\SimpleMigrationStep;
39+
40+
class Version0024Date20220317190331 extends SimpleMigrationStep {
41+
42+
/**
43+
* @param IOutput $output
44+
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
45+
* @param array $options
46+
*
47+
* @return null|ISchemaWrapper
48+
* @throws SchemaException
49+
*/
50+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
51+
/** @var ISchemaWrapper $schema */
52+
$schema = $schemaClosure();
53+
54+
if ($schema->hasTable('circles_membership')) {
55+
$table = $schema->getTable('circles_membership');
56+
if (!$table->hasPrimaryKey()) {
57+
$indexes = $table->getIndexes();
58+
// conflict in Oracle with existing unique index, duplicate of primaryKey.
59+
foreach ($indexes as $index) {
60+
if ($index->isUnique()) {
61+
$table->dropIndex($index->getName());
62+
}
63+
}
64+
$table->setPrimaryKey(['single_id', 'circle_id']);
65+
}
66+
}
67+
68+
return $schema;
69+
}
70+
}

0 commit comments

Comments
 (0)