diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 412f98deb..9c60ec919 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -4,14 +4,21 @@ on: branches: - main pull_request: - + paths: + - '.github/workflows/coding-standards.yml' + - 'includes/**' + - 'src/**' + - 'test/**' + - 'package.*' + - '*.js' + - '*.php' jobs: phpcs: name: PHP Coding Standards runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Get Composer cache directory id: composer-cache @@ -53,7 +60,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Log debug information run: | @@ -64,23 +71,48 @@ jobs: composer --version - name: Install NodeJS - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + # Enable built-in functionality for caching and restoring dependencies, which is disabled by default. + # The actions/setup-node uses actions/cache under the hood. + # https://github.com/actions/setup-node#caching-global-packages-data + cache: 'npm' + + # Restoring the short lived node_modules cache + # to be used accross all workflows running on the last commit. + # https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache + - uses: actions/cache/restore@v4 + id: node_modules-cache with: - node-version-file: '.nvmrc' + path: | + ./node_modules + key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }} - name: NPM install + if: steps.node_modules-cache.outputs.cache-hit != 'true' run: npm ci --legacy-peer-deps + # Creating a short lived node_modules cache + - uses: actions/cache/save@v4 + if: steps.node_modules-cache.outputs.cache-hit != 'true' + with: + path: | + ./node_modules + key: ${{ steps.node_modules-cache.outputs.cache-primary-key }} + - name: Run JSHint run: npm run lint:js if: ${{ success() || failure() }} stylelint: name: CSS Coding Standards + needs: jshint # Wait for jshint job, to mak use of node_modules caching. + if: always() # Run always, even when the jshint job didn't ran. runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Log debug information run: | @@ -91,13 +123,36 @@ jobs: composer --version - name: Install NodeJS - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' + # Enable built-in functionality for caching and restoring dependencies, which is disabled by default. + # The actions/setup-node uses actions/cache under the hood. + # https://github.com/actions/setup-node#caching-global-packages-data + cache: 'npm' + + # Restoring the short lived node_modules cache + # to be used accross all workflows running on the last commit. + # https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache + - uses: actions/cache/restore@v4 + id: node_modules-cache + with: + path: | + ./node_modules + key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }} - name: NPM install + if: steps.node_modules-cache.outputs.cache-hit != 'true' run: npm ci --legacy-peer-deps + # Creating a short lived node_modules cache + - uses: actions/cache/save@v4 + if: steps.node_modules-cache.outputs.cache-hit != 'true' + with: + path: | + ./node_modules + key: ${{ steps.node_modules-cache.outputs.cache-primary-key }} + - name: Run StyleLint run: npm run lint:css if: ${{ success() || failure() }} diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 9c6cf3ca4..ea3420db9 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -5,7 +5,16 @@ # Source repository: https://github.com/actions/dependency-review-action # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement name: 'Dependency Review' -on: [pull_request] +on: + push: + branches: + - main + pull_request: + paths: + - '.github/workflows/dependency-review.yml' + - 'package*' + - 'composer*' + permissions: contents: read @@ -32,7 +41,12 @@ jobs: with: license-check: true vulnerability-check: false - comment-summary-in-pr: on-failure + + # Prevent this workflow to create a comment on the PR on forks outside of the GatherPress organization, + # because the required permission would not be given and the workflow would fail. + # Using a condition check will skip commenting. + comment-summary-in-pr: ${{ github.repository_owner == 'GatherPress' && 'on-failure' || 'never' }} + # You can only include one of these two options: `allow-licenses` and `deny-licences` # ([String]). Only allow these licenses (optional) # Possible values: Any `spdx_id` value(s) from https://docs.github.com/en/rest/licenses diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index a74b82020..471733df4 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Log debug information run: | @@ -21,9 +21,13 @@ jobs: composer --version - name: Install NodeJS - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: - node-version-file: '.nvmrc' + node-version-file: '.nvmrc' + # Enable built-in functionality for caching and restoring dependencies, which is disabled by default. + # The actions/setup-node uses actions/cache under the hood. + # https://github.com/actions/setup-node#caching-global-packages-data + cache: 'npm' - name: NPM install run: npm ci --legacy-peer-deps diff --git a/.github/workflows/jest-tests.yml b/.github/workflows/jest-tests.yml index b7e7703ce..d5f7c2c13 100644 --- a/.github/workflows/jest-tests.yml +++ b/.github/workflows/jest-tests.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Log debug information run: | @@ -27,13 +27,36 @@ jobs: composer --version - name: Install NodeJS - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: - node-version-file: '.nvmrc' + node-version-file: '.nvmrc' + # Enable built-in functionality for caching and restoring dependencies, which is disabled by default. + # The actions/setup-node uses actions/cache under the hood. + # https://github.com/actions/setup-node#caching-global-packages-data + cache: 'npm' + + # Restoring the short lived node_modules cache + # to be used accross all workflows running on the last commit. + # https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache + - uses: actions/cache/restore@v4 + id: node_modules-cache + with: + path: | + ./node_modules + key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }} - name: NPM install + if: steps.node_modules-cache.outputs.cache-hit != 'true' run: npm ci --legacy-peer-deps + # Creating a short lived node_modules cache + - uses: actions/cache/save@v4 + if: steps.node_modules-cache.outputs.cache-hit != 'true' + with: + path: | + ./node_modules + key: ${{ steps.node_modules-cache.outputs.cache-primary-key }} + - name: Run Jest Tests run: npm run test:unit:js if: ${{ success() || failure() }} diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 95f3e0dd2..b6c336fb8 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -21,7 +21,7 @@ jobs: php_versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -33,9 +33,13 @@ jobs: run: composer install --optimize-autoloader --prefer-dist - name: Install NodeJS - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' + # Enable built-in functionality for caching and restoring dependencies, which is disabled by default. + # The actions/setup-node uses actions/cache under the hood. + # https://github.com/actions/setup-node#caching-global-packages-data + cache: 'npm' - name: Log debug information run: | diff --git a/.github/workflows/playground-preview.yml b/.github/workflows/playground-preview.yml index 6f89ce01b..6af24f35a 100644 --- a/.github/workflows/playground-preview.yml +++ b/.github/workflows/playground-preview.yml @@ -50,10 +50,11 @@ jobs: # @source https://dev.to/suzukishunsuke/secure-github-actions-by-pullrequesttarget-641#checkout-merge-commits - uses: suzuki-shunsuke/get-pr-action@v0.1.0 id: pr + - name: Checkout uses: actions/checkout@v4 with: - ref: ${{steps.pr.outputs.merge_commit_sha}} + ref: ${{ steps.pr.outputs.merge_commit_sha }} show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - name: Setup PHP @@ -70,10 +71,32 @@ jobs: uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' - cache: npm + # Enable built-in functionality for caching and restoring dependencies, which is disabled by default. + # The actions/setup-node uses actions/cache under the hood. + # https://github.com/actions/setup-node#caching-global-packages-data + cache: 'npm' + + # Restoring the short lived node_modules cache + # to be used accross all workflows running on the last commit. + # https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache + - uses: actions/cache/restore@v4 + id: node_modules-cache + with: + path: | + ./node_modules + key: ${{ runner.os }}-node_modules-${{ steps.pr.outputs.merge_commit_sha }}-${{ hashFiles('package-lock.json') }} - - name: Install dependencies - run: npm ci + - name: NPM install + if: steps.node_modules-cache.outputs.cache-hit != 'true' + run: npm ci --legacy-peer-deps + + # Creating a short lived node_modules cache + - uses: actions/cache/save@v4 + if: steps.node_modules-cache.outputs.cache-hit != 'true' + with: + path: | + ./node_modules + key: ${{ steps.node_modules-cache.outputs.cache-primary-key }} - name: Build plugin # - [Incorrect version number used when creating zip archive · Issue #92 · wp-cli/dist-archive-command](https://github.com/wp-cli/dist-archive-command/issues/92) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index f0b0ae6d2..c4eb2565e 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -10,7 +10,7 @@ jobs: runs-on: 'ubuntu-latest' steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -22,13 +22,36 @@ jobs: run: composer install --optimize-autoloader --prefer-dist - name: Install NodeJS - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' + # Enable built-in functionality for caching and restoring dependencies, which is disabled by default. + # The actions/setup-node uses actions/cache under the hood. + # https://github.com/actions/setup-node#caching-global-packages-data + cache: 'npm' + + # Restoring the short lived node_modules cache + # to be used accross all workflows running on the last commit. + # https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache + - uses: actions/cache/restore@v4 + id: node_modules-cache + with: + path: | + ./node_modules + key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }} - name: NPM install + if: steps.node_modules-cache.outputs.cache-hit != 'true' run: npm ci --legacy-peer-deps + # Creating a short lived node_modules cache + - uses: actions/cache/save@v4 + if: steps.node_modules-cache.outputs.cache-hit != 'true' + with: + path: | + ./node_modules + key: ${{ steps.node_modules-cache.outputs.cache-primary-key }} + - name: Log debug information run: | npm --version diff --git a/.github/workflows/wordpress-org-plugin-guidelines.yml b/.github/workflows/wordpress-org-plugin-guidelines.yml index 2912b2be2..50ed759d0 100644 --- a/.github/workflows/wordpress-org-plugin-guidelines.yml +++ b/.github/workflows/wordpress-org-plugin-guidelines.yml @@ -2,6 +2,13 @@ name: 'WordPress.org plugin directory guidelines' on: # rebuild any PRs and main branch changes workflow_dispatch: pull_request: + paths: + - '.github/workflows/wordpress-org-plugin-guidelines.yml' + - 'includes/**' + - 'src/**' + - 'package.*' + - '*.js' + - '*.php' push: branches: - main @@ -29,10 +36,32 @@ jobs: with: # Make sure to use the same version like WordPress/gutenberg. node-version-file: '.nvmrc' - cache: npm + # Enable built-in functionality for caching and restoring dependencies, which is disabled by default. + # The actions/setup-node uses actions/cache under the hood. + # https://github.com/actions/setup-node#caching-global-packages-data + cache: 'npm' - - name: Install dependencies - run: npm ci + # Restoring the short lived node_modules cache + # to be used accross all workflows running on the last commit. + # https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache + - uses: actions/cache/restore@v4 + id: node_modules-cache + with: + path: | + ./node_modules + key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }} + + - name: NPM install + if: steps.node_modules-cache.outputs.cache-hit != 'true' + run: npm ci --legacy-peer-deps + + # Creating a short lived node_modules cache + - uses: actions/cache/save@v4 + if: steps.node_modules-cache.outputs.cache-hit != 'true' + with: + path: | + ./node_modules + key: ${{ steps.node_modules-cache.outputs.cache-primary-key }} - name: Build plugin run: | diff --git a/.github/workflows/wordpress-version-checker.yml b/.github/workflows/wordpress-version-checker.yml index 8237e75f3..055870155 100644 --- a/.github/workflows/wordpress-version-checker.yml +++ b/.github/workflows/wordpress-version-checker.yml @@ -23,6 +23,6 @@ jobs: runs-on: ubuntu-latest steps: - name: WordPress Version Checker - uses: skaut/wordpress-version-checker@v2.1.0 + uses: skaut/wordpress-version-checker@v2.2.1 with: repo-token: ${{ secrets.GITHUB_TOKEN }}