Skip to content

Commit

Permalink
fix CI tests for unpublished server version
Browse files Browse the repository at this point in the history
  • Loading branch information
korelstar committed Sep 1, 2020
1 parent 5714bcf commit df9cfe9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
mysql -u root -proot -e "GRANT ALL ON nextcloud.* TO 'nextcloud'@'localhost';"
- name: Select Nextcloud server branch
if: matrix.version == 'min'
run: echo "::set-env name=SERVER_BRANCH::stable$(php tests/nextcloud-version.php --appinfo)"
run: echo "::set-env name=SERVER_BRANCH::$(php tests/nextcloud-version.php --serverbranch)"
- name: Prepare Nextcloud server using ${{ env.SERVER_BRANCH }}
working-directory: ../
run: |
Expand Down
24 changes: 24 additions & 0 deletions tests/nextcloud-version.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ function getDependencyVersionFromAppInfo($path, $type = 'nextcloud', $minmax = '
return $v;
}

function isServerBranch($branch) : bool {
require_once dirname(__FILE__).'/../vendor/autoload.php';
$http = new \GuzzleHttp\Client(['http_errors' => false]);
$response = $http->request('GET', 'https://api.github.com/repos/nextcloud/server/branches/'.$branch);
$status = $response->getStatusCode();
switch ($status) {
case 200:
return true;
case 404:
return false;
default:
throw new \Exception('HTTP Error while checking branch '.$branch.' for Nextcloud server: '.$status);
}
}

function versionCompare($sv1, $sv2, $type) {
$v1 = explode('.', $sv1);
$v2 = explode('.', $sv2);
Expand All @@ -86,6 +101,15 @@ function versionCompare($sv1, $sv2, $type) {
echo getDependencyVersionFromAppInfo($pathAppInfo, 'nextcloud', 'min');
exit;
}
if (in_array('--serverbranch', $argv)) {
$ncVersion = getDependencyVersionFromAppInfo($pathAppInfo, 'nextcloud', 'min');
$branch = 'stable' . $ncVersion;
if (!isServerBranch($branch)) {
$branch = 'master';
}
echo $branch;
exit;
}
if (in_array('--php-min', $argv)) {
echo getDependencyVersionFromAppInfo($pathAppInfo, 'php', 'min');
exit;
Expand Down

0 comments on commit df9cfe9

Please sign in to comment.