Compare commits

..

30 Commits

Author SHA1 Message Date
Shivam Mathur f3e473d116 Bump version to 2.37.2
Update Node.js dependencies
2026-06-08 20:54:40 +05:30
Shivam Mathur 8be473cdc3 Trust brew taps 2026-06-08 20:54:32 +05:30
dependabot[bot] 083d5237d9 Bump the github-actions group with 2 updates (#1085)
Bumps the github-actions group with 2 updates: [github/codeql-action](https://github.com/github/codeql-action) and [codecov/codecov-action](https://github.com/codecov/codecov-action).


Updates `github/codeql-action` from 4.35.5 to 4.36.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/9e0d7b8d25671d64c341c19c0152d693099fb5ba...7211b7c8077ea37d8641b6271f6a365a22a5fbfa)

Updates `codecov/codecov-action` from 6.0.0 to 6.0.1
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/57e3a136b779b570ffcdbf80b3bdc90e7fab3de2...e79a6962e0d4c0c17b229090214935d2e33f8354)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: codecov/codecov-action
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-30 16:35:36 +05:30
Shivam Mathur a919ff576a Update FUNDING.yml 2026-05-19 03:02:31 +05:30
Shivam Mathur deb2299a77 Harden GitHub Actions workflows 2026-05-18 00:56:40 +05:30
Shivam Mathur 5825be4b77 Harden environment lookup 2026-05-18 00:56:40 +05:30
Shivam Mathur 8d45593ff3 Add CODEOWNERS 2026-05-15 23:46:09 +05:30
Shivam Mathur ba8d1631c1 Update PHP versions in SECURITY.md 2026-05-15 01:33:20 +05:30
Shivam Mathur 7c071dfe9d Bump version to 2.37.1
Update Node.js dependencies
2026-05-14 08:58:36 +05:30
Shivam Mathur eeef37e059 GHSA-pqwm-q9pv-ph8r - Fix CWE-78 [skip ci] 2026-05-14 08:58:36 +05:30
Shivam Mathur 0dc33069a3 Fix phalcon5 support on Windows 2026-05-14 03:00:30 +05:30
Shivam Mathur 680a983990 Fix phalcon version for PHP 8.0 [skip ci] 2026-05-14 03:00:29 +05:30
Shivam Mathur 694649a4a3 Fix mutable tool cache restore 2026-05-13 19:43:21 +05:30
Shivam Mathur 46a991b6aa Merge pull request #1081 from Pyker/patch-1
Fix composer v2 version in README
2026-05-13 16:22:14 +05:30
Shivam Mathur 7748c24380 GHSA-f9f8-rm49-7jv2: Fix GitHub auth handling for composer in affected versions 2026-05-13 16:19:11 +05:30
Pedro Cunha ac9c953234 Fix composer v2 version in README 2026-05-13 10:26:15 +01:00
Shivam Mathur 7729e411ec Improve enabling gearman [skip ci] 2026-04-29 01:00:16 +05:30
Shivam Mathur af2322b95c Fix fallback in Install-PSPackage on Windows 2026-04-26 23:49:26 +05:30
Shivam Mathur 45e37a5311 Update os_releases.csv [skip ci] 2026-04-26 15:12:30 +05:30
Shivam Mathur 690cb7c9d8 Merge pull request #1074 from shivammathur/dependabot/github_actions/develop/codecov/codecov-action-6
Bump codecov/codecov-action from 5 to 6
2026-03-30 17:04:06 +05:30
dependabot[bot] b2cf73f5fa Bump codecov/codecov-action from 5 to 6
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5 to 6.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-30 11:19:53 +00:00
Shivam Mathur 64e2975255 Update dependencies 2026-03-29 20:51:51 +05:30
Shivam Mathur 106fd0866c Strip backslash line continuation from extension inputs 2026-03-29 20:46:19 +05:30
Shivam Mathur 44724c9282 Merge pull request #1072 from shivammathur/dependabot/npm_and_yarn/npm_and_yarn-66413a1f6e
Bump picomatch from 2.3.1 to 2.3.2 in the npm_and_yarn group across 1 directory
2026-03-26 07:42:11 +05:30
dependabot[bot] 2fa35d2e4e Bump picomatch in the npm_and_yarn group across 1 directory
Bumps the npm_and_yarn group with 1 update in the / directory: [picomatch](https://github.com/micromatch/picomatch).


Updates `picomatch` from 2.3.1 to 2.3.2
- [Release notes](https://github.com/micromatch/picomatch/releases)
- [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/picomatch/compare/2.3.1...2.3.2)

---
updated-dependencies:
- dependency-name: picomatch
  dependency-version: 2.3.2
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-26 00:21:48 +00:00
Shivam Mathur 29e04e0a1d Add workflow examples for Drupal and WordPress plugins 2026-03-23 14:33:38 +05:30
Shivam Mathur ea13793c13 Merge pull request #1071 from shivammathur/dependabot/npm_and_yarn/npm_and_yarn-e5a595f223
Bump flatted from 3.4.1 to 3.4.2 in the npm_and_yarn group across 1 directory
2026-03-22 02:27:26 +05:30
dependabot[bot] fd580061e0 Bump flatted in the npm_and_yarn group across 1 directory
Bumps the npm_and_yarn group with 1 update in the / directory: [flatted](https://github.com/WebReflection/flatted).


Updates `flatted` from 3.4.1 to 3.4.2
- [Commits](https://github.com/WebReflection/flatted/compare/v3.4.1...v3.4.2)

---
updated-dependencies:
- dependency-name: flatted
  dependency-version: 3.4.2
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-21 20:14:26 +00:00
Shivam Mathur 90d81e2adc Update examples 2026-03-21 21:47:58 +05:30
Shivam Mathur 93cb3149d2 Fix permission for OIDC tokens in publish.yml for trusted publishing [skip ci] 2026-03-15 22:01:57 +05:30
58 changed files with 1682 additions and 1060 deletions
+1
View File
@@ -0,0 +1 @@
* @shivammathur
+1
View File
@@ -1,3 +1,4 @@
# These are supported funding model platforms # These are supported funding model platforms
github: shivammathur github: shivammathur
open_collective: setup-php
+1 -1
View File
@@ -10,10 +10,10 @@ This security policy only applies to the latest patch releases of the following
| Version | Supported | | Version | Supported |
|---------|--------------------| |---------|--------------------|
| 8.1 | :white_check_mark: |
| 8.2 | :white_check_mark: | | 8.2 | :white_check_mark: |
| 8.3 | :white_check_mark: | | 8.3 | :white_check_mark: |
| 8.4 | :white_check_mark: | | 8.4 | :white_check_mark: |
| 8.5 | :white_check_mark: |
## Reporting a Vulnerability ## Reporting a Vulnerability
+11 -5
View File
@@ -1,7 +1,13 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: "github-actions" - package-ecosystem: 'github-actions'
directory: "/" directory: '/'
target-branch: "develop" target-branch: 'develop'
schedule: schedule:
interval: "weekly" interval: 'weekly'
groups:
github-actions:
patterns:
- '*'
cooldown:
default-days: 7
+9 -4
View File
@@ -5,9 +5,13 @@ on:
- cron: '0 15 * * 6' - cron: '0 15 * * 6'
permissions: permissions:
contents: read contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs: jobs:
codeql: codeql:
name: CodeQL Analysis
if: github.event.repository.fork == false if: github.event.repository.fork == false
permissions: permissions:
actions: read # for github/codeql-action/init to get workflow details actions: read # for github/codeql-action/init to get workflow details
@@ -16,18 +20,19 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
fetch-depth: 2 fetch-depth: 2
persist-credentials: false
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v4 uses: github/codeql-action/init@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4
with: with:
config-file: ./.github/codeql/codeql-configuration.yml config-file: ./.github/codeql/codeql-configuration.yml
languages: javascript languages: javascript
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v4 uses: github/codeql-action/autobuild@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4 uses: github/codeql-action/analyze@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4
+20 -10
View File
@@ -5,12 +5,15 @@ on:
- cron: '0 15 * * 6' - cron: '0 15 * * 6'
permissions: permissions:
contents: read contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs: jobs:
create: create:
if: github.event.repository.fork == false if: github.event.repository.fork == false
permissions: permissions:
contents: none contents: none # this job only prepares artifacts and uploads them, no repository writes
name: Create name: Create
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
strategy: strategy:
@@ -20,7 +23,7 @@ jobs:
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6'] php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
steps: steps:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
tools: none tools: none
@@ -39,7 +42,7 @@ jobs:
run: | run: |
php -m | Out-File -FilePath "$env:file.all" -Append php -m | Out-File -FilePath "$env:file.all" -Append
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: none extensions: none
@@ -72,7 +75,7 @@ jobs:
version: ${{ matrix.php-versions }} version: ${{ matrix.php-versions }}
if: matrix.operating-system == 'windows-2022' if: matrix.operating-system == 'windows-2022'
run: | run: |
Write-Output "## PHP ${{ matrix.php-versions }}`n" | Out-File -FilePath "$env:file" Write-Output "## PHP $env:version`n" | Out-File -FilePath "$env:file"
Write-Output "``````" | Out-File -FilePath "$env:file" -Append Write-Output "``````" | Out-File -FilePath "$env:file" -Append
php -m | Out-File -FilePath "$env:file.builtin" -Append php -m | Out-File -FilePath "$env:file.builtin" -Append
Get-Content "$env:file.all" | ForEach-Object { Get-Content "$env:file.all" | ForEach-Object {
@@ -88,7 +91,7 @@ jobs:
Remove-Item "$env:file.all" -Force Remove-Item "$env:file.all" -Force
Remove-Item "$env:file.builtin" -Force Remove-Item "$env:file.builtin" -Force
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v7 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with: with:
name: lists-php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md name: lists-php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
path: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md path: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
@@ -101,19 +104,23 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
repository: ${{ github.repository }}.wiki repository: ${{ github.repository }}.wiki
persist-credentials: false
- name: Download artifacts - name: Download artifacts
uses: actions/download-artifact@v8 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with: with:
path: ${{ github.workspace }}/lists path: ${{ github.workspace }}/lists
pattern: lists-* pattern: lists-*
merge-multiple: true merge-multiple: true
- name: Configure Git - name: Configure Git
env:
GIT_USER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GIT_USER_NAME: github-actions[bot]
run : | run : |
git config --local user.email "${{ secrets.email }}" git config --local user.email "$GIT_USER_EMAIL"
git config --local user.name "${{ github.repository_owner }}" git config --local user.name "$GIT_USER_NAME"
- name: Combine - name: Combine
run: | run: |
for os in ubuntu-24.04 ubuntu-22.04 windows-2025 windows-2022 windows-2019 macos-13 macos-14 macos-15 macos-26; do for os in ubuntu-24.04 ubuntu-22.04 windows-2025 windows-2022 windows-2019 macos-13 macos-14 macos-15 macos-26; do
@@ -130,9 +137,12 @@ jobs:
done done
rm -rf ./lists rm -rf ./lists
- name: Update - name: Update
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WIKI_REPOSITORY: ${{ github.repository }}
run: | run: |
if [ "$(git status --porcelain=v1 2>/dev/null | wc -l)" != "0" ]; then if [ "$(git status --porcelain=v1 2>/dev/null | wc -l)" != "0" ]; then
git add . git add .
git commit -m "Update PHP extensions on wiki - $(date +'%d-%m-%y')" git commit -m "Update PHP extensions on wiki - $(date +'%d-%m-%y')"
git push -f https://${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git master || true git push -f https://x-access-token:${GITHUB_TOKEN}@github.com/${WIKI_REPOSITORY}.wiki.git master || true
fi fi
+8 -3
View File
@@ -18,10 +18,14 @@ on:
- 'examples/**' - 'examples/**'
permissions: permissions:
contents: read contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs: jobs:
run: run:
name: Run name: Run
environment: codecov
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
strategy: strategy:
fail-fast: false fail-fast: false
@@ -29,12 +33,13 @@ jobs:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
fetch-depth: 2 fetch-depth: 2
persist-credentials: false
- name: Setup Node.js 24.x - name: Setup Node.js 24.x
uses: actions/setup-node@v6 uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with: with:
node-version: 24.x node-version: 24.x
@@ -54,7 +59,7 @@ jobs:
run: npm audit run: npm audit
- name: Send Coverage - name: Send Coverage
uses: codecov/codecov-action@v5 uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/lcov.info files: coverage/lcov.info
+15 -6
View File
@@ -19,8 +19,11 @@ on:
- 'examples/**' - 'examples/**'
permissions: permissions:
contents: read contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env: env:
default-php-version: '8.2' default-php-version: '8.5'
jobs: jobs:
run: run:
name: Run name: Run
@@ -39,18 +42,20 @@ jobs:
key: cache-v5 key: cache-v5
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Setup cache environment - name: Setup cache environment
id: cache-env id: cache-env
uses: shivammathur/cache-extensions@develop uses: shivammathur/cache-extensions@256729b5fef535345e27904657f78048c0990f81 # v1
with: with:
php-version: ${{ matrix.php-versions || env.default-php-version }} php-version: ${{ matrix.php-versions || env.default-php-version }}
extensions: ${{ env.extensions }} extensions: ${{ env.extensions }}
key: ${{ env.key }} key: ${{ env.key }}
- name: Cache extensions - name: Cache extensions
uses: actions/cache@v5 uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with: with:
path: ${{ steps.cache-env.outputs.dir }} path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }} key: ${{ steps.cache-env.outputs.key }}
@@ -58,8 +63,10 @@ jobs:
- name: Stage php-version-file - name: Stage php-version-file
if: ${{ matrix.php-version-file == 'php-version-file' }} if: ${{ matrix.php-version-file == 'php-version-file' }}
env:
DEFAULT_PHP_VERSION: ${{ env.default-php-version }}
run: | run: |
echo ${{ env.default-php-version }} > php-version-file echo "$DEFAULT_PHP_VERSION" > php-version-file
- name: Setup PHP with extensions and custom config - name: Setup PHP with extensions and custom config
run: node dist/index.js run: node dist/index.js
@@ -70,9 +77,11 @@ jobs:
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata
- name: Testing PHP version - name: Testing PHP version
env:
EXPECTED_PHP_VERSION: ${{ matrix.php-versions || env.default-php-version }}
run: | run: |
php -v php -v
php -r "if(strpos(phpversion(), '${{ matrix.php-versions || env.default-php-version }}') === false) {throw new Exception('Wrong PHP version Installed');}" php -r '$expected = getenv("EXPECTED_PHP_VERSION"); if(strpos(phpversion(), $expected) === false) {throw new Exception("Wrong PHP version Installed");}'
- name: Testing Composer version - name: Testing Composer version
run: | run: |
+20 -10
View File
@@ -10,28 +10,39 @@ on:
tag: tag:
description: Tag name description: Tag name
required: true required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs: jobs:
build: build:
runs-on: ubuntu-latest name: Build and Publish
permissions: permissions:
contents: read contents: read # for actions/checkout
packages: write packages: write # For publishing to GitHub Packages
id-token: write # For authentication with npm registry
runs-on: ubuntu-latest
steps: steps:
- name: Checkout release - name: Checkout release
if: github.event_name != 'workflow_dispatch' if: github.event_name != 'workflow_dispatch'
uses: actions/checkout@v6 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Checkout tag - name: Checkout tag
uses: actions/checkout@v6 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
if: github.event_name == 'workflow_dispatch' if: github.event_name == 'workflow_dispatch'
with: with:
ref: ${{ github.event.inputs.tag }} ref: ${{ github.event.inputs.tag }}
persist-credentials: false
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v6 uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with: with:
node-version: '20.x' node-version: '24.x'
registry-url: https://registry.npmjs.org registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Install dependencies and add lib - name: Install dependencies and add lib
run: | run: |
@@ -42,13 +53,12 @@ jobs:
- name: Publish to NPM - name: Publish to NPM
if: "!contains(github.event.inputs.skip, 'skip-npm')" if: "!contains(github.event.inputs.skip, 'skip-npm')"
run: npm publish --access public run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Change to GitHub Packages registry - name: Change to GitHub Packages registry
uses: actions/setup-node@v6 uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with: with:
registry-url: https://npm.pkg.github.com registry-url: https://npm.pkg.github.com
package-manager-cache: false
scope: '@shivammathur' scope: '@shivammathur'
- name: Patch package.json - name: Patch package.json
+9 -6
View File
@@ -268,7 +268,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.5' php-version: '8.5'
tools: composer:v1 tools: composer:v2
``` ```
- If you do not use composer in your workflow, you can specify `tools: none` to skip it. - If you do not use composer in your workflow, you can specify `tools: none` to skip it.
@@ -950,11 +950,12 @@ Examples of using `setup-php` with various PHP frameworks and packages.
| Framework/Package | Runs on | Workflow | | Framework/Package | Runs on | Workflow |
|----------------------------------------|---------------------------------|---------------------------------------------------------------------------------------------------------------| |----------------------------------------|---------------------------------|---------------------------------------------------------------------------------------------------------------|
| Blackfire | `macOS`, `ubuntu` and `windows` | [blackfire.yml](./examples/blackfire.yml "GitHub Action using Blackfire") | | Blackfire | `macOS`, `ubuntu` and `windows` | [blackfire.yml](./examples/blackfire.yml "GitHub Action using Blackfire") |
| Blackfire Player | `macOS`, `ubuntu` and `windows` | [blackfire-player.yml](./examples/blackfire-player.yml "GitHub Action using Blackfire Player") | | Blackfire Player | `macOS` and `ubuntu` | [blackfire-player.yml](./examples/blackfire-player.yml "GitHub Action using Blackfire Player") |
| CakePHP with `MySQL` and `Redis` | `ubuntu` | [cakephp-mysql.yml](./examples/cakephp-mysql.yml "GitHub Action for CakePHP with MySQL and Redis") | | CakePHP with `MySQL` and `Redis` | `ubuntu` | [cakephp-mysql.yml](./examples/cakephp-mysql.yml "GitHub Action for CakePHP with MySQL and Redis") |
| CakePHP with `PostgreSQL` and `Redis` | `ubuntu` | [cakephp-postgres.yml](./examples/cakephp-postgres.yml "GitHub Action for CakePHP with Postgres and Redis") | | CakePHP with `PostgreSQL` and `Redis` | `ubuntu` | [cakephp-postgres.yml](./examples/cakephp-postgres.yml "GitHub Action for CakePHP with Postgres and Redis") |
| CakePHP without services | `macOS`, `ubuntu` and `windows` | [cakephp.yml](./examples/cakephp.yml "GitHub Action for CakePHP without services") | | CakePHP without services | `macOS`, `ubuntu` and `windows` | [cakephp.yml](./examples/cakephp.yml "GitHub Action for CakePHP without services") |
| CodeIgniter | `macOS`, `ubuntu` and `windows` | [codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter") | | CodeIgniter | `macOS`, `ubuntu` and `windows` | [codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter") |
| Drupal 11 (Composer-managed) | `ubuntu` | [drupal.yml](./examples/drupal.yml "GitHub Action for Drupal 11 composer-managed projects") |
| Laminas MVC | `macOS`, `ubuntu` and `windows` | [laminas-mvc.yml](./examples/laminas-mvc.yml "GitHub Action for Laminas Framework MVC Projects") | | Laminas MVC | `macOS`, `ubuntu` and `windows` | [laminas-mvc.yml](./examples/laminas-mvc.yml "GitHub Action for Laminas Framework MVC Projects") |
| Laravel with `MySQL` and `Redis` | `ubuntu` | [laravel-mysql.yml](./examples/laravel-mysql.yml "GitHub Action for Laravel with MySQL and Redis") | | Laravel with `MySQL` and `Redis` | `ubuntu` | [laravel-mysql.yml](./examples/laravel-mysql.yml "GitHub Action for Laravel with MySQL and Redis") |
| Laravel with `PostgreSQL` and `Redis` | `ubuntu` | [laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis") | | Laravel with `PostgreSQL` and `Redis` | `ubuntu` | [laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis") |
@@ -964,14 +965,16 @@ Examples of using `setup-php` with various PHP frameworks and packages.
| Lumen without services | `macOS`, `ubuntu` and `windows` | [lumen.yml](./examples/lumen.yml "GitHub Action for Lumen without services") | | Lumen without services | `macOS`, `ubuntu` and `windows` | [lumen.yml](./examples/lumen.yml "GitHub Action for Lumen without services") |
| Phalcon with `MySQL` | `ubuntu` | [phalcon-mysql.yml](./examples/phalcon-mysql.yml "GitHub Action for Phalcon with MySQL") | | Phalcon with `MySQL` | `ubuntu` | [phalcon-mysql.yml](./examples/phalcon-mysql.yml "GitHub Action for Phalcon with MySQL") |
| Phalcon with `PostgreSQL` | `ubuntu` | [phalcon-postgres.yml](./examples/phalcon-postgres.yml "GitHub Action for Phalcon with PostgreSQL") | | Phalcon with `PostgreSQL` | `ubuntu` | [phalcon-postgres.yml](./examples/phalcon-postgres.yml "GitHub Action for Phalcon with PostgreSQL") |
| Roots/bedrock | `ubuntu` | [bedrock.yml](./examples/bedrock.yml "GitHub Action for Wordpress Development using @roots/bedrock") |
| Roots/sage | `ubuntu` | [sage.yml](./examples/sage.yml "GitHub Action for Wordpress Development using @roots/sage") |
| Slim Framework | `macOS`, `ubuntu` and `windows` | [slim-framework.yml](./examples/slim-framework.yml "GitHub Action for Slim Framework") | | Slim Framework | `macOS`, `ubuntu` and `windows` | [slim-framework.yml](./examples/slim-framework.yml "GitHub Action for Slim Framework") |
| Symfony with `MySQL` | `ubuntu` | [symfony-mysql.yml](./examples/symfony-mysql.yml "GitHub Action for Symfony with MySQL") | | Symfony with `MySQL` | `ubuntu` | [symfony-mysql.yml](./examples/symfony-mysql.yml "GitHub Action for Symfony with MySQL") |
| Symfony with `PostgreSQL` | `ubuntu` | [symfony-postgres.yml](./examples/symfony-postgres.yml "GitHub Action for Symfony with PostgreSQL") | | Symfony with `PostgreSQL` | `ubuntu` | [symfony-postgres.yml](./examples/symfony-postgres.yml "GitHub Action for Symfony with PostgreSQL") |
| Symfony without services | `macOS`, `ubuntu` and `windows` | [symfony.yml](./examples/symfony.yml "GitHub Action for Symfony without services") | | Symfony without services | `macOS`, `ubuntu` and `windows` | [symfony.yml](./examples/symfony.yml "GitHub Action for Symfony without services") |
| Yii2 Starter Kit with `MySQL` | `ubuntu` | [yii2-mysql.yml](./examples/yii2-mysql.yml "GitHub Action for Yii2 Starter Kit with MySQL") | | WordPress plugin | `ubuntu` | [wordpress.yml](./examples/wordpress.yml "GitHub Action for WordPress plugins") |
| Yii2 Starter Kit with `PostgreSQL` | `ubuntu` | [yii2-postgres.yml](./examples/yii2-postgres.yml "GitHub Action for Yii2 Starter Kit with PostgreSQL") | | WordPress with Roots/Bedrock | `ubuntu` | [bedrock.yml](./examples/bedrock.yml "GitHub Action for WordPress development using @roots/bedrock") |
| WordPress with Roots/Sage | `ubuntu` | [sage.yml](./examples/sage.yml "GitHub Action for WordPress development using @roots/sage") |
| Yii3 web application with `MySQL` | `ubuntu` | [yii3-mysql.yml](./examples/yii3-mysql.yml "GitHub Action for Yii3 web application with MySQL") |
| Yii3 web application with `PostgreSQL` | `ubuntu` | [yii3-postgres.yml](./examples/yii3-postgres.yml "GitHub Action for Yii3 web application with PostgreSQL") |
| Yii3 web application | `ubuntu` and `windows` | [yii3.yml](./examples/yii3.yml "GitHub Action for Yii3 web application") |
## :bookmark: Versioning ## :bookmark: Versioning
+12 -8
View File
@@ -2,14 +2,18 @@ import * as config from '../src/config';
describe('Config tests', () => { describe('Config tests', () => {
it.each` it.each`
ini_values | os | output ini_values | os | output
${'a=b, c=d'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b\nc=d"'} ${'a=b, c=d'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b\nc=d"'}
${'a=b, c=d'} | ${'linux'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'} ${'a=b, c=d'} | ${'linux'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
${'a=b, c=d'} | ${'darwin'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'} ${'a=b, c=d'} | ${'darwin'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
${'a=b & ~c'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=\'b & ~c\'"'} ${'a=b & ~c'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=\'b & ~c\'"'}
${'a="~(b)"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=\'~(b)\'"'} ${'a="~(b)"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=\'~(b)\'"'}
${'a="b, c"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b, c"'} ${'a="b, c"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b, c"'}
${'a=b, c=d'} | ${'openbsd'} | ${'Platform openbsd is not supported'} ${'disable_functions="exec,system"'} | ${'linux'} | ${'echo "disable_functions=exec,system" | sudo tee -a'}
${'disable_functions="exec,system"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "disable_functions=exec,system"'}
${'a=$(id)'} | ${'linux'} | ${'echo "a=\'\\$(id)\'"'}
${'a=$(id)'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=\'`$(id)\'"'}
${'a=b, c=d'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
`('checking addINIValues on $os', async ({ini_values, os, output}) => { `('checking addINIValues on $os', async ({ini_values, os, output}) => {
expect(await config.addINIValues(ini_values, os)).toContain(output); expect(await config.addINIValues(ini_values, os)).toContain(output);
}); });
+146 -18
View File
@@ -31,6 +31,12 @@ function getData(data: Partial<ToolData>): ToolData {
}; };
} }
function unsetComposerAuthEnv(): void {
delete process.env['GITHUB_TOKEN'];
delete process.env['COMPOSER_TOKEN'];
delete process.env['COMPOSER_AUTH_JSON'];
}
/** /**
* Mock fetch.ts * Mock fetch.ts
*/ */
@@ -181,6 +187,7 @@ describe('Tools tests', () => {
${'1.2.3-dev'} | ${'tool'} | ${'phar'} | ${'1.2.3-dev'} ${'1.2.3-dev'} | ${'tool'} | ${'phar'} | ${'1.2.3-dev'}
${'1.2.3-alpha1'} | ${'tool'} | ${'phar'} | ${'1.2.3-alpha1'} ${'1.2.3-alpha1'} | ${'tool'} | ${'phar'} | ${'1.2.3-alpha1'}
${'1.2.3-alpha.1'} | ${'tool'} | ${'phar'} | ${'1.2.3-alpha.1'} ${'1.2.3-alpha.1'} | ${'tool'} | ${'phar'} | ${'1.2.3-alpha.1'}
${'1.>=0'} | ${'tool'} | ${'phar'} | ${'1.0'}
`( `(
'checking getVersion: $version, $tool, $type', 'checking getVersion: $version, $tool, $type',
async ({version, tool, type, expected}) => { async ({version, tool, type, expected}) => {
@@ -298,22 +305,30 @@ describe('Tools tests', () => {
}); });
it.each` it.each`
os | script | scope os | release | scope | script
${'linux'} | ${'add_composer_tool tool tool:1.2.3 user/ global'} | ${'global'} ${'linux'} | ${'tool:1.2.3'} | ${'global'} | ${'add_composer_tool tool tool:1.2.3 user/ global'}
${'darwin'} | ${'add_composer_tool tool tool:1.2.3 user/ scoped'} | ${'scoped'} ${'darwin'} | ${'tool:1.2.3'} | ${'scoped'} | ${'add_composer_tool tool tool:1.2.3 user/ scoped'}
${'win32'} | ${'Add-ComposerTool tool tool:1.2.3 user/ scoped'} | ${'scoped'} ${'win32'} | ${'tool:1.2.3'} | ${'scoped'} | ${'Add-ComposerTool tool tool:1.2.3 user/ scoped'}
${'openbsd'} | ${'Platform openbsd is not supported'} | ${'global'} ${'linux'} | ${'tool:>=1.2'} | ${'global'} | ${'add_composer_tool tool "tool:>=1.2" user/ global'}
`('checking addPackage: $os, $scope', async ({os, script, scope}) => { ${'win32'} | ${'tool:>=1.2'} | ${'global'} | ${'Add-ComposerTool tool "tool:>=1.2" user/ global'}
const data = getData({ ${'linux'} | ${'tool:1.*'} | ${'global'} | ${'add_composer_tool tool "tool:1.*" user/ global'}
tool: 'tool', ${'linux'} | ${'psalm:^5||^6'} | ${'global'} | ${'add_composer_tool tool "psalm:^5||^6" user/ global'}
version: '1.2.3', ${'linux'} | ${'psalm:>=5,<6'} | ${'global'} | ${'add_composer_tool tool "psalm:>=5,<6" user/ global'}
repository: 'user/tool', ${'openbsd'} | ${'tool:1.2.3'} | ${'global'} | ${'Platform openbsd is not supported'}
os: os, `(
scope: scope 'checking addPackage: $os, $release',
}); async ({os, release, scope, script}) => {
data['release'] = [data['tool'], data['version']].join(':'); const data = getData({
expect(await tools.addPackage(data)).toContain(script); tool: 'tool',
}); version: '1.2.3',
repository: 'user/tool',
os,
scope
});
data['release'] = release;
expect(await tools.addPackage(data)).toContain(script);
}
);
it.each` it.each`
version | php_version | os | script version | php_version | os | script
@@ -423,6 +438,118 @@ describe('Tools tests', () => {
} }
); );
it.each`
version | affected
${'1'} | ${false}
${'1.0.0-alpha1'} | ${true}
${'1.0.0-alpha2'} | ${true}
${'1.0.0-alpha3'} | ${true}
${'1.0.0-alpha4'} | ${true}
${'1.0.0-alpha5'} | ${true}
${'1.0.0-alpha6'} | ${true}
${'1.0.0-alpha7'} | ${true}
${'1.0.0-alpha8'} | ${true}
${'1.0.0-alpha9'} | ${true}
${'1.0.0-alpha10'} | ${true}
${'1.0.0-alpha11'} | ${true}
${'1.0.0-beta1'} | ${true}
${'1.0.0-beta2'} | ${true}
${'1.0.0'} | ${true}
${'1.10.27'} | ${true}
${'1.10.28'} | ${false}
${'2.0.0-alpha1'} | ${true}
${'2.0.0-alpha2'} | ${true}
${'2.0.0-alpha3'} | ${true}
${'2.0.0-RC1'} | ${true}
${'2.0.0-RC2'} | ${true}
${'2.2.27'} | ${true}
${'2.2.28'} | ${false}
${'2.3.0-RC1'} | ${true}
${'2.3.0-RC2'} | ${true}
${'2.9.7'} | ${true}
${'2.9.7-RC1'} | ${true}
${'2.9.8'} | ${false}
${'2.9.0RC1'} | ${false}
${'2.9.x-dev'} | ${false}
`('checking affected composer version: $version', ({version, affected}) => {
expect(tools.skipGitHubAuthForComposerVersion(version)).toBe(affected);
});
it('checking affected composer version with CRLF ranges', async () => {
let affected = false;
let fixed = true;
await jest.isolateModulesAsync(async () => {
jest.doMock('fs', () => ({
...jest.requireActual('fs'),
readFileSync: (
filePath: fs.PathOrFileDescriptor,
options?: unknown
) => {
if (String(filePath).includes('composer-gh-auth-no-op')) {
return '1.0.0-0 1.10.28\r\n2.0.0-0 2.2.28\r\n2.3.0-0 2.9.8';
}
return (jest.requireActual('fs') as typeof fs).readFileSync(
filePath,
options as fs.ObjectEncodingOptions & {flag?: string}
);
}
}));
const isolatedTools = await import('../src/tools');
affected = isolatedTools.skipGitHubAuthForComposerVersion('2.9.7');
fixed = isolatedTools.skipGitHubAuthForComposerVersion('2.9.8');
});
expect(affected).toBe(true);
expect(fixed).toBe(false);
});
it.each`
auth_json | expected
${'{"github-oauth":{"github.com":"ghs_new-token"},"http-basic":{"repo.example":{"username":"u","password":"p"}}}'} | ${'{"http-basic":{"repo.example":{"username":"u","password":"p"}}}'}
${'{"github-oauth":{"github.com":"ghs_new-token"}}'} | ${undefined}
${'{"http-basic":{"repo.example":{"username":"u","password":"p"}}}'} | ${'{"http-basic":{"repo.example":{"username":"u","password":"p"}}}'}
${'{"nested":{"github-oauth":{"github.com":"ghs_new-token"}}}'} | ${'{"nested":{"github-oauth":{"github.com":"ghs_new-token"}}}'}
${'{"github-oauth":'} | ${'{"github-oauth":'}
`('cleaning composer auth json', ({auth_json, expected}) => {
unsetComposerAuthEnv();
process.env['COMPOSER_AUTH_JSON'] = auth_json;
tools.cleanComposerAuthJson();
expect(process.env['COMPOSER_AUTH_JSON']).toBe(expected);
unsetComposerAuthEnv();
});
it.each`
version | os | envs | skip_github_auth
${'latest'} | ${'linux'} | ${{GITHUB_TOKEN: 'ghs_token'}} | ${false}
${'1'} | ${'linux'} | ${{GITHUB_TOKEN: 'ghs_token'}} | ${false}
${'2'} | ${'linux'} | ${{GITHUB_TOKEN: 'ghs_token'}} | ${false}
${'2.9.7'} | ${'linux'} | ${{}} | ${true}
${'2.9.7'} | ${'linux'} | ${{GITHUB_TOKEN: 'ghs_token'}} | ${true}
${'2.9.7'} | ${'linux'} | ${{COMPOSER_TOKEN: 'ghs_token'}} | ${true}
${'2.9.7'} | ${'linux'} | ${{COMPOSER_AUTH_JSON: '{"github-oauth":{"github.com":"ghs_new-token"}}'}} | ${true}
${'2.9.7'} | ${'linux'} | ${{COMPOSER_AUTH_JSON: '{"http-basic":{"repo.example":{"username":"u","password":"p"}}}'}} | ${true}
${'2.9.8'} | ${'linux'} | ${{GITHUB_TOKEN: 'ghs_token'}} | ${false}
${'2.9.7'} | ${'win32'} | ${{GITHUB_TOKEN: 'ghs_token'}} | ${true}
`(
'checking composer github auth skip flag: $version, $os',
async ({version, os, envs, skip_github_auth}) => {
unsetComposerAuthEnv();
Object.assign(process.env, envs);
const data = getData({
tool: 'composer',
os: os,
php_version: '7.4',
domain: 'https://getcomposer.org',
repository: 'composer/composer',
version: version
});
const script = await tools.addComposer(data);
expect(script).toContain(
`composer ${version}${skip_github_auth ? ' true' : ''}`
);
unsetComposerAuthEnv();
}
);
it.each` it.each`
version | uri version | uri
${'latest'} | ${'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true'} ${'latest'} | ${'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true'}
@@ -533,7 +660,7 @@ describe('Tools tests', () => {
'add_devtools phpize', 'add_devtools phpize',
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"', 'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"',
'add_tool https://github.com/phpspec/phpspec/releases/latest/download/phpspec.phar phpspec "-V"', 'add_tool https://github.com/phpspec/phpspec/releases/latest/download/phpspec.phar phpspec "-V"',
'add_composer_tool phpunit-bridge phpunit-bridge:5.6.* symfony/ global', 'add_composer_tool phpunit-bridge "phpunit-bridge:5.6.*" symfony/ global',
'add_composer_tool phpunit-polyfills phpunit-polyfills:1.0.1 yoast/ global', 'add_composer_tool phpunit-polyfills phpunit-polyfills:1.0.1 yoast/ global',
'add_protoc 1.2.3', 'add_protoc 1.2.3',
'add_tool https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm "-v"', 'add_tool https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm "-v"',
@@ -593,7 +720,7 @@ describe('Tools tests', () => {
'Add-ComposerTool codeception codeception codeception/ global', 'Add-ComposerTool codeception codeception codeception/ global',
'Add-ComposerTool prestissimo prestissimo hirak/ global', 'Add-ComposerTool prestissimo prestissimo hirak/ global',
'Add-ComposerTool automatic-composer-prefetcher automatic-composer-prefetcher narrowspark/ global', 'Add-ComposerTool automatic-composer-prefetcher automatic-composer-prefetcher narrowspark/ global',
'Add-ComposerTool phinx phinx:1.2.* robmorgan/ scoped', 'Add-ComposerTool phinx "phinx:1.2.*" robmorgan/ scoped',
'Add-ComposerTool phinx phinx:^1.2 robmorgan/ global', 'Add-ComposerTool phinx phinx:^1.2 robmorgan/ global',
'Add-ComposerTool tool tool:1.2.3 user/ global', 'Add-ComposerTool tool tool:1.2.3 user/ global',
'Add-ComposerTool tool tool:~1.2 user/ global' 'Add-ComposerTool tool tool:~1.2 user/ global'
@@ -642,6 +769,7 @@ describe('Tools tests', () => {
${'composer:preview'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-preview.phar,https://artifacts.setup-php.com/composer/composer-7.4-preview.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-preview.phar,https://getcomposer.org/composer-preview.phar composer preview'} ${'composer:preview'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-preview.phar,https://artifacts.setup-php.com/composer/composer-7.4-preview.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-preview.phar,https://getcomposer.org/composer-preview.phar composer preview'}
${'composer, composer:v1'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://artifacts.setup-php.com/composer/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer'} ${'composer, composer:v1'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://artifacts.setup-php.com/composer/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer'}
${'composer:v1, composer:preview, composer:snapshot'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-snapshot.phar,https://artifacts.setup-php.com/composer/composer-7.4-snapshot.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-snapshot.phar,https://getcomposer.org/composer.phar composer snapshot'} ${'composer:v1, composer:preview, composer:snapshot'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-snapshot.phar,https://artifacts.setup-php.com/composer/composer-7.4-snapshot.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-snapshot.phar,https://getcomposer.org/composer.phar composer snapshot'}
${'composer:2.9.7'} | ${'add_tool https://github.com/composer/composer/releases/download/2.9.7/composer.phar,https://getcomposer.org/download/2.9.7/composer.phar composer 2.9.7 true'}
`('checking composer setup: $tools_csv', async ({tools_csv, script}) => { `('checking composer setup: $tools_csv', async ({tools_csv, script}) => {
expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script); expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
}); });
+80 -2
View File
@@ -11,6 +11,12 @@ describe('Utils tests', () => {
expect(await utils.readEnv('TEST')).toBe('setup-php'); expect(await utils.readEnv('TEST')).toBe('setup-php');
expect(await utils.readEnv('test_hyphen')).toBe('setup-php'); expect(await utils.readEnv('test_hyphen')).toBe('setup-php');
expect(await utils.readEnv('TEST_HYPHEN')).toBe('setup-php'); expect(await utils.readEnv('TEST_HYPHEN')).toBe('setup-php');
expect(await utils.readEnv('test invalid')).toBe('');
process.env['conflict_hyphen'] = 'setup-php';
process.env['conflict-hyphen'] = 'wrong';
expect(await utils.readEnv('conflict_hyphen')).toBe('setup-php');
delete process.env['conflict_hyphen'];
delete process.env['conflict-hyphen'];
expect(await utils.readEnv('undefined')).toBe(''); expect(await utils.readEnv('undefined')).toBe('');
}); });
@@ -40,7 +46,19 @@ describe('Utils tests', () => {
expect(await utils.parseVersion('7')).toBe('7.0'); expect(await utils.parseVersion('7')).toBe('7.0');
expect(await utils.parseVersion('7.4')).toBe('7.4'); expect(await utils.parseVersion('7.4')).toBe('7.4');
expect(await utils.parseVersion('5.x')).toBe('5.6'); expect(await utils.parseVersion('5.x')).toBe('5.6');
expect(await utils.parseVersion('4.x')).toBe(undefined); expect(await utils.parseVersion('pre')).toBe('pre');
expect(await utils.parseVersion('pre-installed')).toBe('pre');
await expect(utils.parseVersion('4.x')).rejects.toThrow(
'Invalid PHP version: 4.x'
);
await expect(utils.parseVersion('foo')).rejects.toThrow(
'Invalid PHP version:'
);
fetchSpy.mockResolvedValue({data: '{ "latest": "8.1.0" }'});
await expect(utils.parseVersion('latest')).rejects.toThrow(
'Invalid PHP version in manifest:'
);
fetchSpy.mockReset(); fetchSpy.mockReset();
fetchSpy.mockResolvedValueOnce({}).mockResolvedValueOnce({}); fetchSpy.mockResolvedValueOnce({}).mockResolvedValueOnce({});
@@ -56,6 +74,12 @@ describe('Utils tests', () => {
expect(await utils.parseIniFile('none')).toBe('none'); expect(await utils.parseIniFile('none')).toBe('none');
expect(await utils.parseIniFile('php.ini-production')).toBe('production'); expect(await utils.parseIniFile('php.ini-production')).toBe('production');
expect(await utils.parseIniFile('php.ini-development')).toBe('development'); expect(await utils.parseIniFile('php.ini-development')).toBe('development');
expect(await utils.parseIniFile('/etc/php.ini-production')).toBe(
'production'
);
expect(await utils.parseIniFile('/a-b/php.ini-development')).toBe(
'development'
);
expect(await utils.parseIniFile('invalid')).toBe('production'); expect(await utils.parseIniFile('invalid')).toBe('production');
}); });
@@ -85,6 +109,26 @@ describe('Utils tests', () => {
expect(await utils.extensionArray('')).toEqual([]); expect(await utils.extensionArray('')).toEqual([]);
expect(await utils.extensionArray(' ')).toEqual([]); expect(await utils.extensionArray(' ')).toEqual([]);
expect(
await utils.extensionArray('apcu, mbstring, \\ pdo_pgsql, posix, session')
).toEqual(['apcu', 'mbstring', 'pdo_pgsql', 'posix', 'session']);
});
it('checking shell helpers', () => {
expect(utils.escapeForShell('a$b`c\\d"e', 'linux')).toBe(
'a\\$b\\`c\\\\d\\"e'
);
expect(utils.escapeForShell('a$b`c"d', 'win32')).toBe('a`$b``c`"d');
expect(utils.safeArg('vendor-pkg/repo@v1.0.0', 'linux')).toBe(
'vendor-pkg/repo@v1.0.0'
);
expect(utils.safeArg('phpcs:>=3.0', 'linux')).toBe('"phpcs:>=3.0"');
expect(utils.safeArg('foo$bar', 'win32')).toBe('"foo`$bar"');
expect(utils.sanitizeShellInput('foo;$(`ls`)bar')).toBe('foolsbar');
expect(utils.sanitizeShellInput('vendor/foo:1.*', true)).toBe(
'vendor/foo:1.'
);
}); });
it('checking INIArray', async () => { it('checking INIArray', async () => {
@@ -278,6 +322,9 @@ describe('Utils tests', () => {
process.env['php-version'] = '8.2'; process.env['php-version'] = '8.2';
expect(await utils.readPHPVersion()).toBe('8.2'); expect(await utils.readPHPVersion()).toBe('8.2');
process.env['php-version'] = 'pre-installed';
expect(await utils.readPHPVersion()).toBe('pre-installed');
delete process.env['php-version-file']; delete process.env['php-version-file'];
delete process.env['php-version']; delete process.env['php-version'];
@@ -287,7 +334,7 @@ describe('Utils tests', () => {
existsSync.mockReturnValue(true); existsSync.mockReturnValue(true);
readFileSync.mockReturnValue('setup-php'); readFileSync.mockReturnValue('setup-php');
expect(await utils.readPHPVersion()).toBe('setup-php'); await expect(utils.readPHPVersion()).rejects.toThrow('Invalid PHP version');
existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true); existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
readFileSync.mockReturnValue( readFileSync.mockReturnValue(
@@ -308,6 +355,37 @@ describe('Utils tests', () => {
readFileSync.mockClear(); readFileSync.mockClear();
}); });
it('readPHPVersion rejects unsupported values from each source', async () => {
const existsSync = jest.spyOn(fs, 'existsSync').mockImplementation();
const readFileSync = jest.spyOn(fs, 'readFileSync').mockImplementation();
process.env['php-version'] = 'bogus';
await expect(utils.readPHPVersion()).rejects.toThrow('php-version input');
delete process.env['php-version'];
existsSync.mockReturnValue(true);
readFileSync.mockReturnValue('bogus');
await expect(utils.readPHPVersion()).rejects.toThrow('.php-version');
existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
readFileSync.mockReturnValue('{"platform-overrides":{"php":"bogus"}}');
await expect(utils.readPHPVersion()).rejects.toThrow(
'composer.lock platform-overrides.php'
);
existsSync
.mockReturnValueOnce(false)
.mockReturnValueOnce(false)
.mockReturnValueOnce(true);
readFileSync.mockReturnValue('{"config":{"platform":{"php":"bogus"}}}');
await expect(utils.readPHPVersion()).rejects.toThrow(
'composer.json config.platform.php'
);
existsSync.mockClear();
readFileSync.mockClear();
});
it('checking setVariable', async () => { it('checking setVariable', async () => {
let script: string = await utils.setVariable('var', 'command', 'linux'); let script: string = await utils.setVariable('var', 'command', 'linux');
expect(script).toEqual('\nvar="$(command)"\n'); expect(script).toEqual('\nvar="$(command)"\n');
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -8,7 +8,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
+16 -5
View File
@@ -4,6 +4,9 @@ on: [push, pull_request]
jobs: jobs:
blackfire-player: blackfire-player:
name: Blackfire (PHP ${{ matrix.php-versions }}) name: Blackfire (PHP ${{ matrix.php-versions }})
defaults:
run:
shell: bash
# Add your Blackfire credentials securely using GitHub Secrets # Add your Blackfire credentials securely using GitHub Secrets
env: env:
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }} BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
@@ -14,9 +17,9 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, macos-latest]
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
# blackfire-player supports PHP >= 5.5 # Blackfire Player supports PHP 8.5 and is available on Ubuntu and macOS.
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -31,6 +34,14 @@ jobs:
tools: blackfire, blackfire-player tools: blackfire, blackfire-player
coverage: none coverage: none
# Refer to https://blackfire.io/docs/player/index#usage - name: Start local endpoint
run: |
php -S 127.0.0.1:8080 > "$RUNNER_TEMP/blackfire-player.log" 2>&1 &
sleep 5
- name: Validate scenario
run: blackfire-player validate scenario.bkf
# Refer to https://docs.blackfire.io/builds-cookbooks/player
- name: Play the scenario - name: Play the scenario
run: blackfire-player run scenario.bkf run: blackfire-player run scenario.bkf --endpoint=http://127.0.0.1:8080
+17 -5
View File
@@ -15,8 +15,8 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
# Blackfire supports PHP >= 5.3 on Ubuntu and macOS, and PHP >= 5.4 on Windows # Blackfire supports the current PHP releases on Ubuntu, macOS, and Windows.
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -26,12 +26,24 @@ jobs:
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
# Setup Blackfire extension and CLI # Setup Blackfire extension and CLI.
extensions: blackfire extensions: blackfire, :xdebug
tools: blackfire tools: blackfire
# Disable Xdebug and PCOV coverage drivers # Disable Xdebug and PCOV coverage drivers
coverage: none coverage: none
# Refer to https://blackfire.io/docs/cookbooks/profiling-cli # Refer to https://blackfire.io/docs/cookbooks/profiling-cli
- name: Profile - name: Profile
run: blackfire run php my-script.php shell: bash
run: |
set +e
output=$(blackfire run php my-script.php 2>&1)
exit_code=$?
printf '%s\n' "$output"
if [ "$exit_code" -ne 0 ]; then
if printf '%s' "$output" | grep -q "upgrade your subscription"; then
echo "Blackfire profiling reached the repository quota limit; treating this as a known non-fatal condition."
exit 0
fi
exit "$exit_code"
fi
+11 -7
View File
@@ -6,7 +6,8 @@ jobs:
tests: tests:
strategy: strategy:
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.4', '8.5']
# The latest cakephp/app release resolves dev dependencies that require PHP 8.4+.
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Docs: https://docs.github.com/en/actions/using-containerized-services # Docs: https://docs.github.com/en/actions/using-containerized-services
@@ -37,7 +38,7 @@ jobs:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
# You can also use ext-apcu or ext-memcached instead of ext-redis # You can also use ext-apcu or ext-memcached instead of ext-redis
# Install memcached if using ext-memcached # Install memcached if using ext-memcached
extensions: mbstring, intl, redis, pdo_mysql extensions: mbstring, intl, redis, apcu, pdo_mysql
coverage: pcov coverage: pcov
# Local MySQL service in GitHub hosted environments is disabled by default. # Local MySQL service in GitHub hosted environments is disabled by default.
@@ -61,14 +62,15 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
composer install --no-progress --prefer-dist --optimize-autoloader composer install --no-progress --prefer-dist --optimize-autoloader
composer run-script post-install-cmd composer run-script post-install-cmd --no-interaction
# Add a step to run migrations if required # Add a step to run migrations if required
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit --coverage-text
env: env:
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DB_DSN: "mysql://root:password@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/cakephp?init[]=SET sql_mode = \"STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\"" DATABASE_URL: "mysql://root:password@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/cakephp?init[]=SET sql_mode = \"STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\""
DATABASE_TEST_URL: "mysql://root:password@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/cakephp?init[]=SET sql_mode = \"STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\""
coding-standard: coding-standard:
name: Coding Standard name: Coding Standard
@@ -81,7 +83,7 @@ jobs:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.1' php-version: '8.5'
extensions: mbstring, intl extensions: mbstring, intl
- name: Get composer cache directory - name: Get composer cache directory
@@ -114,7 +116,7 @@ jobs:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.1' php-version: '8.5'
extensions: mbstring, intl extensions: mbstring, intl
tools: phpstan tools: phpstan
@@ -132,7 +134,9 @@ jobs:
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader run: |
composer install --no-progress --prefer-dist --optimize-autoloader
composer run-script post-install-cmd --no-interaction
- name: Static Analysis using PHPStan - name: Static Analysis using PHPStan
run: phpstan analyse --no-progress src/ run: phpstan analyse --no-progress src/
+14 -9
View File
@@ -5,8 +5,10 @@ on: [push, pull_request]
jobs: jobs:
tests: tests:
strategy: strategy:
fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.4', '8.5']
# The latest cakephp/app release resolves dev dependencies that require PHP 8.4+.
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Docs: https://docs.github.com/en/actions/using-containerized-services # Docs: https://docs.github.com/en/actions/using-containerized-services
@@ -37,7 +39,7 @@ jobs:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
# You can also use ext-apcu or ext-memcached instead of ext-redis # You can also use ext-apcu or ext-memcached instead of ext-redis
# Install memcached if using ext-memcached # Install memcached if using ext-memcached
extensions: mbstring, intl, redis, pdo_pgsql extensions: mbstring, intl, redis, apcu, pdo_pgsql
coverage: pcov coverage: pcov
# Local PostgreSQL service in GitHub hosted environments is disabled by default. # Local PostgreSQL service in GitHub hosted environments is disabled by default.
@@ -61,14 +63,15 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
composer install --no-progress --prefer-dist --optimize-autoloader composer install --no-progress --prefer-dist --optimize-autoloader
composer run-script post-install-cmd composer run-script post-install-cmd --no-interaction
# Add a step to run migrations if required # Add a step to run migrations if required
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit --coverage-text
env: env:
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DB_DSN: postgres://postgres@127.0.0.1:${{ job.services.postgres.ports['5432'] }}/postgres DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports['5432'] }}/postgres?encoding=UTF8
DATABASE_TEST_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports['5432'] }}/postgres?encoding=UTF8
coding-standard: coding-standard:
name: Coding Standard name: Coding Standard
@@ -81,8 +84,8 @@ jobs:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.1' php-version: '8.5'
extensions: mbstring, intl extensions: mbstring, intl, apcu
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
@@ -114,8 +117,8 @@ jobs:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.1' php-version: '8.5'
extensions: mbstring, intl extensions: mbstring, intl, apcu
tools: phpstan tools: phpstan
- name: Get composer cache directory - name: Get composer cache directory
@@ -132,7 +135,9 @@ jobs:
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader run: |
composer install --no-progress --prefer-dist --optimize-autoloader
composer run-script post-install-cmd --no-interaction
- name: Static Analysis using PHPStan - name: Static Analysis using PHPStan
run: phpstan analyse --no-progress src/ run: phpstan analyse --no-progress src/
+11 -5
View File
@@ -7,7 +7,8 @@ jobs:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.4', '8.5']
# The latest cakephp/app release resolves dev dependencies that require PHP 8.4+.
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
@@ -23,6 +24,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies - name: Cache composer dependencies
@@ -37,7 +39,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
composer install --no-progress --prefer-dist --optimize-autoloader composer install --no-progress --prefer-dist --optimize-autoloader
composer run-script post-install-cmd composer run-script post-install-cmd --no-interaction
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit --coverage-text
@@ -53,10 +55,11 @@ jobs:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.1' php-version: '8.5'
extensions: mbstring, intl extensions: mbstring, intl
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies - name: Cache composer dependencies
@@ -85,12 +88,13 @@ jobs:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.1' php-version: '8.5'
extensions: mbstring, intl extensions: mbstring, intl
tools: phpstan tools: phpstan
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies - name: Cache composer dependencies
@@ -103,7 +107,9 @@ jobs:
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader run: |
composer install --no-progress --prefer-dist --optimize-autoloader
composer run-script post-install-cmd --no-interaction
- name: Static Analysis using PHPStan - name: Static Analysis using PHPStan
run: phpstan analyse --no-progress src/ run: phpstan analyse --no-progress src/
+4 -3
View File
@@ -6,7 +6,7 @@ jobs:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
@@ -17,12 +17,13 @@ jobs:
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, curl, dom extensions: mbstring, intl, curl, dom, sqlite3, pdo_sqlite
coverage: xdebug coverage: xdebug
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v5 uses: actions/cache@v5
+59
View File
@@ -0,0 +1,59 @@
# GitHub Action for Drupal 11 composer-managed projects
# Requires drupal/core-dev in require-dev for vendor/bin/phpunit
name: Testing Drupal
on: [push, pull_request]
jobs:
drupal:
name: Drupal (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
env:
SIMPLETEST_BASE_URL: http://127.0.0.1:8080
SIMPLETEST_DB: sqlite://localhost/sites/default/files/.ht.sqlite
BROWSERTEST_OUTPUT_DIRECTORY: /tmp/browser_output
strategy:
fail-fast: false
matrix:
php-versions: ['8.3', '8.4', '8.5']
steps:
- name: Checkout
uses: actions/checkout@v6
# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: apcu, ctype, curl, dom, gd, iconv, intl, mbstring, pdo_sqlite, simplexml, xml, zip
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: |
if [ "${{ matrix.php-versions }}" = "8.3" ]; then
composer require --dev drupal/core-dev:11.2.10 doctrine/instantiator:^2.0.0 --no-interaction --no-update
composer update drupal/core-dev doctrine/instantiator --with-all-dependencies --no-interaction --no-progress --prefer-dist --optimize-autoloader
else
composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader
fi
- name: Prepare Drupal test directories
run: mkdir -p web/sites/default/files "$BROWSERTEST_OUTPUT_DIRECTORY"
- name: Start Drupal web server
run: php -S 127.0.0.1:8080 -t web >/tmp/php-server.log 2>&1 &
- name: Test with phpunit
# Adjust the test path to match your custom modules or themes.
run: vendor/bin/phpunit -c web/core web/modules/custom
+3 -2
View File
@@ -1,12 +1,12 @@
# GitHub Action for Laminas framework MVC projects # GitHub Action for Laminas framework MVC projects
name: Testing Zend Framework name: Testing Laminas MVC
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
build: build:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.1', '8.2', '8.3']
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
@@ -21,6 +21,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies - name: Cache composer dependencies
+5 -3
View File
@@ -6,11 +6,13 @@ jobs:
name: Laravel (PHP ${{ matrix.php-versions }}) name: Laravel (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_DATABASE: laravel DB_DATABASE: laravel
DB_USERNAME: root DB_USERNAME: root
DB_PASSWORD: password DB_PASSWORD: password
BROADCAST_DRIVER: log BROADCAST_CONNECTION: log
CACHE_DRIVER: redis CACHE_STORE: redis
QUEUE_CONNECTION: redis QUEUE_CONNECTION: redis
SESSION_DRIVER: redis SESSION_DRIVER: redis
@@ -34,7 +36,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
+4 -4
View File
@@ -11,7 +11,7 @@ jobs:
QUEUE_CONNECTION: redis QUEUE_CONNECTION: redis
SESSION_DRIVER: redis SESSION_DRIVER: redis
DB_CONNECTION: pgsql DB_CONNECTION: pgsql
DB_HOST: localhost DB_HOST: 127.0.0.1
DB_PASSWORD: postgres DB_PASSWORD: postgres
DB_USERNAME: postgres DB_USERNAME: postgres
DB_DATABASE: postgres DB_DATABASE: postgres
@@ -36,7 +36,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -81,11 +81,11 @@ jobs:
- name: Run Migration - name: Run Migration
run: php artisan migrate -v run: php artisan migrate -v
env: env:
DB_PORT: ${{ job.services.postgres.ports[5432] }} DB_PORT: ${{ job.services.postgres.ports['5432'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit --coverage-text
env: env:
DB_PORT: ${{ job.services.postgres.ports[5432] }} DB_PORT: ${{ job.services.postgres.ports['5432'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
+2 -1
View File
@@ -9,7 +9,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -24,6 +24,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies - name: Cache composer dependencies
+2 -2
View File
@@ -34,7 +34,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -83,7 +83,7 @@ jobs:
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit --coverage-text --coverage-filter app
env: env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }} DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
+6 -6
View File
@@ -11,7 +11,7 @@ jobs:
QUEUE_CONNECTION: redis QUEUE_CONNECTION: redis
SESSION_DRIVER: redis SESSION_DRIVER: redis
DB_CONNECTION: pgsql DB_CONNECTION: pgsql
DB_HOST: localhost DB_HOST: 127.0.0.1
DB_PASSWORD: postgres DB_PASSWORD: postgres
DB_USERNAME: postgres DB_USERNAME: postgres
DB_DATABASE: postgres DB_DATABASE: postgres
@@ -36,7 +36,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -47,7 +47,7 @@ jobs:
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, pgsql extensions: mbstring, dom, fileinfo, pgsql
coverage: xdebug coverage: none
# Local PostgreSQL service in GitHub hosted environments is disabled by default. # Local PostgreSQL service in GitHub hosted environments is disabled by default.
# If you are using it instead of service containers, make sure you start it. # If you are using it instead of service containers, make sure you start it.
@@ -81,11 +81,11 @@ jobs:
- name: Run Migration - name: Run Migration
run: php artisan migrate -v run: php artisan migrate -v
env: env:
DB_PORT: ${{ job.services.postgres.ports[5432] }} DB_PORT: ${{ job.services.postgres.ports['5432'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit
env: env:
DB_PORT: ${{ job.services.postgres.ports[5432] }} DB_PORT: ${{ job.services.postgres.ports['5432'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
+3 -2
View File
@@ -9,7 +9,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -24,6 +24,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies - name: Cache composer dependencies
@@ -42,4 +43,4 @@ jobs:
run: php -r "file_exists('.env') || copy('.env.example', '.env');" run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit --coverage-text --coverage-filter app
+4 -7
View File
@@ -11,7 +11,7 @@ jobs:
env: env:
DB_ADAPTER: mysql DB_ADAPTER: mysql
DB_HOST: 127.0.0.1 DB_HOST: 127.0.0.1
DB_NAME: phalcon DB_NAME: vokuro
DB_USERNAME: root DB_USERNAME: root
DB_PASSWORD: password DB_PASSWORD: password
CODECEPTION_URL: 127.0.0.1 CODECEPTION_URL: 127.0.0.1
@@ -20,11 +20,11 @@ jobs:
# Docs: https://docs.github.com/en/actions/using-containerized-services # Docs: https://docs.github.com/en/actions/using-containerized-services
services: services:
mysql: mysql:
image: mysql:latest image: mysql:5.7
env: env:
MYSQL_ALLOW_EMPTY_PASSWORD: false MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: phalcon MYSQL_DATABASE: vokuro
ports: ports:
- 3306/tcp - 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
@@ -32,8 +32,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
# For phalcon 3.x, use
# php-versions: ['7.0', '7.1', '7.2', '7.3']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -43,7 +41,7 @@ jobs:
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
# Use phalcon3 for the phalcon 3.x. # Use phalcon4 for the latest compatible Vokuro sample release.
extensions: mbstring, dom, zip, phalcon4, mysql extensions: mbstring, dom, zip, phalcon4, mysql
coverage: xdebug coverage: xdebug
@@ -73,7 +71,6 @@ jobs:
- name: Run Migration - name: Run Migration
run: | run: |
if [ ! -e phinx.yml ]; then vendor/bin/phinx init; fi
vendor/bin/phinx migrate vendor/bin/phinx migrate
vendor/bin/phinx seed:run vendor/bin/phinx seed:run
env: env:
+13 -19
View File
@@ -11,21 +11,18 @@ jobs:
env: env:
DB_ADAPTER: pgsql DB_ADAPTER: pgsql
DB_HOST: 127.0.0.1 DB_HOST: 127.0.0.1
DB_NAME: postgres DB_NAME: vokuro
DB_USERNAME: postgres DB_USERNAME: postgres
DB_PASSWORD: postgres DB_PASSWORD: postgres
CODECEPTION_URL: 127.0.0.1 CODECEPTION_URL: 127.0.0.1
CODECEPTION_PORT: 8888 CODECEPTION_PORT: 8888
DB_CONNECTION: pgsql
# Docs: https://docs.github.com/en/actions/using-containerized-services
services: services:
postgres: postgres:
image: postgres:latest image: postgres:latest
env: env:
POSTGRES_USER: postgres POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres POSTGRES_DB: vokuro
ports: ports:
- 5432/tcp - 5432/tcp
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
@@ -33,8 +30,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
# For phalcon 3.x, use
# php-versions: ['7.0', '7.1', '7.2', '7.3']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -44,40 +39,39 @@ jobs:
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
# Use phalcon3 for the phalcon 3.x
extensions: mbstring, dom, zip, phalcon4, pgsql extensions: mbstring, dom, zip, phalcon4, pgsql
coverage: xdebug coverage: xdebug
# Local PostgreSQL service in GitHub hosted environments is disabled by default.
# If you are using it instead of service containers, make sure you start it.
# - name: Start postgresql service
# run: sudo systemctl start postgresql.service
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v5 uses: actions/cache@v5
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader run: composer install --no-progress --prefer-dist --optimize-autoloader --no-security-blocking
- name: Prepare the application - name: Prepare the application
run: php -r "file_exists('.env') || copy('.env.example', '.env');" run: |
php -r "file_exists('.env') || copy('.env.example', '.env');"
mkdir -p var/cache/acl var/cache/metaData var/cache/session var/cache/volt var/logs
chmod -R 777 var/cache var/logs
- name: Run Migration - name: Run Migration
run: | run: |
if [ ! -e phinx.yml ]; then vendor/bin/phinx init; fi
vendor/bin/phinx migrate vendor/bin/phinx migrate
vendor/bin/phinx seed:run vendor/bin/phinx seed:run
env: env:
DB_PORT: ${{ job.services.postgres.ports['5432'] }} DB_PORT: ${{ job.services.postgres.ports['5432'] }}
- name: Run Tests - name: Run Tests
run: | run: |
(cd public && nohup php -S $CODECEPTION_URL:$CODECEPTION_PORT > phalcon.log 2>&1 &) (cd public && nohup php -S $CODECEPTION_URL:$CODECEPTION_PORT > vokuro.log 2>&1 &)
vendor/bin/codecept build vendor/bin/codecept build
vendor/bin/codecept run vendor/bin/codecept run
env: env:
+5 -12
View File
@@ -8,8 +8,8 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
node-versions: ['16'] node-versions: ['20']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -53,17 +53,10 @@ jobs:
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install yarn dependencies - name: Install yarn dependencies
run: yarn -V run: yarn install --frozen-lockfile --non-interactive
- name: Install Composer dependencies - name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Yarn test and build - name: Yarn build
run: | run: yarn build
yarn run test
yarn run build
yarn run rmdist
yarn run "build:production"
- name: PHP test
run: composer test
+2 -1
View File
@@ -6,7 +6,7 @@ jobs:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.3', '8.4', '8.5']
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
@@ -22,6 +22,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies - name: Cache composer dependencies
+13 -13
View File
@@ -5,11 +5,13 @@ jobs:
symfony: symfony:
name: Symfony (PHP ${{ matrix.php-versions }}) name: Symfony (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
APP_ENV: test
# Docs: https://docs.github.com/en/actions/using-containerized-services # Docs: https://docs.github.com/en/actions/using-containerized-services
services: services:
mysql: mysql:
image: mysql:latest image: mysql:8.4
env: env:
MYSQL_ALLOW_EMPTY_PASSWORD: false MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: symfony MYSQL_ROOT_PASSWORD: symfony
@@ -20,7 +22,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.4', '8.5', '8.6']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -30,7 +32,6 @@ jobs:
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
tools: phpunit-bridge
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
coverage: xdebug coverage: xdebug
@@ -53,18 +54,17 @@ jobs:
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader run: composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader
- name: Run Migration - name: Prepare database
run: | run: |
composer require --dev symfony/orm-pack php bin/console doctrine:database:create --if-not-exists --no-interaction
php bin/console doctrine:schema:update --force || echo "No migrations found or schema update failed" php bin/console doctrine:schema:create --no-interaction
php bin/console doctrine:migrations:migrate || echo "No migrations found or migration failed" php bin/console doctrine:fixtures:load --no-interaction
env: env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony?serverVersion=8.4&charset=utf8mb4
- name: Install PHPUnit
run: simple-phpunit install
- name: Run tests - name: Run tests
run: simple-phpunit --coverage-text run: php bin/phpunit --coverage-text
env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony?serverVersion=8.4&charset=utf8mb4
+13 -13
View File
@@ -5,11 +5,13 @@ jobs:
symfony: symfony:
name: Symfony (PHP ${{ matrix.php-versions }}) name: Symfony (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
APP_ENV: test
# Docs: https://docs.github.com/en/actions/using-containerized-services # Docs: https://docs.github.com/en/actions/using-containerized-services
services: services:
postgres: postgres:
image: postgres:latest image: postgres:16
env: env:
POSTGRES_USER: postgres POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres POSTGRES_PASSWORD: postgres
@@ -20,7 +22,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.4', '8.5', '8.6']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -30,8 +32,7 @@ jobs:
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
tools: phpunit-bridge extensions: mbstring, xml, ctype, iconv, intl, pdo_pgsql, pgsql
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql
coverage: xdebug coverage: xdebug
# Local PostgreSQL service in GitHub hosted environments is disabled by default. # Local PostgreSQL service in GitHub hosted environments is disabled by default.
@@ -55,16 +56,15 @@ jobs:
- name: Install Composer dependencies - name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run Migration - name: Prepare database
run: | run: |
composer require --dev symfony/orm-pack php bin/console doctrine:database:create --if-not-exists --no-interaction
php bin/console doctrine:schema:update --force || echo "No migrations found or schema update failed" php bin/console doctrine:schema:create --no-interaction
php bin/console doctrine:migrations:migrate || echo "No migrations found or migration failed" php bin/console doctrine:fixtures:load --no-interaction
env: env:
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8 DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?serverVersion=16.0.0&charset=utf8
- name: Install PHPUnit
run: simple-phpunit install
- name: Run tests - name: Run tests
run: simple-phpunit --coverage-text run: php bin/phpunit --coverage-text
env:
DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?serverVersion=16.0.0&charset=utf8
+4 -7
View File
@@ -9,7 +9,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['8.4', '8.5', '8.6']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@@ -19,12 +19,12 @@ jobs:
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
tools: phpunit-bridge extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, zip
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
coverage: xdebug coverage: xdebug
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies - name: Cache composer dependencies
@@ -39,8 +39,5 @@ jobs:
- name: Install Composer dependencies - name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Install PHPUnit
run: simple-phpunit install
- name: Run tests - name: Run tests
run: simple-phpunit --coverage-text run: ./bin/phpunit --coverage-text
+68
View File
@@ -0,0 +1,68 @@
# GitHub Action for WordPress plugins
# Tested with files scaffolded by wp scaffold plugin-tests --ci=github
# Requires phpunit/phpunit and yoast/phpunit-polyfills in require-dev for vendor/bin/phpunit
name: Testing WordPress
on: [push, pull_request]
jobs:
wordpress:
name: WordPress (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['8.3', '8.4', '8.5']
# Docs: https://docs.github.com/en/actions/using-containerized-services
services:
mysql:
image: mysql:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress_test
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v6
# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, zip, intl, mysql
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y subversion default-mysql-client
- name: Install Composer dependencies
run: |
if [ "${{ matrix.php-versions }}" = "8.3" ]; then
composer require --dev doctrine/instantiator:^2.0.0 --no-interaction --no-update
composer update doctrine/instantiator --with-all-dependencies --no-interaction --no-progress --prefer-dist --optimize-autoloader
else
composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader
fi
- name: Install WordPress test environment
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:${{ job.services.mysql.ports['3306'] }} latest true
- name: Test with phpunit
run: vendor/bin/phpunit
-86
View File
@@ -1,86 +0,0 @@
# GitHub Action for Yii Framework with MySQL
name: Testing Yii2 with MySQL
on: [push, pull_request]
jobs:
yii:
name: Yii2 (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
env:
DB_USERNAME: root
DB_PASSWORD: yii
TEST_DB_USERNAME: root
TEST_DB_PASSWORD: yii
DB_CHARSET: utf8
# Docs: https://docs.github.com/en/actions/using-containerized-services
services:
mysql:
image: mysql:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: yii
MYSQL_DATABASE: yii
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0']
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set Node.js 10.x
uses: actions/setup-node@v5
with:
node-version: 10.x
# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, gd, imagick, zip, dom, mysql
coverage: xdebug
# Local MySQL service in GitHub hosted environments is disabled by default.
# If you are using it instead of service containers, make sure you start it.
# - name: Start mysql service
# run: sudo systemctl start mysql.service
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Prepare the application
run: |
php -r "file_exists('.env') || copy('.env.dist', '.env');"
php console/yii app/setup
npm install --development
npm run build
env:
DB_DSN: mysql:host=127.0.0.1;port=${{ job.services.mysql.ports['3306'] }};dbname=yii
TEST_DB_DSN: mysql:host=127.0.0.1;port=${{ job.services.mysql.ports['3306'] }};dbname=yii
- name: Run Tests
run: |
vendor/bin/codecept build
php tests/bin/yii app/setup --interactive=0
nohup php -S localhost:8080 > yii.log 2>&1 &
vendor/bin/codecept run
env:
DB_DSN: mysql:host=127.0.0.1;port=${{ job.services.mysql.ports['3306'] }};dbname=yii
TEST_DB_DSN: mysql:host=127.0.0.1;port=${{ job.services.mysql.ports['3306'] }};dbname=yii
-86
View File
@@ -1,86 +0,0 @@
# GitHub Action for Yii Framework with PostgreSQL
name: Testing Yii2 with PostgreSQL
on: [push, pull_request]
jobs:
yii:
name: Yii2 (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
env:
DB_USERNAME: postgres
DB_PASSWORD: postgres
TEST_DB_USERNAME: postgres
TEST_DB_PASSWORD: postgres
DB_CHARSET: utf8
# Docs: https://docs.github.com/en/actions/using-containerized-services
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432/tcp
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0']
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set Node.js 10.x
uses: actions/setup-node@v5
with:
node-version: 10.x
# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, gd, imagick, zip, dom, pgsql
coverage: xdebug
# Local PostgreSQL service in GitHub hosted environments is disabled by default.
# If you are using it instead of service containers, make sure you start it.
# - name: Start postgresql service
# run: sudo systemctl start postgresql.service
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Prepare the application
run: |
php -r "file_exists('.env') || copy('.env.dist', '.env');"
php console/yii app/setup
npm install --development
npm run build
env:
DB_DSN: pgsql:host=127.0.0.1;port=${{ job.services.postgres.ports['5432'] }};dbname=postgres
TEST_DB_DSN: pgsql:host=127.0.0.1;port=${{ job.services.postgres.ports['5432'] }};dbname=postgres
- name: Run Tests
run: |
vendor/bin/codecept build
php tests/bin/yii app/setup --interactive=0
nohup php -S localhost:8080 > yii.log 2>&1 &
vendor/bin/codecept run
env:
DB_DSN: pgsql:host=127.0.0.1;port=${{ job.services.postgres.ports['5432'] }};dbname=postgres
TEST_DB_DSN: pgsql:host=127.0.0.1;port=${{ job.services.postgres.ports['5432'] }};dbname=postgres
+78
View File
@@ -0,0 +1,78 @@
# GitHub Action for Yii3 web application with MySQL
# Tested with https://github.com/yiisoft/app
name: Testing Yii3 with MySQL
on: [push, pull_request]
jobs:
yii:
name: Yii3 (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
env:
APP_C3: true
APP_ENV: test
APP_DEBUG: false
# Docs: https://docs.github.com/en/actions/using-containerized-services
services:
mysql:
image: mysql:8.4
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: app
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
php-versions: ['8.4', '8.5']
# The latest yiisoft/app release resolves Symfony 8.0 packages that require PHP 8.4+.
steps:
- name: Checkout
uses: actions/checkout@v6
# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: fileinfo, intl, pdo_mysql
ini-values: date.timezone='UTC', register_argc_argv=On
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run migrations
run: php yii migrate:up --no-interaction
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
DB_NAME: app
DB_USERNAME: root
DB_PASSWORD: password
- name: Run codeception build
run: vendor/bin/codecept build
- name: Run tests with Codeception
run: vendor/bin/codecept run
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
DB_NAME: app
DB_USERNAME: root
DB_PASSWORD: password
+78
View File
@@ -0,0 +1,78 @@
# GitHub Action for Yii3 web application with PostgreSQL
# Tested with https://github.com/yiisoft/app
name: Testing Yii3 with PostgreSQL
on: [push, pull_request]
jobs:
yii:
name: Yii3 (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
env:
APP_C3: true
APP_ENV: test
APP_DEBUG: false
# Docs: https://docs.github.com/en/actions/using-containerized-services
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: app
ports:
- 5432/tcp
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
strategy:
fail-fast: false
matrix:
php-versions: ['8.4', '8.5']
# The latest yiisoft/app release resolves Symfony 8.0 packages that require PHP 8.4+.
steps:
- name: Checkout
uses: actions/checkout@v6
# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: fileinfo, intl, pdo_pgsql
ini-values: date.timezone='UTC', register_argc_argv=On
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run migrations
run: php yii migrate:up --no-interaction
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
DB_NAME: app
DB_USERNAME: postgres
DB_PASSWORD: postgres
- name: Run codeception build
run: vendor/bin/codecept build
- name: Run tests with Codeception
run: vendor/bin/codecept run
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
DB_NAME: app
DB_USERNAME: postgres
DB_PASSWORD: postgres
+53
View File
@@ -0,0 +1,53 @@
# GitHub Action for Yii3 web application
# Tested with https://github.com/yiisoft/app
name: Testing Yii3
on: [push, pull_request]
jobs:
yii:
name: Yii3 (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
runs-on: ${{ matrix.operating-system }}
env:
APP_C3: true
APP_ENV: test
APP_DEBUG: false
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest]
php-versions: ['8.4', '8.5']
# The latest yiisoft/app release resolves Symfony 8.0 packages that require PHP 8.4+.
steps:
- name: Checkout
uses: actions/checkout@v6
# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: fileinfo, intl
ini-values: date.timezone='UTC', register_argc_argv=On
coverage: none
- name: Get composer cache directory
id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run codeception build
run: vendor/bin/codecept build
- name: Run tests with Codeception
run: vendor/bin/codecept run
+618 -581
View File
File diff suppressed because it is too large Load Diff
+15 -15
View File
@@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "2.37.0", "version": "2.37.2",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "lib/install.js", "main": "lib/install.js",
@@ -38,26 +38,26 @@
"compare-versions": "^6.1.1" "compare-versions": "^6.1.1"
}, },
"devDependencies": { "devDependencies": {
"@eslint/compat": "^2.0.3", "@eslint/compat": "^2.1.0",
"@eslint/js": "^10.0.1", "@eslint/js": "^10.0.1",
"@types/jest": "^30.0.0", "@types/jest": "^30.0.0",
"@types/node": "^25.5.0", "@types/node": "^25.9.2",
"@typescript-eslint/eslint-plugin": "^8.57.0", "@typescript-eslint/eslint-plugin": "^8.60.1",
"@typescript-eslint/parser": "^8.57.0", "@typescript-eslint/parser": "^8.60.1",
"@vercel/ncc": "^0.38.4", "@vercel/ncc": "^0.38.4",
"eslint": "^10.0.3", "eslint": "^10.4.1",
"eslint-config-prettier": "^10.1.8", "eslint-config-prettier": "^10.1.8",
"eslint-import-resolver-typescript": "^4.4.4", "eslint-import-resolver-typescript": "^4.4.5",
"eslint-plugin-import-x": "^4.16.2", "eslint-plugin-import-x": "^4.16.2",
"eslint-plugin-jest": "^29.15.0", "eslint-plugin-jest": "^29.15.2",
"eslint-plugin-prettier": "^5.5.5", "eslint-plugin-prettier": "^5.5.6",
"globals": "^17.4.0", "globals": "^17.6.0",
"jest": "^30.3.0", "jest": "^30.4.2",
"jest-circus": "^30.3.0", "jest-circus": "^30.4.2",
"nock": "^14.0.11", "nock": "^14.0.15",
"prettier": "^3.8.1", "prettier": "^3.8.3",
"simple-git-hooks": "^2.13.1", "simple-git-hooks": "^2.13.1",
"ts-jest": "^29.4.6", "ts-jest": "^29.4.11",
"typescript": "^5.9.3" "typescript": "^5.9.3"
}, },
"overrides": { "overrides": {
+5 -2
View File
@@ -16,7 +16,7 @@ export async function addINIValuesUnix(
}); });
return ( return (
'echo "' + 'echo "' +
ini_values.join('\n') + ini_values.map(v => utils.escapeForShell(v, 'linux')).join('\n') +
'" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1' + '" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1' +
script script
); );
@@ -37,7 +37,10 @@ export async function addINIValuesWindows(
(await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n'; (await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n';
}); });
return ( return (
'Add-Content "$php_dir\\php.ini" "' + ini_values.join('\n') + '"' + script 'Add-Content "$php_dir\\php.ini" "' +
ini_values.map(v => utils.escapeForShell(v, 'win32')).join('\n') +
'"' +
script
); );
} }
+3
View File
@@ -0,0 +1,3 @@
1.0.0-0 1.10.28
2.0.0-0 2.2.28
2.3.0-0 2.9.8
+1
View File
@@ -0,0 +1 @@
Composer %s has a known GitHub token parsing bug that exposes GitHub tokens in the error output. So, GitHub authentication has not been configured for this Composer version. Please update to the latest version of Composer. See: https://github.com/composer/composer/security/advisories/GHSA-f9f8-rm49-7jv2
+4 -1
View File
@@ -21,4 +21,7 @@
23.10,mantic 23.10,mantic
24.04,noble 24.04,noble
24.10,oracular 24.10,oracular
25.10,plucky 25.05,plucky
25.10,questing
26.04,resolute
26.10,stonking
1 8 jessie
21 23.10 mantic
22 24.04 noble
23 24.10 oracular
24 25.10 25.05 plucky
25 25.10 questing
26 26.04 resolute
27 26.10 stonking
+5 -2
View File
@@ -18,7 +18,10 @@ export async function getScript(os: string): Promise<string> {
const filename = os + (await utils.scriptExtension(os)); const filename = os + (await utils.scriptExtension(os));
const script_path = path.join(__dirname, '../src/scripts', filename); const script_path = path.join(__dirname, '../src/scripts', filename);
const run_path = script_path.replace(os, 'run'); const run_path = script_path.replace(os, 'run');
const extension_csv: string = await utils.getInput('extensions', false); const extension_csv: string = utils.sanitizeShellInput(
await utils.getInput('extensions', false),
true
);
const ini_values_csv: string = await utils.getInput('ini-values', false); const ini_values_csv: string = await utils.getInput('ini-values', false);
const coverage_driver: string = await utils.getInput('coverage', false); const coverage_driver: string = await utils.getInput('coverage', false);
const tools_csv: string = await utils.getInput('tools', false); const tools_csv: string = await utils.getInput('tools', false);
@@ -28,7 +31,7 @@ export async function getScript(os: string): Promise<string> {
const ini_file: string = await utils.parseIniFile( const ini_file: string = await utils.parseIniFile(
await utils.getInput('ini-file', false) await utils.getInput('ini-file', false)
); );
let script = await utils.joins('.', script_path, version, ini_file); let script = await utils.joins('.', script_path, `'${version}'`, ini_file);
if (extension_csv) { if (extension_csv) {
script += await extensions.addExtension(extension_csv, version, os); script += await extensions.addExtension(extension_csv, version, os);
} }
+1 -1
View File
@@ -1,9 +1,9 @@
# Helper function to add gearman extension. # Helper function to add gearman extension.
add_gearman_helper() { add_gearman_helper() {
install_packages libgearman-dev
enable_extension gearman extension enable_extension gearman extension
if ! check_extension gearman; then if ! check_extension gearman; then
status="Installed and enabled" status="Installed and enabled"
install_packages libgearman-dev
if [[ "${version:?}" =~ 5.[3-6] ]]; then if [[ "${version:?}" =~ 5.[3-6] ]]; then
pecl_install gearman-1.1.2 pecl_install gearman-1.1.2
elif [[ "${version:?}" =~ 7.0 ]]; then elif [[ "${version:?}" =~ 7.0 ]]; then
+3 -21
View File
@@ -19,26 +19,6 @@ Function Get-PhalconReleaseAssetUrl() {
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)" $match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
} catch { } } catch { }
} }
} else {
$nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
try {
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(php_phalcon-php${version}${nts}-windows.*-x64.zip)"
} catch { }
if($null -eq $match) {
try {
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(php_phalcon-php${version}${nts}-windows.*-x64.zip)"
} catch { }
}
if($null -eq $match) {
try {
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)"
} catch { }
}
if($null -eq $match) {
try {
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)"
} catch { }
}
} }
if($NULL -ne $match) { if($NULL -ne $match) {
return "$github/$releases/download/v$Semver/$($match.Matches[0].Groups[1].Value)" return "$github/$releases/download/v$Semver/$($match.Matches[0].Groups[1].Value)"
@@ -73,6 +53,8 @@ Function Get-PhalconSemver() {
return '4.1.0' return '4.1.0'
} elseif (($extension_version -eq '5') -and ($version -eq '7.4')) { } elseif (($extension_version -eq '5') -and ($version -eq '7.4')) {
return '5.4.0' return '5.4.0'
} elseif (($extension_version -eq '5') -and ($version -eq '8.0')) {
return '5.10.0'
} }
return Get-PeclPackageVersion phalcon $extension_version stable stable | Select-Object -First 1 return Get-PeclPackageVersion phalcon $extension_version stable stable | Select-Object -First 1
} }
@@ -80,7 +62,7 @@ Function Get-PhalconSemver() {
# Function to install phalcon # Function to install phalcon
Function Add-PhalconHelper() { Function Add-PhalconHelper() {
$semver = Get-PhalconSemver $semver = Get-PhalconSemver
if ($extension_version -eq '3') { if ($extension_version -match '[3-4]') {
Add-PhalconFromGitHub $semver Add-PhalconFromGitHub $semver
} else { } else {
Add-Extension -Extension phalcon -Stability stable -Extension_version $semver Add-Extension -Extension phalcon -Stability stable -Extension_version $semver
+2
View File
@@ -3,6 +3,8 @@ get_phalcon_version() {
if [ "$extension" = "phalcon5" ]; then if [ "$extension" = "phalcon5" ]; then
if [ "${version:?}" = "7.4" ]; then if [ "${version:?}" = "7.4" ]; then
echo '5.4.0' echo '5.4.0'
elif [ "${version:?}" = "8.0" ]; then
echo '5.10.0'
else else
get_pecl_version phalcon stable 5 get_pecl_version phalcon stable 5
fi fi
+24 -2
View File
@@ -3,6 +3,7 @@ $composer_home = "$env:APPDATA\Composer"
$composer_bin = "$composer_home\vendor\bin" $composer_bin = "$composer_home\vendor\bin"
$composer_json = "$composer_home\composer.json" $composer_json = "$composer_home\composer.json"
$composer_lock = "$composer_home\composer.lock" $composer_lock = "$composer_home\composer.lock"
$skip_composer_github_auth = $false
# Function to configure composer. # Function to configure composer.
Function Edit-ComposerConfig() { Function Edit-ComposerConfig() {
@@ -23,6 +24,7 @@ Function Edit-ComposerConfig() {
if (-not(Test-Path $composer_json)) { if (-not(Test-Path $composer_json)) {
Set-Content -Path $composer_json -Value "{}" Set-Content -Path $composer_json -Value "{}"
} }
Get-ToolVersion "composer" $null | Out-Null
Set-ComposerEnv Set-ComposerEnv
Add-Path $composer_bin Add-Path $composer_bin
Set-ComposerAuth Set-ComposerAuth
@@ -74,8 +76,18 @@ function Test-GitHubPublicAccess {
} }
} }
Function Write-ComposerGhAuthNoOpWarning() {
$message = (Get-Content (Join-Path $src 'configs\composer-gh-auth-warn') -Raw).Trim().Replace('%s', $composer_version)
if($env:fail_fast -eq 'true') {
Add-Log "$cross" "composer" $message
} else {
Write-Output "::warning::$message"
}
}
# Function to setup authentication in composer. # Function to setup authentication in composer.
Function Set-ComposerAuth() { Function Set-ComposerAuth() {
$token = if ($env:COMPOSER_TOKEN) { $env:COMPOSER_TOKEN } else { $env:GITHUB_TOKEN }
if(Test-Path env:COMPOSER_AUTH_JSON) { if(Test-Path env:COMPOSER_AUTH_JSON) {
if(Test-Json -JSON $env:COMPOSER_AUTH_JSON) { if(Test-Json -JSON $env:COMPOSER_AUTH_JSON) {
Set-Content -Path $composer_home\auth.json -Value $env:COMPOSER_AUTH_JSON Set-Content -Path $composer_home\auth.json -Value $env:COMPOSER_AUTH_JSON
@@ -83,13 +95,18 @@ Function Set-ComposerAuth() {
Add-Log "$cross" "composer" "Could not parse COMPOSER_AUTH_JSON as valid JSON" Add-Log "$cross" "composer" "Could not parse COMPOSER_AUTH_JSON as valid JSON"
} }
} }
if($skip_composer_github_auth) {
Write-ComposerGhAuthNoOpWarning
}
$composer_auth = @() $composer_auth = @()
if(Test-Path env:PACKAGIST_TOKEN) { if(Test-Path env:PACKAGIST_TOKEN) {
$composer_auth += '"http-basic": {"repo.packagist.com": { "username": "token", "password": "' + $env:PACKAGIST_TOKEN + '"}}' $composer_auth += '"http-basic": {"repo.packagist.com": { "username": "token", "password": "' + $env:PACKAGIST_TOKEN + '"}}'
} }
$write_token = $true $write_token = $true
$token = if ($env:COMPOSER_TOKEN) { $env:COMPOSER_TOKEN } else { $env:GITHUB_TOKEN }
if ($token) { if ($token) {
if ($skip_composer_github_auth) {
$write_token = $false
}
if ($env:GITHUB_SERVER_URL -ne "https://github.com" -and -not(Test-GitHubPublicAccess $token)) { if ($env:GITHUB_SERVER_URL -ne "https://github.com" -and -not(Test-GitHubPublicAccess $token)) {
$write_token = $false $write_token = $false
} }
@@ -210,8 +227,13 @@ Function Add-Tool() {
[ValidateNotNull()] [ValidateNotNull()]
$tool, $tool,
[Parameter(Position = 2, Mandatory = $false)] [Parameter(Position = 2, Mandatory = $false)]
$ver_param $ver_param,
[Parameter(Position = 3, Mandatory = $false)]
$skip_composer_github_auth
) )
if($tool -eq "composer") {
$script:skip_composer_github_auth = $skip_composer_github_auth -eq 'true'
}
$urls = $urls -split ',' $urls = $urls -split ','
$tool_path = "$bin_dir\$tool" $tool_path = "$bin_dir\$tool"
$is_exe = ((($urls[0] | Split-Path -Extension).ToLowerInvariant()) -eq '.exe') $is_exe = ((($urls[0] | Split-Path -Extension).ToLowerInvariant()) -eq '.exe')
+29 -7
View File
@@ -3,6 +3,7 @@ export composer_home="$HOME/.composer"
export composer_bin="$composer_home/vendor/bin" export composer_bin="$composer_home/vendor/bin"
export composer_json="$composer_home/composer.json" export composer_json="$composer_home/composer.json"
export composer_lock="$composer_home/composer.lock" export composer_lock="$composer_home/composer.lock"
skip_composer_github_auth=false
# Function to extract tool version. # Function to extract tool version.
get_tool_version() { get_tool_version() {
@@ -41,6 +42,7 @@ configure_composer() {
echo '{}' | tee "$composer_json" >/dev/null echo '{}' | tee "$composer_json" >/dev/null
chmod 644 "$composer_json" chmod 644 "$composer_json"
fi fi
get_tool_version composer >/dev/null
set_composer_env set_composer_env
add_path "$composer_bin" add_path "$composer_bin"
set_composer_auth set_composer_auth
@@ -70,22 +72,39 @@ can_access_public_github() {
curl --fail -s -H "Authorization: token $1" 'https://api.github.com/' >/dev/null 2>&1 curl --fail -s -H "Authorization: token $1" 'https://api.github.com/' >/dev/null 2>&1
} }
composer_gh_auth_no_op() {
local message
message="$(<"${src:?}"/configs/composer-gh-auth-warn)"
message="${message//%s/$composer_version}"
if [ "${fail_fast:-false}" = "true" ]; then
add_log "${cross:?}" "composer" "$message"
else
echo "::warning::$message"
fi
}
# Function to setup authentication in composer. # Function to setup authentication in composer.
set_composer_auth() { set_composer_auth() {
if [ -n "$COMPOSER_AUTH_JSON" ]; then token="${COMPOSER_TOKEN:-$GITHUB_TOKEN}"
if php -r "json_decode('$COMPOSER_AUTH_JSON'); if(json_last_error() !== JSON_ERROR_NONE) { throw new Exception('invalid json'); }"; then if [ -n "${COMPOSER_AUTH_JSON:-}" ]; then
echo "$COMPOSER_AUTH_JSON" | tee "$composer_home/auth.json" >/dev/null if printf '%s' "$COMPOSER_AUTH_JSON" | jq -e . >/dev/null; then
printf '%s' "$COMPOSER_AUTH_JSON" | tee "$composer_home/auth.json" >/dev/null
else else
add_log "${cross:?}" "composer" "Could not parse COMPOSER_AUTH_JSON as valid JSON" add_log "${cross:?}" "composer" "Could not parse COMPOSER_AUTH_JSON as valid JSON"
fi fi
fi fi
if [ "$skip_composer_github_auth" = "true" ]; then
composer_gh_auth_no_op
fi
composer_auth=() composer_auth=()
if [ -n "$PACKAGIST_TOKEN" ]; then if [ -n "$PACKAGIST_TOKEN" ]; then
composer_auth+=( '"http-basic": {"repo.packagist.com": { "username": "token", "password": "'"$PACKAGIST_TOKEN"'"}}' ) composer_auth+=( '"http-basic": {"repo.packagist.com": { "username": "token", "password": "'"$PACKAGIST_TOKEN"'"}}' )
fi fi
token="${COMPOSER_TOKEN:-$GITHUB_TOKEN}"
if [ -n "$token" ]; then if [ -n "$token" ]; then
write_token=true write_token=true
if [ "$skip_composer_github_auth" = "true" ]; then
write_token=false
fi
if [ "$GITHUB_SERVER_URL" != "https://github.com" ]; then if [ "$GITHUB_SERVER_URL" != "https://github.com" ]; then
can_access_public_github "$token" || write_token=false can_access_public_github "$token" || write_token=false
fi fi
@@ -182,6 +201,9 @@ add_tool() {
url=$1 url=$1
tool=$2 tool=$2
ver_param=$3 ver_param=$3
if [ "$tool" = "composer" ]; then
skip_composer_github_auth="${4:-false}"
fi
tool_path="$tool_path_dir/$tool" tool_path="$tool_path_dir/$tool"
if ! [ -d "$tool_path_dir" ]; then if ! [ -d "$tool_path_dir" ]; then
sudo mkdir -p "$tool_path_dir" sudo mkdir -p "$tool_path_dir"
@@ -206,8 +228,8 @@ add_tool() {
url[0]="${url[0]//releases\/latest\/download/releases/download/$(get -s -n "" "$(echo "${url[0]}" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "${url[0]}" | sed -e "s/.*\///")" | cut -d '/' -f 1)}" url[0]="${url[0]//releases\/latest\/download/releases/download/$(get -s -n "" "$(echo "${url[0]}" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "${url[0]}" | sed -e "s/.*\///")" | cut -d '/' -f 1)}"
status_code=$(get -v -e "$tool_path" "${url[0]}") status_code=$(get -v -e "$tool_path" "${url[0]}")
fi fi
if [ "$status_code" = "200" ] && [ "$use_cache" = "true" ]; then if [ "$status_code" = "200" ]; then
sudo cp -a "$tool_path" "$cache_path" [ "$use_cache" = "true" ] && sudo cp -a "$tool_path" "$cache_path"
elif [ -f "$tool_path.bak" ]; then elif [ -f "$tool_path.bak" ]; then
sudo mv "$tool_path.bak" "$tool_path" sudo mv "$tool_path.bak" "$tool_path"
fi fi
@@ -215,8 +237,8 @@ add_tool() {
fi fi
if [ "$status_code" = "200" ]; then if [ "$status_code" = "200" ]; then
add_tools_helper "$tool" add_tools_helper "$tool"
[ -L "$tool_cache_path_dir/$tool" ] || sudo ln -s "$tool_path" "$tool_cache_path_dir/$tool" 2>/dev/null || true
tool_version=$(get_tool_version "$tool" "$ver_param") tool_version=$(get_tool_version "$tool" "$ver_param")
sudo ln -sfn "$tool_path" "$tool_cache_path_dir/$tool" 2>/dev/null || true
add_log "${tick:?}" "$tool" "Added $tool $tool_version" add_log "${tick:?}" "$tool" "Added $tool $tool_version"
else else
if [ "$tool" = "composer" ]; then if [ "$tool" = "composer" ]; then
+1
View File
@@ -22,6 +22,7 @@ add_brew_tap() {
fi fi
fi fi
fi fi
brew trust "$tap" >/dev/null 2>&1
} }
# Function to get brew prefix. # Function to get brew prefix.
+13 -9
View File
@@ -203,16 +203,20 @@ Function Install-PSPackage() {
$cmdlet $cmdlet
) )
$module_path = "$bin_dir\$psm1_path.psm1" $module_path = "$bin_dir\$psm1_path.psm1"
if(-not (Test-Path $module_path -PathType Leaf)) { $imported = $false
$zip_file = "$bin_dir\$package.zip" try {
Get-File -Url $url -OutFile $zip_file if(-not (Test-Path $module_path -PathType Leaf)) {
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force $zip_file = "$bin_dir\$package.zip"
} Get-File -Url $url -OutFile $zip_file
Import-Module $module_path Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force -ErrorAction Stop
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) { }
Install-Module -Name $package -Force Import-Module $module_path -ErrorAction Stop
} else { $imported = $null -ne (Get-Command $cmdlet -ErrorAction SilentlyContinue)
} catch { }
if($imported) {
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path" Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
} else {
Install-Module -Name $package -Force
} }
} }
+47 -9
View File
@@ -95,6 +95,42 @@ interface DeployerManifestEntry {
url: string; url: string;
} }
export function skipGitHubAuthForComposerVersion(version: string): boolean {
if (!/^\d+\.\d+\.\d+(?:-[\w-]+)?$/.test(version)) {
return false;
}
return fs
.readFileSync(
path.join(__dirname, '../src/configs/composer-gh-auth-no-op'),
'utf8'
)
.trim()
.split(/\r?\n/)
.some(range => {
const [min, max] = range.trim().split(/\s+/);
return (
cv.compareVersions(version, min) >= 0 &&
cv.compareVersions(version, max) < 0
);
});
}
export function cleanComposerAuthJson(): void {
try {
const auth_json = process.env['COMPOSER_AUTH_JSON'] || '';
if (!auth_json.includes('github-oauth')) return;
const auth = JSON.parse(auth_json);
delete auth['github-oauth'];
if (!Object.keys(auth).length) {
delete process.env['COMPOSER_AUTH_JSON'];
} else {
process.env['COMPOSER_AUTH_JSON'] = JSON.stringify(auth);
}
} catch {
return;
}
}
/** /**
* Function to get version in semver format. * Function to get version in semver format.
* *
@@ -195,7 +231,7 @@ export async function getVersion(
case !!data.repository && major_minor_regex.test(data.version): case !!data.repository && major_minor_regex.test(data.version):
return await getSemverVersion(data); return await getSemverVersion(data);
default: default:
return data.version.replace(/[><=^~]*/, ''); return data.version.replace(/[^a-zA-Z0-9_.:@+,/-]/g, '');
} }
} }
@@ -311,12 +347,9 @@ export async function addArchive(data: ToolData): Promise<string> {
export async function addPackage(data: ToolData): Promise<string> { export async function addPackage(data: ToolData): Promise<string> {
const command = await utils.getCommand(data.os, 'composer_tool'); const command = await utils.getCommand(data.os, 'composer_tool');
const parts: string[] = data.repository.split('/'); const parts: string[] = data.repository.split('/');
const args: string = await utils.joins( const args = [parts[1], data.release, parts[0] + '/', data.scope]
parts[1], .map(a => utils.safeArg(a, data.os))
data.release, .join(' ');
parts[0] + '/',
data.scope
);
return command + args; return command + args;
} }
@@ -383,6 +416,7 @@ export async function addComposer(data: ToolData): Promise<string> {
const version_source_url = `${getcomposer}/download/${channel}/composer.phar`; const version_source_url = `${getcomposer}/download/${channel}/composer.phar`;
let cache_url = `${releases_url},${spc_url},${cds_url}`; let cache_url = `${releases_url},${spc_url},${cds_url}`;
let source_url = `${getcomposer}/composer.phar`; let source_url = `${getcomposer}/composer.phar`;
let skip_composer_github_auth = '';
switch (true) { switch (true) {
case /^snapshot$/.test(channel): case /^snapshot$/.test(channel):
source_url = is_lts ? lts_url : source_url; source_url = is_lts ? lts_url : source_url;
@@ -393,7 +427,11 @@ export async function addComposer(data: ToolData): Promise<string> {
case /^1$/.test(channel): case /^1$/.test(channel):
source_url = channel_source_url; source_url = channel_source_url;
break; break;
case /^\d+\.\d+\.\d+[\w-]*$/.test(data.version): case /^\d+\.\d+\.\d+(?:-[\w-]+)?$/.test(data.version):
if (skipGitHubAuthForComposerVersion(data.version)) {
cleanComposerAuthJson();
skip_composer_github_auth = ' true';
}
cache_url = `${github}/${data.repository}/releases/download/${data.version}/composer.phar`; cache_url = `${github}/${data.repository}/releases/download/${data.version}/composer.phar`;
source_url = version_source_url; source_url = version_source_url;
break; break;
@@ -402,7 +440,7 @@ export async function addComposer(data: ToolData): Promise<string> {
} }
const use_cache: boolean = (await utils.readEnv('NO_TOOLS_CACHE')) !== 'true'; const use_cache: boolean = (await utils.readEnv('NO_TOOLS_CACHE')) !== 'true';
data.url = use_cache ? `${cache_url},${source_url}` : source_url; data.url = use_cache ? `${cache_url},${source_url}` : source_url;
data.version_parameter = data.version; data.version_parameter = data.version + skip_composer_github_auth;
return await addArchive(data); return await addArchive(data);
} }
+87 -36
View File
@@ -9,16 +9,19 @@ import * as fetch from './fetch';
* @param property * @param property
*/ */
export async function readEnv(property: string): Promise<string> { export async function readEnv(property: string): Promise<string> {
if (!/^[A-Za-z0-9_-]+$/.test(property)) {
return '';
}
const property_lc: string = property.toLowerCase(); const property_lc: string = property.toLowerCase();
const property_uc: string = property.toUpperCase(); const property_uc: string = property.toUpperCase();
return ( const candidates = [
process.env[property] || property,
process.env[property_lc] || property_lc,
process.env[property_uc] || property_uc,
process.env[property_lc.replace('_', '-')] || property_lc.replace('_', '-'),
process.env[property_uc.replace('_', '-')] || property_uc.replace('_', '-')
'' ].filter((value, index, array) => array.indexOf(value) === index);
); return candidates.map(name => process.env[name] || '').find(Boolean) || '';
} }
/** /**
@@ -62,15 +65,31 @@ export async function getManifestURLS(): Promise<string[]> {
*/ */
export async function parseVersion(version: string): Promise<string> { export async function parseVersion(version: string): Promise<string> {
switch (true) { switch (true) {
case /^pre(-installed)?$/.test(version):
return 'pre';
case /^(latest|lowest|highest|nightly|master|\d+\.x)$/.test(version): case /^(latest|lowest|highest|nightly|master|\d+\.x)$/.test(version):
for (const manifestURL of await getManifestURLS()) { for (const manifestURL of await getManifestURLS()) {
const fetchResult = await fetch.fetch(manifestURL); const fetchResult = await fetch.fetch(manifestURL);
if (fetchResult['data'] ?? false) { if (fetchResult['data'] ?? false) {
return JSON.parse(fetchResult['data'])[version]; const resolved: string | undefined = JSON.parse(fetchResult['data'])[
version
];
if (resolved === undefined) {
throw new Error(`Invalid PHP version: ${version.slice(0, 20)}`);
}
if (!/^\d+\.\d+$/.test(resolved)) {
throw new Error(
`Invalid PHP version in manifest: ${resolved.slice(0, 10)}`
);
}
return resolved;
} }
} }
throw new Error(`Could not fetch the PHP version manifest.`); throw new Error(`Could not fetch the PHP version manifest.`);
default: default:
if (!/^\d+(\.\d+){0,2}$/.test(version)) {
throw new Error(`Invalid PHP version: ${version.slice(0, 20)}`);
}
switch (true) { switch (true) {
case version.length > 1: case version.length > 1:
return version.slice(0, 3); return version.slice(0, 3);
@@ -86,14 +105,11 @@ export async function parseVersion(version: string): Promise<string> {
* @param ini_file * @param ini_file
*/ */
export async function parseIniFile(ini_file: string): Promise<string> { export async function parseIniFile(ini_file: string): Promise<string> {
switch (true) { if (/^(production|development|none)$/.test(ini_file)) {
case /^(production|development|none)$/.test(ini_file): return ini_file;
return ini_file;
case /php\.ini-(production|development)$/.test(ini_file):
return ini_file.split('-')[1];
default:
return 'production';
} }
const match = ini_file.match(/php\.ini-(production|development)$/);
return match ? match[1] : 'production';
} }
/** /**
@@ -172,10 +188,10 @@ export async function log(
export async function stepLog(message: string, os: string): Promise<string> { export async function stepLog(message: string, os: string): Promise<string> {
switch (os) { switch (os) {
case 'win32': case 'win32':
return 'Step-Log "' + message + '"'; return 'Step-Log "' + escapeForShell(message, os) + '"';
case 'linux': case 'linux':
case 'darwin': case 'darwin':
return 'step_log "' + message + '"'; return 'step_log "' + escapeForShell(message, os) + '"';
default: default:
return await log('Platform ' + os + ' is not supported', os, 'error'); return await log('Platform ' + os + ' is not supported', os, 'error');
} }
@@ -194,17 +210,40 @@ export async function addLog(
message: string, message: string,
os: string os: string
): Promise<string> { ): Promise<string> {
const sub = escapeForShell(subject, os);
const msg = escapeForShell(message, os);
switch (os) { switch (os) {
case 'win32': case 'win32':
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"'; return `Add-Log "${mark}" "${sub}" "${msg}"`;
case 'linux': case 'linux':
case 'darwin': case 'darwin':
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"'; return `add_log "${mark}" "${sub}" "${msg}"`;
default: default:
return await log('Platform ' + os + ' is not supported', os, 'error'); return await log('Platform ' + os + ' is not supported', os, 'error');
} }
} }
export function escapeForShell(value: string, os: string): string {
if (os === 'win32') {
return value.replace(/[`$"]/g, '`$&');
}
return value.replace(/[\\`$"]/g, '\\$&');
}
export function safeArg(value: string, os: string): string {
if (!/^[a-zA-Z0-9_./:@+,~^-]*$/.test(value)) {
return '"' + escapeForShell(value, os) + '"';
}
return value;
}
export function sanitizeShellInput(value: string, strict = false): string {
const pattern = strict
? /[$`"';|&(){}[\]\\<>*?\n\r\t]/g
: /[$`"';|&(){}[\]\\\n\r\t]/g;
return value.replace(pattern, '');
}
/** /**
* Function to break extension csv into an array * Function to break extension csv into an array
* *
@@ -224,11 +263,11 @@ export async function extensionArray(
.split(',') .split(',')
.map(function (extension: string) { .map(function (extension: string) {
extension = extension.trim().replace(/^\\\s*/, '');
if (/.+-.+\/.+@.+/.test(extension)) { if (/.+-.+\/.+@.+/.test(extension)) {
return extension; return extension;
} }
return extension return extension
.trim()
.toLowerCase() .toLowerCase()
.replace(/^(:)?(php[-_]|none|zend )|(-[^-]*)-/, '$1$3'); .replace(/^(:)?(php[-_]|none|zend )|(-[^-]*)-/, '$1$3');
}) })
@@ -431,22 +470,35 @@ export async function parseExtensionSource(
); );
} }
const VERSION_INPUT_REGEX =
/^(latest|lowest|highest|nightly|master|pre|pre-installed|\d+\.x|\d+(\.\d+){0,2})$/;
function validatePHPVersionInput(version: string, source: string): string {
if (!VERSION_INPUT_REGEX.test(version)) {
throw new Error(
`Invalid PHP version in ${source}: ${version.slice(0, 20)}`
);
}
return version;
}
/** /**
* Read php version from input or file * Read php version from input or file
*/ */
export async function readPHPVersion(): Promise<string> { export async function readPHPVersion(): Promise<string> {
const version = await getInput('php-version', false); const version = await getInput('php-version', false);
if (version) { if (version) {
return version; return validatePHPVersionInput(version, 'php-version input');
} }
const versionFile = const versionFile =
(await getInput('php-version-file', false)) || '.php-version'; (await getInput('php-version-file', false)) || '.php-version';
if (fs.existsSync(versionFile)) { if (fs.existsSync(versionFile)) {
const contents: string = fs.readFileSync(versionFile, 'utf8'); const contents: string = fs.readFileSync(versionFile, 'utf8');
const match: RegExpMatchArray | null = contents.match( const match = contents.match(/^(?:php\s)?(\d+\.\d+\.\d+)$/m);
/^(?:php\s)?(\d+\.\d+\.\d+)$/m return validatePHPVersionInput(
match ? match[1] : contents.trim(),
versionFile
); );
return match ? match[1] : contents.trim();
} else if (versionFile !== '.php-version') { } else if (versionFile !== '.php-version') {
throw new Error(`Could not find '${versionFile}' file.`); throw new Error(`Could not find '${versionFile}' file.`);
} }
@@ -456,11 +508,11 @@ export async function readPHPVersion(): Promise<string> {
if (fs.existsSync(composerLock)) { if (fs.existsSync(composerLock)) {
const lockFileContents = JSON.parse(fs.readFileSync(composerLock, 'utf8')); const lockFileContents = JSON.parse(fs.readFileSync(composerLock, 'utf8'));
/* istanbul ignore next */ /* istanbul ignore next */
if ( if (lockFileContents['platform-overrides']?.['php']) {
lockFileContents['platform-overrides'] && return validatePHPVersionInput(
lockFileContents['platform-overrides']['php'] lockFileContents['platform-overrides']['php'],
) { 'composer.lock platform-overrides.php'
return lockFileContents['platform-overrides']['php']; );
} }
} }
@@ -470,12 +522,11 @@ export async function readPHPVersion(): Promise<string> {
fs.readFileSync(composerJson, 'utf8') fs.readFileSync(composerJson, 'utf8')
); );
/* istanbul ignore next */ /* istanbul ignore next */
if ( if (composerFileContents['config']?.['platform']?.['php']) {
composerFileContents['config'] && return validatePHPVersionInput(
composerFileContents['config']['platform'] && composerFileContents['config']['platform']['php'],
composerFileContents['config']['platform']['php'] 'composer.json config.platform.php'
) { );
return composerFileContents['config']['platform']['php'];
} }
} }