fix CI tests for unpublished server version
This commit is contained in:
parent
80124cad8b
commit
0de90c429d
|
@ -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: |
|
||||
|
|
|
@ -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);
|
||||
|
@ -86,6 +101,15 @@ if (in_array('--appinfo', $argv)) {
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue