diff --git a/.github/workflows/lint-eslint.yml b/.github/workflows/lint-eslint.yml index 5f48fb58..68746778 100644 --- a/.github/workflows/lint-eslint.yml +++ b/.github/workflows/lint-eslint.yml @@ -5,13 +5,14 @@ name: Lint -on: - pull_request: - push: - branches: - - main - - master - - stable* +on: pull_request + +permissions: + contents: read + +concurrency: + group: lint-eslint-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: lint: diff --git a/.github/workflows/lint-info-xml.yml b/.github/workflows/lint-info-xml.yml index cea2a2bc..19064a81 100644 --- a/.github/workflows/lint-info-xml.yml +++ b/.github/workflows/lint-info-xml.yml @@ -9,9 +9,17 @@ on: pull_request: push: branches: + - main - master - stable* +permissions: + contents: read + +concurrency: + group: lint-info-xml-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: xml-linters: runs-on: ubuntu-latest @@ -19,7 +27,7 @@ jobs: name: info.xml lint steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@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 9aad5140..9f4bad17 100644 --- a/.github/workflows/lint-php-cs.yml +++ b/.github/workflows/lint-php-cs.yml @@ -5,12 +5,14 @@ name: Lint -on: - pull_request: - push: - branches: - - master - - stable* +on: pull_request + +permissions: + contents: read + +concurrency: + group: lint-php-cs-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: lint: @@ -20,9 +22,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - - name: Set up php ${{ matrix.php-versions }} + - name: Set up php uses: shivammathur/setup-php@v2 with: php-version: "7.4" diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml index 9cfb484e..0509e800 100644 --- a/.github/workflows/lint-php.yml +++ b/.github/workflows/lint-php.yml @@ -5,12 +5,14 @@ name: Lint -on: - pull_request: - push: - branches: - - master - - stable* +on: pull_request + +permissions: + contents: read + +concurrency: + group: lint-php-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: php-lint: @@ -23,7 +25,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up php ${{ matrix.php-versions }} uses: shivammathur/setup-php@v2 @@ -35,6 +37,8 @@ jobs: run: composer run lint summary: + permissions: + contents: none runs-on: ubuntu-latest needs: php-lint diff --git a/.github/workflows/lint-stylelint.yml b/.github/workflows/lint-stylelint.yml index 64edcfba..a1197f8d 100644 --- a/.github/workflows/lint-stylelint.yml +++ b/.github/workflows/lint-stylelint.yml @@ -5,12 +5,14 @@ name: Lint -on: - pull_request: - push: - branches: - - master - - stable* +on: pull_request + +permissions: + contents: read + +concurrency: + group: lint-stylelint-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: lint: @@ -20,17 +22,17 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@v1.1 + uses: skjnldsv/read-package-engines-version-actions@v1.2 id: versions with: fallbackNode: '^12' fallbackNpm: '^6' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 9150d1f1..f6fd6b98 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -5,17 +5,15 @@ name: Node -on: - pull_request: - push: - branches: - - main - - master - - stable* +on: pull_request permissions: contents: read +concurrency: + group: node-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: build: runs-on: ubuntu-latest @@ -44,13 +42,12 @@ jobs: run: | npm ci npm run build --if-present - - name: Check webpack build changes run: | - bash -c "[[ ! \"`git status --porcelain `\" ]] || exit 1" - + bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)" - name: Show changes on failure if: failure() run: | git status git --no-pager diff + exit 1 # make it red to grab attention diff --git a/.github/workflows/phpunit-mysql.yml b/.github/workflows/phpunit-mysql.yml index 45d78dfa..96a187fd 100644 --- a/.github/workflows/phpunit-mysql.yml +++ b/.github/workflows/phpunit-mysql.yml @@ -1,29 +1,44 @@ +# 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 + name: PHPUnit on: pull_request: - push: - branches: - - master - - stable* + paths: + - '.github/workflows/**' + - 'appinfo/**' + - 'lib/**' + - 'templates/**' + - 'tests/**' + - 'vendor/**' + - 'vendor-bin/**' + - '.php-cs-fixer.dist.php' + - 'composer.json' + - 'composer.lock' + +permissions: + contents: read + +concurrency: + group: phpunit-mysql-${{ github.head_ref || github.run_id }} + cancel-in-progress: true env: - APP_NAME: registration # Location of the phpunit.xml and phpunit.integration.xml files - # Comment to disable PHPUNIT_CONFIG: ./tests/phpunit.xml - # PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml + PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml jobs: phpunit-mysql: runs-on: ubuntu-latest strategy: - # do not stop on another job's failure - fail-fast: false matrix: php-versions: ['7.4', '8.0', '8.1'] - server-versions: ['master', 'stable25'] + server-versions: ['master'] services: mysql: @@ -35,15 +50,25 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5 steps: + - name: Set app env + run: | + # Split and keep last + echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV + + - name: Enable ONLY_FULL_GROUP_BY MySQL option + run: | + echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword + echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword + - name: Checkout server - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: apps/${{ env.APP_NAME }} @@ -55,7 +80,15 @@ jobs: extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql coverage: none + - name: Check composer file existence + id: check_composer + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/composer.json + - name: Set up PHPUnit + # Only run if phpunit config file exists + if: steps.check_composer.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: composer i @@ -66,21 +99,39 @@ jobs: mkdir data ./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 }} - php -S localhost:8080 & + + - name: Check PHPUnit config file existence + id: check_phpunit + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} - name: PHPUnit # Only run if phpunit config file exists - if: env.PHPUNIT_CONFIG != '' + if: steps.check_phpunit.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }} + - name: Check PHPUnit integration config file existence + id: check_integration + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} + + - name: Run Nextcloud + # Only run if phpunit integration config file exists + if: steps.check_integration.outputs.files_exists == 'true' + run: php -S localhost:8080 & + - name: PHPUnit integration # Only run if phpunit integration config file exists - if: env.PHPUNIT_INTEGRATION_CONFIG != '' + if: steps.check_integration.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} summary: + permissions: + contents: none runs-on: ubuntu-latest needs: phpunit-mysql diff --git a/.github/workflows/phpunit-oci.yml b/.github/workflows/phpunit-oci.yml index 9c894557..4948ffb9 100644 --- a/.github/workflows/phpunit-oci.yml +++ b/.github/workflows/phpunit-oci.yml @@ -1,26 +1,41 @@ +# 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 + name: PHPUnit on: pull_request: - push: - branches: - - master - - stable* + paths: + - '.github/workflows/**' + - 'appinfo/**' + - 'lib/**' + - 'templates/**' + - 'tests/**' + - 'vendor/**' + - 'vendor-bin/**' + - '.php-cs-fixer.dist.php' + - 'composer.json' + - 'composer.lock' + +permissions: + contents: read + +concurrency: + group: phpunit-oci-${{ github.head_ref || github.run_id }} + cancel-in-progress: true env: - APP_NAME: registration # Location of the phpunit.xml and phpunit.integration.xml files - # Comment to disable PHPUNIT_CONFIG: ./tests/phpunit.xml - # PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml + PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml jobs: phpunit-oci: runs-on: ubuntu-latest strategy: - # do not stop on another job's failure - fail-fast: false matrix: php-versions: ['8.0'] server-versions: ['master'] @@ -32,15 +47,20 @@ jobs: - 1521:1521/tcp steps: + - name: Set app env + run: | + # Split and keep last + echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV + - name: Checkout server - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: apps/${{ env.APP_NAME }} @@ -52,7 +72,15 @@ jobs: tools: phpunit coverage: none + - name: Check composer file existence + id: check_composer + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/composer.json + - name: Set up PHPUnit + # Only run if phpunit config file exists + if: steps.check_composer.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: composer i @@ -63,21 +91,39 @@ jobs: mkdir data ./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 }} - php -S localhost:8080 & + + - name: Check PHPUnit config file existence + id: check_phpunit + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} - name: PHPUnit # Only run if phpunit config file exists - if: env.PHPUNIT_CONFIG != '' + if: steps.check_phpunit.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }} + - name: Check PHPUnit integration config file existence + id: check_integration + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} + + - name: Run Nextcloud + # Only run if phpunit integration config file exists + if: steps.check_integration.outputs.files_exists == 'true' + run: php -S localhost:8080 & + - name: PHPUnit integration # Only run if phpunit integration config file exists - if: env.PHPUNIT_INTEGRATION_CONFIG != '' + if: steps.check_integration.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} summary: + permissions: + contents: none runs-on: ubuntu-latest needs: phpunit-oci diff --git a/.github/workflows/phpunit-pgsql.yml b/.github/workflows/phpunit-pgsql.yml index 87ac9127..46b73071 100644 --- a/.github/workflows/phpunit-pgsql.yml +++ b/.github/workflows/phpunit-pgsql.yml @@ -1,26 +1,41 @@ +# 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 + name: PHPUnit on: pull_request: - push: - branches: - - master - - stable* + paths: + - '.github/workflows/**' + - 'appinfo/**' + - 'lib/**' + - 'templates/**' + - 'tests/**' + - 'vendor/**' + - 'vendor-bin/**' + - '.php-cs-fixer.dist.php' + - 'composer.json' + - 'composer.lock' + +permissions: + contents: read + +concurrency: + group: phpunit-pgsql-${{ github.head_ref || github.run_id }} + cancel-in-progress: true env: - APP_NAME: registration # Location of the phpunit.xml and phpunit.integration.xml files - # Comment to disable PHPUNIT_CONFIG: ./tests/phpunit.xml - # PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml + PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml jobs: phpunit-pgsql: runs-on: ubuntu-latest strategy: - # do not stop on another job's failure - fail-fast: false matrix: php-versions: ['8.0'] server-versions: ['master'] @@ -37,15 +52,19 @@ jobs: options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5 steps: + - name: Set app env + run: | + # Split and keep last + echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Checkout server - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: apps/${{ env.APP_NAME }} @@ -57,7 +76,15 @@ jobs: extensions: mbstring, iconv, fileinfo, intl, pgsql, pdo_pgsql coverage: none + - name: Check composer file existence + id: check_composer + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/composer.json + - name: Set up PHPUnit + # Only run if phpunit config file exists + if: steps.check_composer.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: composer i @@ -68,21 +95,38 @@ jobs: mkdir data ./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 }} - php -S localhost:8080 & + - name: Check PHPUnit config file existence + id: check_phpunit + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} - name: PHPUnit # Only run if phpunit config file exists - if: env.PHPUNIT_CONFIG != '' + if: steps.check_phpunit.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }} + - name: Check PHPUnit integration config file existence + id: check_integration + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} + + - name: Run Nextcloud + # Only run if phpunit integration config file exists + if: steps.check_integration.outputs.files_exists == 'true' + run: php -S localhost:8080 & + - name: PHPUnit integration # Only run if phpunit integration config file exists - if: env.PHPUNIT_INTEGRATION_CONFIG != '' + if: steps.check_integration.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} summary: + permissions: + contents: none runs-on: ubuntu-latest needs: phpunit-pgsql diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml index c6e159fb..deb196c9 100644 --- a/.github/workflows/phpunit-sqlite.yml +++ b/.github/workflows/phpunit-sqlite.yml @@ -1,41 +1,59 @@ +# 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 + name: PHPUnit on: pull_request: - push: - branches: - - master - - stable* + paths: + - '.github/workflows/**' + - 'appinfo/**' + - 'lib/**' + - 'templates/**' + - 'tests/**' + - 'vendor/**' + - 'vendor-bin/**' + - '.php-cs-fixer.dist.php' + - 'composer.json' + - 'composer.lock' + +permissions: + contents: read + +concurrency: + group: phpunit-sqlite-${{ github.head_ref || github.run_id }} + cancel-in-progress: true env: - APP_NAME: registration # Location of the phpunit.xml and phpunit.integration.xml files - # Comment to disable PHPUNIT_CONFIG: ./tests/phpunit.xml - # PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml + PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml jobs: phpunit-sqlite: runs-on: ubuntu-latest strategy: - # do not stop on another job's failure - fail-fast: false matrix: php-versions: ['8.0'] - databases: ['sqlite'] - server-versions: ['master'] + server-versions: ['master', 'stable25'] steps: + - name: Set app env + run: | + # Split and keep last + echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Checkout server - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: apps/${{ env.APP_NAME }} @@ -47,7 +65,15 @@ jobs: extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite coverage: none + - name: Check composer file existence + id: check_composer + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/composer.json + - name: Set up PHPUnit + # Only run if phpunit config file exists + if: steps.check_composer.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: composer i @@ -58,21 +84,38 @@ jobs: mkdir data ./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 }} - php -S localhost:8080 & + - name: Check PHPUnit config file existence + id: check_phpunit + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} - name: PHPUnit # Only run if phpunit config file exists - if: env.PHPUNIT_CONFIG != '' + if: steps.check_phpunit.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }} + - name: Check PHPUnit integration config file existence + id: check_integration + uses: andstor/file-existence-action@v1 + with: + files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} + + - name: Run Nextcloud + # Only run if phpunit integration config file exists + if: steps.check_integration.outputs.files_exists == 'true' + run: php -S localhost:8080 & + - name: PHPUnit integration # Only run if phpunit integration config file exists - if: env.PHPUNIT_INTEGRATION_CONFIG != '' + if: steps.check_integration.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} summary: + permissions: + contents: none runs-on: ubuntu-latest needs: phpunit-sqlite