diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a5218712..d0934734 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -46,18 +46,17 @@ jobs: strategy: matrix: version: [min, max] - include: - - version: min - php-version: 7.1 - - version: max - php-version: 7.4 steps: - name: Checkout uses: actions/checkout@v2 - - name: Set up php${{ matrix.php-versions }} + - name: Determine PHP version + env: + VERSION_MINMAX: ${{ matrix.version }} + run: echo "::set-env name=PHP_VERSION::$(php tests/nextcloud-version.php --php-$VERSION_MINMAX)" + - name: Set up PHP ${{ env.PHP_VERSION }} uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ env.PHP_VERSION }} - name: Install Dependencies run: composer install --prefer-dist - name: Install latest Nextcloud API (dev-master) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e9418648..4ab4895c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,20 +12,19 @@ jobs: strategy: matrix: version: [min, max] - include: - - version: min - php-version: 7.1 - - version: max - php-version: 7.4 env: SERVER_BRANCH: master steps: - name: Checkout uses: actions/checkout@v2 - - name: Set up php${{ matrix.php-versions }} + - name: Determine PHP version + env: + VERSION_MINMAX: ${{ matrix.version }} + run: echo "::set-env name=PHP_VERSION::$(php tests/nextcloud-version.php --php-$VERSION_MINMAX)" + - name: Set up PHP ${{ env.PHP_VERSION }} uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ env.PHP_VERSION }} - name: Install Dependencies run: composer install --prefer-dist - name: Prepare MySQL database @@ -35,8 +34,8 @@ jobs: mysql -u root -proot -e "CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY '';" mysql -u root -proot -e "GRANT ALL ON nextcloud.* TO 'nextcloud'@'localhost';" - name: Select Nextcloud server branch - run: echo "::set-env name=SERVER_BRANCH::stable$(php tests/nextcloud-version.php --appinfo)" if: matrix.version == 'min' + run: echo "::set-env name=SERVER_BRANCH::stable$(php tests/nextcloud-version.php --appinfo)" - name: Prepare Nextcloud server using ${{ env.SERVER_BRANCH }} working-directory: ../ run: | diff --git a/appinfo/info.xml b/appinfo/info.xml index c70fad2d..ea561df7 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -22,6 +22,7 @@ The Notes app is a distraction free notes taking app for [Nextcloud](https://www https://github.com/nextcloud/notes.git https://raw.githubusercontent.com/nextcloud/screenshots/master/apps/Notes/notes.png + diff --git a/tests/nextcloud-version.php b/tests/nextcloud-version.php index 06c0242e..9250c7b2 100644 --- a/tests/nextcloud-version.php +++ b/tests/nextcloud-version.php @@ -50,7 +50,7 @@ function getValidProperty($json, $prop) { return $json->{$prop}; } -function getNCVersionFromAppInfo($path, $minmax = 'min') { +function getDependencyVersionFromAppInfo($path, $type = 'nextcloud', $minmax = 'min') { if (!file_exists($path)) { throw new Exception('AppInfo does not exists: '.$path); } @@ -59,7 +59,7 @@ function getNCVersionFromAppInfo($path, $minmax = 'min') { } $content = file_get_contents($path); $info = new SimpleXMLElement($content); - $nc = $info->dependencies->nextcloud; + $nc = $info->dependencies->$type; $v = (string)$nc->attributes()->{$minmax.'-version'}; return $v; } @@ -79,8 +79,19 @@ function versionCompare($sv1, $sv2, $type) { return true; } +$pathAppInfo = __DIR__.'/../appinfo/info.xml'; + + if (in_array('--appinfo', $argv)) { - echo getNCVersionFromAppInfo(__DIR__.'/../appinfo/info.xml', 'min'); + echo getDependencyVersionFromAppInfo($pathAppInfo, 'nextcloud', 'min'); + exit; +} +if (in_array('--php-min', $argv)) { + echo getDependencyVersionFromAppInfo($pathAppInfo, 'php', 'min'); + exit; +} +if (in_array('--php-max', $argv)) { + echo getDependencyVersionFromAppInfo($pathAppInfo, 'php', 'max'); exit; } @@ -89,10 +100,10 @@ try { $vComposer = getNCVersionFromComposer(__DIR__.'/../composer.json'); if ($vComposer === 'dev-master') { $vComposer = getNCVersionFromComposerBranchAlias(__DIR__.'/../vendor/christophwurst/nextcloud/composer.json'); - $vAppInfo = getNCVersionFromAppInfo(__DIR__.'/../appinfo/info.xml', 'max'); + $vAppInfo = getDependencyVersionFromAppInfo($pathAppInfo, 'nextcloud', 'max'); $type = 'max'; } else { - $vAppInfo = getNCVersionFromAppInfo(__DIR__.'/../appinfo/info.xml', 'min'); + $vAppInfo = getDependencyVersionFromAppInfo($pathAppInfo, 'nextcloud', 'min'); $type = 'min'; } echo $type.': '.$vAppInfo.' (AppInfo) vs. '.$vComposer.' (Composer) => ';