diff --git a/.github/workflows/appstore-build-publish.yml b/.github/workflows/appstore-build-publish.yml index 9f61bcb4cea..90453eb0c38 100644 --- a/.github/workflows/appstore-build-publish.yml +++ b/.github/workflows/appstore-build-publish.yml @@ -32,7 +32,7 @@ jobs: echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: path: ${{ env.APP_NAME }} @@ -50,8 +50,8 @@ jobs: continue-on-error: true with: path: ${{ env.APP_NAME }} - fallbackNode: "^12" - fallbackNpm: "^6" + fallbackNode: "^16" + fallbackNpm: "^7" - name: Set up node ${{ steps.versions.outputs.nodeVersion }} # Skip if no package.json @@ -102,8 +102,8 @@ jobs: - name: Install Krankerl if: steps.krankerl.outputs.files_exists == 'true' run: | - wget https://github.com/ChristophWurst/krankerl/releases/download/v0.13.0/krankerl_0.13.0_amd64.deb - sudo dpkg -i krankerl_0.13.0_amd64.deb + wget https://github.com/ChristophWurst/krankerl/releases/download/v0.14.0/krankerl_0.14.0_amd64.deb + sudo dpkg -i krankerl_0.14.0_amd64.deb - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with krankerl if: steps.krankerl.outputs.files_exists == 'true' @@ -126,7 +126,7 @@ jobs: unzip latest-$NCVERSION.zip - name: Checkout server master fallback - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 if: ${{ steps.server-checkout.outcome != 'success' }} with: repository: nextcloud/server diff --git a/.github/workflows/lint-eslint-when-unrelated.yml b/.github/workflows/lint-eslint-when-unrelated.yml new file mode 100644 index 00000000000..63710eb6654 --- /dev/null +++ b/.github/workflows/lint-eslint-when-unrelated.yml @@ -0,0 +1,39 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions +# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks + +name: Lint + +on: + pull_request: + paths-ignore: + - '.github/workflows/**' + - 'src/**' + - 'appinfo/info.xml' + - 'package.json' + - 'package-lock.json' + - 'tsconfig.json' + - '.eslintrc.*' + - '.eslintignore' + - '**.js' + - '**.ts' + - '**.vue' + +permissions: + contents: read + +jobs: + lint: + permissions: + contents: none + + runs-on: ubuntu-latest + + name: eslint + + steps: + - run: 'echo "No eslint required"' diff --git a/.github/workflows/lint-eslint.yml b/.github/workflows/lint-eslint.yml index 80ec2445e22..628e8fefa99 100644 --- a/.github/workflows/lint-eslint.yml +++ b/.github/workflows/lint-eslint.yml @@ -2,6 +2,9 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions +# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks name: Lint @@ -14,6 +17,8 @@ on: - 'package.json' - 'package-lock.json' - 'tsconfig.json' + - '.eslintrc.*' + - '.eslintignore' - '**.js' - '**.ts' - '**.vue' @@ -33,14 +38,14 @@ jobs: steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Read package.json node and npm engines version uses: skjnldsv/read-package-engines-version-actions@1bdcee71fa343c46b18dc6aceffb4cd1e35209c6 # v1.2 id: versions with: - fallbackNode: '^12' - fallbackNpm: '^6' + fallbackNode: '^16' + fallbackNpm: '^7' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3 diff --git a/.github/workflows/lint-info-xml.yml b/.github/workflows/lint-info-xml.yml index c5f57dd5e22..8f024cfcb98 100644 --- a/.github/workflows/lint-info-xml.yml +++ b/.github/workflows/lint-info-xml.yml @@ -27,7 +27,7 @@ jobs: name: info.xml lint steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Download schema run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd diff --git a/.github/workflows/lint-php-cs.yml b/.github/workflows/lint-php-cs.yml index 85cb03664bf..df490fb23b9 100644 --- a/.github/workflows/lint-php-cs.yml +++ b/.github/workflows/lint-php-cs.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Set up php uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml index 5a7cbffb099..45bf08292a3 100644 --- a/.github/workflows/lint-php.yml +++ b/.github/workflows/lint-php.yml @@ -31,7 +31,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Set up php ${{ matrix.php-versions }} uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 diff --git a/.github/workflows/lint-stylelint.yml b/.github/workflows/lint-stylelint.yml index a035b176551..6cdf20cc9c6 100644 --- a/.github/workflows/lint-stylelint.yml +++ b/.github/workflows/lint-stylelint.yml @@ -22,14 +22,14 @@ jobs: steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Read package.json node and npm engines version uses: skjnldsv/read-package-engines-version-actions@1bdcee71fa343c46b18dc6aceffb4cd1e35209c6 # v1.2 id: versions with: - fallbackNode: '^12' - fallbackNpm: '^6' + fallbackNode: '^16' + fallbackNpm: '^7' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3 diff --git a/.github/workflows/node-when-unrelated.yml b/.github/workflows/node-when-unrelated.yml new file mode 100644 index 00000000000..db32b0dba53 --- /dev/null +++ b/.github/workflows/node-when-unrelated.yml @@ -0,0 +1,43 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# Use node together with node-when-unrelated to make eslint a required check for GitHub actions +# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks + +name: Node + +on: + pull_request: + paths-ignore: + - '.github/workflows/**' + - 'src/**' + - 'appinfo/info.xml' + - 'package.json' + - 'package-lock.json' + - 'tsconfig.json' + - '**.js' + - '**.ts' + - '**.vue' + push: + branches: + - main + - master + - stable* + +concurrency: + group: node-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + build: + permissions: + contents: none + + runs-on: ubuntu-latest + + name: node + steps: + - name: Skip + run: 'echo "No JS/TS files changed, skipped Node"' diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index f0db34e8340..e3310644ec1 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -37,14 +37,14 @@ jobs: name: node steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Read package.json node and npm engines version uses: skjnldsv/read-package-engines-version-actions@1bdcee71fa343c46b18dc6aceffb4cd1e35209c6 # v1.2 id: versions with: - fallbackNode: '^12' - fallbackNpm: '^6' + fallbackNode: '^16' + fallbackNpm: '^7' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3 diff --git a/.github/workflows/phpunit-mysql.yml b/.github/workflows/phpunit-mysql.yml index a30adf5b577..bf3aaa5c56f 100644 --- a/.github/workflows/phpunit-mysql.yml +++ b/.github/workflows/phpunit-mysql.yml @@ -32,11 +32,6 @@ concurrency: group: phpunit-mysql-${{ github.head_ref || github.run_id }} cancel-in-progress: true -env: - # Location of the phpunit.xml and phpunit.integration.xml files - PHPUNIT_CONFIG: ./tests/php/phpunit.xml - PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml - jobs: phpunit-mysql: runs-on: ubuntu-latest @@ -67,14 +62,14 @@ jobs: echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword - name: Checkout server - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: path: apps/${{ env.APP_NAME }} @@ -93,7 +88,7 @@ jobs: with: files: apps/${{ env.APP_NAME }}/composer.json - - name: Set up PHPUnit + - name: Set up dependencies # Only run if phpunit config file exists if: steps.check_composer.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} @@ -107,34 +102,43 @@ jobs: ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password ./occ app:enable --force ${{ env.APP_NAME }} - - name: Check PHPUnit config file existence + - name: Check PHPUnit script is defined id: check_phpunit - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep "^ test:unit " | wc -l | grep 1 - name: PHPUnit # Only run if phpunit config file exists - if: steps.check_phpunit.outputs.files_exists == 'true' + if: steps.check_phpunit.outcome == 'success' working-directory: apps/${{ env.APP_NAME }} - run: composer run test + run: composer run test:unit - - name: Check PHPUnit integration config file existence + - name: Check PHPUnit integration script is defined id: check_integration - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep "^ test:integration " | wc -l | grep 1 - name: Run Nextcloud # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' + if: steps.check_integration.outcome == 'success' run: php -S localhost:8080 & - name: PHPUnit integration # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' + if: steps.check_integration.outcome == 'success' working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} + run: composer run test:integration + + - name: Skipped + # Fail the action when neither unit nor integration tests ran + if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure' + run: | + echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts' + exit 1 summary: permissions: diff --git a/.github/workflows/phpunit-oci.yml b/.github/workflows/phpunit-oci.yml index 9750fbb1f0a..930d2c24351 100644 --- a/.github/workflows/phpunit-oci.yml +++ b/.github/workflows/phpunit-oci.yml @@ -32,11 +32,6 @@ concurrency: group: phpunit-oci-${{ github.head_ref || github.run_id }} cancel-in-progress: true -env: - # Location of the phpunit.xml and phpunit.integration.xml files - PHPUNIT_CONFIG: ./tests/php/phpunit.xml - PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml - jobs: phpunit-oci: runs-on: ubuntu-latest @@ -59,14 +54,14 @@ jobs: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Checkout server - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: path: apps/${{ env.APP_NAME }} @@ -85,7 +80,7 @@ jobs: with: files: apps/${{ env.APP_NAME }}/composer.json - - name: Set up PHPUnit + - name: Set up dependencies # Only run if phpunit config file exists if: steps.check_composer.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} @@ -99,34 +94,43 @@ jobs: ./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin ./occ app:enable --force ${{ env.APP_NAME }} - - name: Check PHPUnit config file existence + - name: Check PHPUnit script is defined id: check_phpunit - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep "^ test:unit " | wc -l | grep 1 - name: PHPUnit # Only run if phpunit config file exists - if: steps.check_phpunit.outputs.files_exists == 'true' + if: steps.check_phpunit.outcome == 'success' working-directory: apps/${{ env.APP_NAME }} - run: composer run test + run: composer run test:unit - - name: Check PHPUnit integration config file existence + - name: Check PHPUnit integration script is defined id: check_integration - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep "^ test:integration " | wc -l | grep 1 - name: Run Nextcloud # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' + if: steps.check_integration.outcome == 'success' run: php -S localhost:8080 & - name: PHPUnit integration # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' + if: steps.check_integration.outcome == 'success' working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} + run: composer run test:integration + + - name: Skipped + # Fail the action when neither unit nor integration tests ran + if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure' + run: | + echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts' + exit 1 summary: permissions: diff --git a/.github/workflows/phpunit-pgsql.yml b/.github/workflows/phpunit-pgsql.yml index ee80c6c76dc..8ec26389d5f 100644 --- a/.github/workflows/phpunit-pgsql.yml +++ b/.github/workflows/phpunit-pgsql.yml @@ -32,11 +32,6 @@ concurrency: group: phpunit-pgsql-${{ github.head_ref || github.run_id }} cancel-in-progress: true -env: - # Location of the phpunit.xml and phpunit.integration.xml files - PHPUNIT_CONFIG: ./tests/php/phpunit.xml - PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml - jobs: phpunit-pgsql: runs-on: ubuntu-latest @@ -64,14 +59,14 @@ jobs: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Checkout server - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: path: apps/${{ env.APP_NAME }} @@ -90,7 +85,7 @@ jobs: with: files: apps/${{ env.APP_NAME }}/composer.json - - name: Set up PHPUnit + - name: Set up dependencies # Only run if phpunit config file exists if: steps.check_composer.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} @@ -104,34 +99,43 @@ jobs: ./occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password ./occ app:enable --force ${{ env.APP_NAME }} - - name: Check PHPUnit config file existence + - name: Check PHPUnit script is defined id: check_phpunit - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep "^ test:unit " | wc -l | grep 1 - name: PHPUnit # Only run if phpunit config file exists - if: steps.check_phpunit.outputs.files_exists == 'true' + if: steps.check_phpunit.outcome == 'success' working-directory: apps/${{ env.APP_NAME }} - run: composer run test + run: composer run test:unit - - name: Check PHPUnit integration config file existence + - name: Check PHPUnit integration script is defined id: check_integration - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep "^ test:integration " | wc -l | grep 1 - name: Run Nextcloud # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' + if: steps.check_integration.outcome == 'success' run: php -S localhost:8080 & - name: PHPUnit integration # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' + if: steps.check_integration.outcome == 'success' working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} + run: composer run test:integration + + - name: Skipped + # Fail the action when neither unit nor integration tests ran + if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure' + run: | + echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts' + exit 1 summary: permissions: diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml index bbafb1455fb..f1e432afbfe 100644 --- a/.github/workflows/phpunit-sqlite.yml +++ b/.github/workflows/phpunit-sqlite.yml @@ -32,11 +32,6 @@ concurrency: group: phpunit-sqlite-${{ github.head_ref || github.run_id }} cancel-in-progress: true -env: - # Location of the phpunit.xml and phpunit.integration.xml files - PHPUNIT_CONFIG: ./tests/php/phpunit.xml - PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml - jobs: phpunit-sqlite: runs-on: ubuntu-latest @@ -53,14 +48,14 @@ jobs: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Checkout server - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: path: apps/${{ env.APP_NAME }} @@ -79,7 +74,7 @@ jobs: with: files: apps/${{ env.APP_NAME }}/composer.json - - name: Set up PHPUnit + - name: Set up dependencies # Only run if phpunit config file exists if: steps.check_composer.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} @@ -93,34 +88,43 @@ jobs: ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password ./occ app:enable --force ${{ env.APP_NAME }} - - name: Check PHPUnit config file existence + - name: Check PHPUnit script is defined id: check_phpunit - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep "^ test:unit " | wc -l | grep 1 - name: PHPUnit # Only run if phpunit config file exists - if: steps.check_phpunit.outputs.files_exists == 'true' + if: steps.check_phpunit.outcome == 'success' working-directory: apps/${{ env.APP_NAME }} - run: composer run test + run: composer run test:unit - - name: Check PHPUnit integration config file existence + - name: Check PHPUnit integration script is defined id: check_integration - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep "^ test:integration " | wc -l | grep 1 - name: Run Nextcloud # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' + if: steps.check_integration.outcome == 'success' run: php -S localhost:8080 & - name: PHPUnit integration # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' + if: steps.check_integration.outcome == 'success' working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} + run: composer run test:integration + + - name: Skipped + # Fail the action when neither unit nor integration tests ran + if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure' + run: | + echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts' + exit 1 summary: permissions: diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 64939cc6068..15cab7e300f 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -24,7 +24,7 @@ jobs: name: Nextcloud steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Set up php uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 diff --git a/.github/workflows/update-nextcloud-ocp.yml b/.github/workflows/update-nextcloud-ocp.yml index 872d8df4851..c103a16b65e 100644 --- a/.github/workflows/update-nextcloud-ocp.yml +++ b/.github/workflows/update-nextcloud-ocp.yml @@ -8,7 +8,7 @@ name: Update nextcloud/ocp on: workflow_dispatch: schedule: - - cron: "5 4 * * 0" + - cron: "5 2 * * 0" jobs: update-nextcloud-ocp: @@ -22,7 +22,7 @@ jobs: name: update-nextcloud-ocp-${{ matrix.branches }} steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: ref: ${{ matrix.branches }} submodules: true diff --git a/composer.json b/composer.json index 301f0e6663c..a42eb32fd43 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "\"vendor/bin/mozart\" compose", "composer dump-autoload" ], - "test": "cd tests/php/ && phpunit -c phpunit.xml" + "test:unit": "vendor/bin/phpunit -c tests/php/phpunit.xml" }, "require-dev": { "nextcloud/ocp": "dev-master",