diff --git a/.github/actions/setup-git/README.md b/.github/actions/setup-git/README.md new file mode 100644 index 00000000..f8c3d19f --- /dev/null +++ b/.github/actions/setup-git/README.md @@ -0,0 +1,25 @@ +# Set up Git + +This composite action configures SSH authentication, Git user identity, and optional commit signing. + +## Simple usage example + +```yml +steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-git + with: + ssh-private-key: ${{ secrets.GITHUB_USER_SSH_KEY }} + user-email: ${{ secrets.GITHUB_USER_EMAIL }} + user-name: ${{ secrets.GITHUB_USER_NAME }} +``` + +## Inputs + +| Name | Default | Description | +|---------------------|-----------|------------------------------------------------------------------------------------------------------------------| +| `ssh-private-key` | `''` | Private SSH key for authentication. | +| `user-email` | `''` | Git user email. | +| `user-name` | `''` | Git user name. | +| `ssh-public-key` | `''` | Public SSH key for commit signing. | +| `automated-commits` | `'false'` | Enable Git settings for automated commits (auto-tracks remote branches on push, silences ignored-file warnings). | diff --git a/.github/actions/setup-git/action.yml b/.github/actions/setup-git/action.yml new file mode 100644 index 00000000..e1950bd9 --- /dev/null +++ b/.github/actions/setup-git/action.yml @@ -0,0 +1,58 @@ +name: Set up Git +description: Set up SSH agent, Git identity, and optional commit signing. + +inputs: + ssh-private-key: + description: Private SSH key for authentication. + default: '' + required: false + user-email: + description: Git user email. + default: '' + required: false + user-name: + description: Git user name. + default: '' + required: false + ssh-public-key: + description: Public SSH key for commit signing. + default: '' + required: false + automated-commits: + description: Enable Git settings for automated commits (auto-tracks remote branches on push, silences ignored-file warnings). + default: 'false' + required: false + +runs: + using: composite + steps: + - name: Set up SSH + if: ${{ inputs.ssh-private-key != '' }} + uses: webfactory/ssh-agent@e83874834305fe9a4a2997156cb26c5de65a8555 # v0.10.0 + with: + ssh-private-key: ${{ inputs.ssh-private-key }} + + - name: Set up Git identity + if: ${{ inputs.user-email != '' && inputs.user-name != '' }} + shell: bash + run: | + git config --global user.email "${{ inputs.user-email }}" + git config --global user.name "${{ inputs.user-name }}" + + - name: Set up Git configuration + if: ${{ inputs.automated-commits == 'true' }} + shell: bash + run: | + git config --global advice.addIgnoredFile false + git config --global push.autoSetupRemote true + + - name: Set up commit signing + if: ${{ inputs.ssh-public-key != '' }} + shell: bash + run: | + : # Create empty SSH private key file so Git does not complain. + touch "${{ runner.temp }}/signingkey" + echo "${{ inputs.ssh-public-key }}" > "${{ runner.temp }}/signingkey.pub" + git config --global commit.gpgsign true + git config --global gpg.format ssh + git config --global user.signingkey "${{ runner.temp }}/signingkey.pub" diff --git a/.github/actions/setup-node/README.md b/.github/actions/setup-node/README.md new file mode 100644 index 00000000..1725de13 --- /dev/null +++ b/.github/actions/setup-node/README.md @@ -0,0 +1,26 @@ +# Set up Node + +This composite action sets up Node.js, automatically detects lock files for dependency caching, and installs project dependencies. + +## Simple usage example + +```yml +steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-node + with: + registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }} + node-auth-token: ${{ secrets.NPM_REGISTRY_TOKEN }} +``` + +## Inputs + +| Name | Default | Description | +|------------------------|---------------------------------|-------------------------------------------------------------------------------------------------------------| +| `node-version` | `'18'` | Node version to set up. | +| `node-version-file` | `''` | Path to a file containing the Node version (takes precedence over `node-version`). | +| `registry-url` | `'https://npm.pkg.github.com/'` | npm registry URL. | +| `node-auth-token` | `''` | Authentication token for the npm registry. | +| `node-options` | `''` | Space-separated list of command-line Node options. | +| `package-manager` | `'npm'` | Package manager to use (`npm` or `yarn`). **Deprecated:** yarn support will be removed in a future version. | +| `install-dependencies` | `'true'` | Whether to install dependencies (`'true'` or `'false'`). | diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml new file mode 100644 index 00000000..68d92c11 --- /dev/null +++ b/.github/actions/setup-node/action.yml @@ -0,0 +1,85 @@ +name: Set up Node +description: Set up Node with cache detection and dependency installation. + +inputs: + node-version: + description: Node version to set up. + default: '18' + required: false + node-version-file: + description: Path to a file containing the Node version (takes precedence over node-version). + default: '' + required: false + registry-url: + description: npm registry URL. + default: 'https://npm.pkg.github.com/' + required: false + node-auth-token: + description: Authentication token for the npm registry. + default: '' + required: false + node-options: + description: Space-separated list of command-line Node options. + default: '' + required: false + package-manager: + description: "Package manager to use (npm or yarn). Deprecated: yarn support will be removed in a future version." + default: 'npm' + required: false + install-dependencies: + description: Whether to install dependencies ('true' or 'false'). + default: 'true' + required: false + +runs: + using: composite + steps: + - name: Package manager deprecation warning + if: ${{ inputs.package-manager != 'npm' }} + shell: bash + run: | + echo "::warning::The package-manager input is deprecated and will be removed soon. Please update your workflow to use npm." + + - name: Detect cache mode + id: cache-detection + shell: bash + run: | + CACHE_MODE="" + if [ "${{ inputs.package-manager }}" == 'npm' ] && { [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; }; then + CACHE_MODE="npm" + elif [ "${{ inputs.package-manager }}" == 'yarn' ] && [ -f "${GITHUB_WORKSPACE}/yarn.lock" ]; then + CACHE_MODE="yarn" + else + echo "No lock files found for ${{ inputs.package-manager }}" + fi + echo "cache-mode=$CACHE_MODE" >> "$GITHUB_OUTPUT" + + - name: Set up Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + env: + NODE_OPTIONS: ${{ inputs.node-options }} + NODE_AUTH_TOKEN: ${{ inputs.node-auth-token }} + with: + node-version: ${{ inputs.node-version-file && '' || inputs.node-version }} + node-version-file: ${{ inputs.node-version-file }} + registry-url: ${{ inputs.registry-url }} + cache: ${{ steps.cache-detection.outputs.cache-mode }} + + - name: Install dependencies + if: ${{ inputs.install-dependencies == 'true' }} + shell: bash + run: | + CACHE_MODE="${{ steps.cache-detection.outputs.cache-mode }}" + if [ "${{ inputs.package-manager }}" == 'yarn' ]; then + if [ "$CACHE_MODE" == 'yarn' ]; then + yarn --frozen-lockfile + else + yarn install + fi + else + if [ "$CACHE_MODE" == 'npm' ]; then + npm ci + else + npm install + fi + fi diff --git a/.github/actions/setup-php/README.md b/.github/actions/setup-php/README.md new file mode 100644 index 00000000..ba344b37 --- /dev/null +++ b/.github/actions/setup-php/README.md @@ -0,0 +1,26 @@ +# Set up PHP + +This composite action sets up PHP, validates `composer.json`/`composer.lock`, and installs Composer dependencies. + +## Simple usage example + +```yml +steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-php + with: + composer-auth-json: ${{ secrets.COMPOSER_AUTH_JSON }} +``` + +## Inputs + +| Name | Default | Description | +|----------------------|-------------------|-------------------------------------------------------------------------------------------| +| `php-version` | `'8.2'` | PHP version to set up. | +| `php-extensions` | `''` | PHP extensions to install. | +| `php-tools` | `'composer'` | PHP tools to install (e.g. `composer`, `cs2pr`, `parallel-lint`). | +| `coverage` | `'none'` | Code coverage driver (`none`, `xdebug`, `pcov`, or empty for default). | +| `composer-install` | `'true'` | Whether to validate and install Composer dependencies (`'true'` or `'false'`). | +| `composer-options` | `'--prefer-dist'` | Arguments passed to Composer install. | +| `composer-auth-json` | `''` | Authentication for privately hosted packages and repositories as a JSON formatted object. | + diff --git a/.github/actions/setup-php/action.yml b/.github/actions/setup-php/action.yml new file mode 100644 index 00000000..fb50941c --- /dev/null +++ b/.github/actions/setup-php/action.yml @@ -0,0 +1,56 @@ +name: Set up PHP +description: Set up PHP, validate and install Composer dependencies. + +inputs: + php-version: + description: PHP version to set up. + default: '8.2' + required: false + php-extensions: + description: PHP extensions to install. + default: '' + required: false + php-tools: + description: PHP tools to install (e.g. composer, cs2pr, parallel-lint). + default: 'composer' + required: false + coverage: + description: Code coverage driver (none, xdebug, pcov, or empty for default). + default: 'none' + required: false + composer-install: + description: Whether to validate and install Composer dependencies ('true' or 'false'). + default: 'true' + required: false + composer-options: + description: Arguments passed to Composer install. + default: '--prefer-dist' + required: false + composer-auth-json: + description: Authentication for privately hosted packages and repositories as a JSON formatted object. + default: '' + required: false + +runs: + using: composite + steps: + - name: Set up PHP + uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 + with: + php-version: ${{ inputs.php-version }} + extensions: ${{ inputs.php-extensions }} + tools: ${{ inputs.php-tools }} + coverage: ${{ inputs.coverage }} + + - name: Validate composer.json and composer.lock + if: ${{ inputs.composer-install == 'true' }} + shell: bash + run: composer validate + + - name: Install Composer dependencies + if: ${{ inputs.composer-install == 'true' }} + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + env: + COMPOSER_AUTH: ${{ inputs.composer-auth-json }} + with: + composer-options: ${{ inputs.composer-options }} diff --git a/.github/workflows/automatic-release.yml b/.github/workflows/automatic-release.yml index a2b6608f..2ef0fb99 100644 --- a/.github/workflows/automatic-release.yml +++ b/.github/workflows/automatic-release.yml @@ -44,13 +44,13 @@ jobs: sparse-checkout-cone-mode: false path: semantic-release-repo - - name: Set up node - uses: actions/setup-node@v4 - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} + - name: Set up Node + uses: inpsyde/reusable-workflows/.github/actions/setup-node@main with: node-version-file: semantic-release-repo/package.json registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }} + node-auth-token: ${{ secrets.NPM_REGISTRY_TOKEN }} + install-dependencies: 'false' - name: Install dependencies run: | @@ -68,25 +68,13 @@ jobs: persist-credentials: false ssh-key: ${{ secrets.GITHUB_USER_SSH_KEY }} - - name: Set up SSH - env: - GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }} - if: ${{ env.GITHUB_USER_SSH_KEY != '' }} - uses: webfactory/ssh-agent@v0.9.1 + - name: Set up Git + uses: inpsyde/reusable-workflows/.github/actions/setup-git@main with: - ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }} - - - name: Set up signing commits - env: - GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.GITHUB_USER_SSH_PUBLIC_KEY }} - if: ${{ env.GITHUB_USER_SSH_PUBLIC_KEY != '' }} - run: | - : # Create empty SSH private key file so Git does not complain. - touch "${{ runner.temp }}/signingkey" - echo "${{ env.GITHUB_USER_SSH_PUBLIC_KEY }}" > "${{ runner.temp }}/signingkey.pub" - git config --global commit.gpgsign true - git config --global gpg.format ssh - git config --global user.signingkey "${{ runner.temp }}/signingkey.pub" + ssh-private-key: ${{ secrets.GITHUB_USER_SSH_KEY }} + ssh-public-key: ${{ secrets.GITHUB_USER_SSH_PUBLIC_KEY }} + user-email: ${{ secrets.GITHUB_USER_EMAIL }} + user-name: ${{ secrets.GITHUB_USER_NAME }} - name: Check presence of release.config.js run: | @@ -113,25 +101,8 @@ jobs: run: | rm -rf workflow-repo - - name: Set up release environment variables - env: - GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }} - GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }} - run: | - ${{ env.GITHUB_USER_EMAIL != '' }} && echo "GIT_AUTHOR_EMAIL=${{ env.GITHUB_USER_EMAIL }}" >> $GITHUB_ENV || true - ${{ env.GITHUB_USER_NAME != '' }} && echo "GIT_AUTHOR_NAME=${{ env.GITHUB_USER_NAME }}" >> $GITHUB_ENV || true - ${{ env.GITHUB_USER_EMAIL != '' }} && echo "GIT_COMMITTER_EMAIL=${{ env.GITHUB_USER_EMAIL }}" >> $GITHUB_ENV || true - ${{ env.GITHUB_USER_NAME != '' }} && echo "GIT_COMMITTER_NAME=${{ env.GITHUB_USER_NAME }}" >> $GITHUB_ENV || true - - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_USER_TOKEN != '' && secrets.GITHUB_USER_TOKEN || secrets.GITHUB_TOKEN }} run: npx semantic-release - - name: Delete signing key files - env: - GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.GITHUB_USER_SSH_PUBLIC_KEY }} - if: ${{ always() && env.GITHUB_USER_SSH_PUBLIC_KEY != '' }} - run: | - rm -f "${{ runner.temp }}/signingkey" - rm -f "${{ runner.temp }}/signingkey.pub" diff --git a/.github/workflows/build-and-distribute.yml b/.github/workflows/build-and-distribute.yml index de676838..8b4f13d5 100644 --- a/.github/workflows/build-and-distribute.yml +++ b/.github/workflows/build-and-distribute.yml @@ -107,26 +107,14 @@ jobs: fetch-depth: 0 ssh-key: ${{ secrets.GITHUB_USER_SSH_KEY }} - - name: Set up SSH - uses: webfactory/ssh-agent@v0.9.0 + - name: Set up Git + uses: inpsyde/reusable-workflows/.github/actions/setup-git@main with: ssh-private-key: ${{ secrets.GITHUB_USER_SSH_KEY }} - - - name: Set up Git - run: | - git config --global user.email "${{ secrets.GITHUB_USER_EMAIL }}" - git config --global user.name "${{ secrets.GITHUB_USER_NAME }}" - git config --global advice.addIgnoredFile false - git config --global push.autoSetupRemote true - - - name: Set up signing commits - run: | - : # Create empty SSH private key file so Git does not complain. - touch "${{ runner.temp }}/signingkey" - echo "${{ secrets.GITHUB_USER_SSH_PUBLIC_KEY }}" > "${{ runner.temp }}/signingkey.pub" - git config --global commit.gpgsign true - git config --global gpg.format ssh - git config --global user.signingkey "${{ runner.temp }}/signingkey.pub" + user-email: ${{ secrets.GITHUB_USER_EMAIL }} + user-name: ${{ secrets.GITHUB_USER_NAME }} + ssh-public-key: ${{ secrets.GITHUB_USER_SSH_PUBLIC_KEY }} + automated-commits: 'true' - name: Set up custom environment variables env: @@ -269,18 +257,13 @@ jobs: with: composer-options: ${{ inputs.COMPOSER_ARGS }} - - name: Set up node - uses: actions/setup-node@v4 - env: - NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} + - name: Set up Node + uses: inpsyde/reusable-workflows/.github/actions/setup-node@main with: node-version: ${{ inputs.NODE_VERSION }} registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }} - cache: npm - - - name: Install dependencies - run: npm ci + node-auth-token: ${{ secrets.NPM_REGISTRY_TOKEN }} + node-options: ${{ inputs.NODE_OPTIONS }} - name: Determine package type run: | @@ -399,8 +382,3 @@ jobs: include-hidden-files: true compression-level: 9 - - name: Delete signing key files - if: ${{ always() }} - run: | - rm -f "${{ runner.temp }}/signingkey" - rm -f "${{ runner.temp }}/signingkey.pub" diff --git a/.github/workflows/coding-standards-php.yml b/.github/workflows/coding-standards-php.yml index 40575fd3..b0b60f24 100644 --- a/.github/workflows/coding-standards-php.yml +++ b/.github/workflows/coding-standards-php.yml @@ -56,22 +56,13 @@ jobs: .forEach(envVar => core.exportVariable(envVar.name, envVar.value)); - name: Set up PHP - uses: shivammathur/setup-php@v2 + uses: inpsyde/reusable-workflows/.github/actions/setup-php@main with: php-version: ${{ inputs.PHP_VERSION }} - extensions: ${{ inputs.PHP_EXTENSIONS }} - tools: composer, cs2pr - coverage: none - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install Composer dependencies - uses: ramsey/composer-install@v3 - env: - COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}' - with: + php-extensions: ${{ inputs.PHP_EXTENSIONS }} + php-tools: 'composer, cs2pr' composer-options: ${{ inputs.COMPOSER_ARGS }} + composer-auth-json: ${{ secrets.COMPOSER_AUTH_JSON }} - name: Run PHP_CodeSniffer run: ./$(composer config bin-dir)/phpcs ${{ inputs.PHPCS_ARGS }} diff --git a/.github/workflows/deploy-deployer.yml b/.github/workflows/deploy-deployer.yml index b25f5d75..9bb92aa3 100644 --- a/.github/workflows/deploy-deployer.yml +++ b/.github/workflows/deploy-deployer.yml @@ -63,7 +63,6 @@ jobs: deploy: runs-on: ubuntu-latest env: - NODE_CACHE_MODE: '' COMPOSER_NO_DEV: 1 steps: @@ -73,19 +72,11 @@ jobs: fetch-depth: 0 ssh-key: ${{ secrets.GITHUB_USER_SSH_KEY }} - - name: Set up SSH - uses: webfactory/ssh-agent@v0.9.1 + - name: Set up Git + uses: inpsyde/reusable-workflows/.github/actions/setup-git@main with: ssh-private-key: ${{ secrets.GITHUB_USER_SSH_KEY }} - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ inputs.PHP_VERSION }} - extensions: ${{ inputs.PHP_EXTENSIONS }} - tools: composer, ${{ inputs.PHP_TOOLS }} - coverage: none - - name: Set up WireGuard uses: inpsyde/actions/setup-wireguard@v1 env: @@ -94,13 +85,14 @@ jobs: with: wireguard-configuration: ${{ secrets.WIREGUARD_CONFIGURATION }} - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install Composer dependencies - uses: ramsey/composer-install@v3 - env: - COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}' + - name: Set up PHP + uses: inpsyde/reusable-workflows/.github/actions/setup-php@main + with: + php-version: ${{ inputs.PHP_VERSION }} + php-extensions: ${{ inputs.PHP_EXTENSIONS }} + php-tools: 'composer, ${{ inputs.PHP_TOOLS }}' + composer-options: '' + composer-auth-json: ${{ secrets.COMPOSER_AUTH_JSON }} - name: Detect npm workspaces id: npm-workspaces @@ -111,27 +103,13 @@ jobs: echo "enabled=false" >> $GITHUB_OUTPUT fi - - name: Set up node cache mode - run: | - if [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; then - echo "NODE_CACHE_MODE=npm" >> $GITHUB_ENV - else - echo "No lock files found or unknown package manager" - fi - - - name: Set up node + - name: Set up Node if: steps.npm-workspaces.outputs.enabled == 'true' - uses: actions/setup-node@v4 - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} + uses: inpsyde/reusable-workflows/.github/actions/setup-node@main with: node-version: ${{ inputs.NODE_VERSION }} registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }} - cache: ${{ env.NODE_CACHE_MODE }} - - - name: Install npm dependencies - if: steps.npm-workspaces.outputs.enabled == 'true' - run: npm ${{ env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} + node-auth-token: ${{ secrets.NPM_REGISTRY_TOKEN }} - name: Run the build using workspaces if: steps.npm-workspaces.outputs.enabled == 'true' @@ -155,6 +133,7 @@ jobs: - name: Run Deployer env: + ENVIRONMENT: ${{ inputs.ENVIRONMENT }} DEPLOY_HOSTNAME: ${{ secrets.DEPLOY_HOSTNAME }} DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }} DEPLOY_USER: ${{ secrets.DEPLOY_USER }} diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml index 28c9397b..639224b8 100644 --- a/.github/workflows/lint-php.yml +++ b/.github/workflows/lint-php.yml @@ -56,20 +56,14 @@ jobs: .forEach(envVar => core.exportVariable(envVar.name, envVar.value)); - name: Set up PHP - uses: shivammathur/setup-php@v2 + uses: inpsyde/reusable-workflows/.github/actions/setup-php@main with: php-version: ${{ inputs.PHP_VERSION }} - extensions: ${{ inputs.PHP_EXTENSIONS }} - tools: cs2pr, parallel-lint - coverage: none - - - name: Install Composer dependencies - if: ${{ inputs.COMPOSER_DEPS_INSTALL }} - uses: ramsey/composer-install@v3 - env: - COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}' - with: + php-extensions: ${{ inputs.PHP_EXTENSIONS }} + php-tools: 'cs2pr, parallel-lint' + composer-install: ${{ inputs.COMPOSER_DEPS_INSTALL }} composer-options: ${{ inputs.COMPOSER_ARGS }} + composer-auth-json: ${{ secrets.COMPOSER_AUTH_JSON }} - name: Run PHP lint check run: parallel-lint ${{ inputs.LINT_ARGS }} --checkstyle | cs2pr diff --git a/.github/workflows/static-analysis-js.yml b/.github/workflows/static-analysis-js.yml index 290f744c..543d6f0c 100644 --- a/.github/workflows/static-analysis-js.yml +++ b/.github/workflows/static-analysis-js.yml @@ -39,8 +39,6 @@ jobs: static-analysis-js: timeout-minutes: 5 runs-on: ubuntu-latest - env: - NODE_CACHE_MODE: '' steps: - name: Checkout uses: actions/checkout@v4 @@ -56,45 +54,20 @@ jobs: .parse(process.env.ENV_VARS) .forEach(envVar => core.exportVariable(envVar.name, envVar.value)); - - name: Set up SSH - env: - GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }} - if: ${{ env.GITHUB_USER_SSH_KEY != '' }} - uses: webfactory/ssh-agent@v0.9.1 - with: - ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }} - - name: Set up Git - env: - GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }} - GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }} - if: ${{ env.GITHUB_USER_EMAIL != '' && env.GITHUB_USER_NAME != '' }} - run: | - git config --global user.email "${{ env.GITHUB_USER_EMAIL }}" - git config --global user.name "${{ env.GITHUB_USER_NAME }}" - - - name: Set up node cache mode - run: | - if [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; then - echo "NODE_CACHE_MODE=npm" >> $GITHUB_ENV - else - echo "No lock files found" - fi + uses: inpsyde/reusable-workflows/.github/actions/setup-git@main + with: + ssh-private-key: ${{ secrets.GITHUB_USER_SSH_KEY }} + user-email: ${{ secrets.GITHUB_USER_EMAIL }} + user-name: ${{ secrets.GITHUB_USER_NAME }} - - name: Set up node - uses: actions/setup-node@v4 - env: - NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} + - name: Set up Node + uses: inpsyde/reusable-workflows/.github/actions/setup-node@main with: node-version: ${{ inputs.NODE_VERSION }} registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }} - cache: ${{ env.NODE_CACHE_MODE }} - - - name: Install dependencies - env: - ARGS: ${{ env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} - run: ${{ format('npm {0}', env.ARGS) }} + node-auth-token: ${{ secrets.NPM_REGISTRY_TOKEN }} + node-options: ${{ inputs.NODE_OPTIONS }} - name: Run tsc run: ./node_modules/.bin/tsc --noEmit --skipLibCheck --pretty false diff --git a/.github/workflows/static-analysis-php.yml b/.github/workflows/static-analysis-php.yml index 61b8a333..5b40a056 100644 --- a/.github/workflows/static-analysis-php.yml +++ b/.github/workflows/static-analysis-php.yml @@ -56,22 +56,13 @@ jobs: .forEach(envVar => core.exportVariable(envVar.name, envVar.value)); - name: Set up PHP - uses: shivammathur/setup-php@v2 + uses: inpsyde/reusable-workflows/.github/actions/setup-php@main with: php-version: ${{ inputs.PHP_VERSION }} - extensions: ${{ inputs.PHP_EXTENSIONS }} - tools: composer, cs2pr - coverage: none - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install Composer dependencies - uses: ramsey/composer-install@v3 - env: - COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}' - with: + php-extensions: ${{ inputs.PHP_EXTENSIONS }} + php-tools: 'composer, cs2pr' composer-options: ${{ inputs.COMPOSER_ARGS }} + composer-auth-json: ${{ secrets.COMPOSER_AUTH_JSON }} - name: Run Psalm if: ${{ hashFiles('psalm.xml', 'psalm.xml.dist') != '' }} diff --git a/.github/workflows/test-playwright.yml b/.github/workflows/test-playwright.yml index 371d8bb4..03124dbb 100644 --- a/.github/workflows/test-playwright.yml +++ b/.github/workflows/test-playwright.yml @@ -116,64 +116,31 @@ jobs: runs-on: ubuntu-latest env: PHP_CHECK: false - NODE_CACHE_MODE: '' steps: - name: Checkout uses: actions/checkout@v4 - - name: Set up SSH - env: - GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }} - if: ${{ env.GITHUB_USER_SSH_KEY != '' }} - uses: webfactory/ssh-agent@v0.9.1 - with: - ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }} - - name: Set up Git - env: - GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }} - GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }} - if: ${{ env.GITHUB_USER_EMAIL != '' && env.GITHUB_USER_NAME != '' }} - run: | - git config --global user.email "${{ env.GITHUB_USER_EMAIL }}" - git config --global user.name "${{ env.GITHUB_USER_NAME }}" - - - name: Set up node cache mode - run: | - if [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; then - echo "NODE_CACHE_MODE=npm" >> $GITHUB_ENV - else - echo "No lock files found or unknown package manager" - fi + uses: inpsyde/reusable-workflows/.github/actions/setup-git@main + with: + ssh-private-key: ${{ secrets.GITHUB_USER_SSH_KEY }} + user-email: ${{ secrets.GITHUB_USER_EMAIL }} + user-name: ${{ secrets.GITHUB_USER_NAME }} - name: Set up PHP if: ${{ inputs.COMPOSER_DEPS_INSTALL }} - uses: shivammathur/setup-php@v2 + uses: inpsyde/reusable-workflows/.github/actions/setup-php@main with: php-version: ${{ inputs.PHP_VERSION }} - extensions: ${{ inputs.PHP_EXTENSIONS }} - tools: composer - coverage: none - - - name: Install Composer dependencies - if: ${{ inputs.COMPOSER_DEPS_INSTALL }} - uses: ramsey/composer-install@v3 - env: - COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}' - with: - composer-options: '--prefer-dist' + php-extensions: ${{ inputs.PHP_EXTENSIONS }} + composer-auth-json: ${{ secrets.COMPOSER_AUTH_JSON }} - - name: Set up node - uses: actions/setup-node@v4 - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} + - name: Set up Node + uses: inpsyde/reusable-workflows/.github/actions/setup-node@main with: node-version: ${{ inputs.NODE_VERSION }} registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }} - cache: ${{ env.NODE_CACHE_MODE }} - - - name: Install dependencies - run: npm ${{ env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} + node-auth-token: ${{ secrets.NPM_REGISTRY_TOKEN }} - name: Build assets run: npm run build --if-present diff --git a/.github/workflows/tests-unit-js.yml b/.github/workflows/tests-unit-js.yml index e6725c18..3502d480 100644 --- a/.github/workflows/tests-unit-js.yml +++ b/.github/workflows/tests-unit-js.yml @@ -49,18 +49,7 @@ jobs: tests-unit-js: timeout-minutes: 5 runs-on: ubuntu-latest - env: - NODE_CACHE_MODE: '' steps: - - name: PACKAGE_MANAGER deprecation warning - if: ${{ inputs.PACKAGE_MANAGER != '' }} - run: | - if [ "${{ inputs.PACKAGE_MANAGER }}" == 'npm' ]; then - echo "::warning::The PACKAGE_MANAGER input is deprecated and will be removed soon. Please remove it. The workflow already uses npm by default." - else - echo "::warning::The PACKAGE_MANAGER input is deprecated and will be removed soon. Please update your workflow to use npm." - fi - - name: Checkout uses: actions/checkout@v4 @@ -75,47 +64,21 @@ jobs: .parse(process.env.ENV_VARS) .forEach(envVar => core.exportVariable(envVar.name, envVar.value)); - - name: Set up SSH - env: - GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }} - if: ${{ env.GITHUB_USER_SSH_KEY != '' }} - uses: webfactory/ssh-agent@v0.9.1 - with: - ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }} - - name: Set up Git - env: - GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }} - GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }} - if: ${{ env.GITHUB_USER_EMAIL != '' && env.GITHUB_USER_NAME != '' }} - run: | - git config --global user.email "${{ env.GITHUB_USER_EMAIL }}" - git config --global user.name "${{ env.GITHUB_USER_NAME }}" - - - name: Set up node cache mode - run: | - if [ "${{ inputs.PACKAGE_MANAGER }}" == 'npm' ] && { [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; }; then - echo "NODE_CACHE_MODE=npm" >> $GITHUB_ENV - elif [ "${{ inputs.PACKAGE_MANAGER }}" == 'yarn' ] && [ -f "${GITHUB_WORKSPACE}/yarn.lock" ]; then - echo "NODE_CACHE_MODE=yarn" >> $GITHUB_ENV - else - echo "No lock files found or unknown package manager" - fi + uses: inpsyde/reusable-workflows/.github/actions/setup-git@main + with: + ssh-private-key: ${{ secrets.GITHUB_USER_SSH_KEY }} + user-email: ${{ secrets.GITHUB_USER_EMAIL }} + user-name: ${{ secrets.GITHUB_USER_NAME }} - - name: Set up node - uses: actions/setup-node@v4 - env: - NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} + - name: Set up Node + uses: inpsyde/reusable-workflows/.github/actions/setup-node@main with: node-version: ${{ inputs.NODE_VERSION }} registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }} - cache: ${{ env.NODE_CACHE_MODE }} - - - name: Install dependencies - env: - ARGS: ${{ env.NODE_CACHE_MODE == 'yarn' && '--frozen-lockfile' || env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} - run: ${{ format('{0} {1}', inputs.PACKAGE_MANAGER, env.ARGS) }} + node-auth-token: ${{ secrets.NPM_REGISTRY_TOKEN }} + node-options: ${{ inputs.NODE_OPTIONS }} + package-manager: ${{ inputs.PACKAGE_MANAGER }} - name: Run Jest run: ./node_modules/.bin/jest ${{ inputs.JEST_ARGS }} diff --git a/.github/workflows/tests-unit-php.yml b/.github/workflows/tests-unit-php.yml index c91911ab..10359bd3 100644 --- a/.github/workflows/tests-unit-php.yml +++ b/.github/workflows/tests-unit-php.yml @@ -51,20 +51,17 @@ jobs: .forEach(envVar => core.exportVariable(envVar.name, envVar.value)); - name: Set up PHP - uses: shivammathur/setup-php@v2 + uses: inpsyde/reusable-workflows/.github/actions/setup-php@main with: php-version: ${{ inputs.PHP_VERSION }} - extensions: ${{ inputs.PHP_EXTENSIONS }} + php-extensions: ${{ inputs.PHP_EXTENSIONS }} + php-tools: '' + coverage: '' + composer-options: ${{ inputs.COMPOSER_ARGS }} + composer-auth-json: ${{ secrets.COMPOSER_AUTH_JSON }} - name: Set up problem matchers for PHPUnit run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Install Composer dependencies - uses: ramsey/composer-install@v3 - env: - COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}' - with: - composer-options: ${{ inputs.COMPOSER_ARGS }} - - name: Run PHPUnit run: ./$(composer config bin-dir)/phpunit ${{ inputs.PHPUNIT_ARGS }} diff --git a/.github/workflows/wp-scripts-lint.yml b/.github/workflows/wp-scripts-lint.yml index 3b81f5f4..be946d1f 100644 --- a/.github/workflows/wp-scripts-lint.yml +++ b/.github/workflows/wp-scripts-lint.yml @@ -70,18 +70,7 @@ jobs: static-analysis-assets: timeout-minutes: 5 runs-on: ubuntu-latest - env: - NODE_CACHE_MODE: '' steps: - - name: PACKAGE_MANAGER deprecation warning - if: ${{ inputs.PACKAGE_MANAGER != '' }} - run: | - if [ "${{ inputs.PACKAGE_MANAGER }}" == 'npm' ]; then - echo "::warning::The PACKAGE_MANAGER input is deprecated and will be removed soon. Please remove it. The workflow already uses npm by default." - else - echo "::warning::The PACKAGE_MANAGER input is deprecated and will be removed soon. Please update your workflow to use npm." - fi - - name: Checkout uses: actions/checkout@v4 @@ -96,47 +85,21 @@ jobs: .parse(process.env.ENV_VARS) .forEach(envVar => core.exportVariable(envVar.name, envVar.value)); - - name: Set up SSH - env: - GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }} - if: ${{ env.GITHUB_USER_SSH_KEY != '' }} - uses: webfactory/ssh-agent@v0.9.1 - with: - ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }} - - name: Set up Git - env: - GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }} - GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }} - if: ${{ env.GITHUB_USER_EMAIL != '' && env.GITHUB_USER_NAME != '' }} - run: | - git config --global user.email "${{ env.GITHUB_USER_EMAIL }}" - git config --global user.name "${{ env.GITHUB_USER_NAME }}" - - - name: Set up node cache mode - run: | - if [ "${{ inputs.PACKAGE_MANAGER }}" == 'npm' ] && { [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; }; then - echo "NODE_CACHE_MODE=npm" >> $GITHUB_ENV - elif [ "${{ inputs.PACKAGE_MANAGER }}" == 'yarn' ] && [ -f "${GITHUB_WORKSPACE}/yarn.lock" ]; then - echo "NODE_CACHE_MODE=yarn" >> $GITHUB_ENV - else - echo "No lock files found or unknown package manager" - fi + uses: inpsyde/reusable-workflows/.github/actions/setup-git@main + with: + ssh-private-key: ${{ secrets.GITHUB_USER_SSH_KEY }} + user-email: ${{ secrets.GITHUB_USER_EMAIL }} + user-name: ${{ secrets.GITHUB_USER_NAME }} - - name: Set up node - uses: actions/setup-node@v4 - env: - NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} + - name: Set up Node + uses: inpsyde/reusable-workflows/.github/actions/setup-node@main with: node-version: ${{ inputs.NODE_VERSION }} registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }} - cache: ${{ env.NODE_CACHE_MODE }} - - - name: Install dependencies - env: - ARGS: ${{ env.NODE_CACHE_MODE == 'yarn' && '--frozen-lockfile' || env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} - run: ${{ format('{0} {1}', inputs.PACKAGE_MANAGER, env.ARGS) }} + node-auth-token: ${{ secrets.NPM_REGISTRY_TOKEN }} + node-options: ${{ inputs.NODE_OPTIONS }} + package-manager: ${{ inputs.PACKAGE_MANAGER }} - name: Lint script files if: ${{ contains(fromJSON(inputs.LINT_TOOLS), 'js') }}