Skip to content

Commit

Permalink
Merge pull request #227 from nanasess/improve/php8.3
Browse files Browse the repository at this point in the history
Add PHP8.3
  • Loading branch information
nanasess authored Nov 24, 2023
2 parents 2c469fe + 895917e commit 6b9aab7
Show file tree
Hide file tree
Showing 12 changed files with 13,966 additions and 14,191 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-20.04, windows-2022, windows-2019]
php: ['5.4', '5.5', '5.6', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '7.2.11', '7.2.12', '8.1.9', '8.2']
php: ['5.4', '5.5', '5.6', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '7.2.11', '7.2.12', '8.1.9', '8.2', '8.3']
exclude:
- os: windows-2019
php: 7.2.11
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This action sets up a PHP environment for use in actions by:
- 8.0
- 8.1
- 8.2
- 8.3

*Patch version can also be set. e.g. 7.2.11*

Expand Down
2 changes: 2 additions & 0 deletions __tests__/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('example tests', () => {
expect(installer.hasAptVersion(new Number('8').toFixed(1))).toBe(true);
expect(installer.hasAptVersion('8.2snapshot')).toBe(false);
expect(installer.hasAptVersion('8.2')).toBe(true);
expect(installer.hasAptVersion('8.3')).toBe(true);
});
it('convertInstallVersion tests', async () => {
expect(await installer.convertInstallVersion('5')).toBe('5');
Expand All @@ -42,6 +43,7 @@ describe('example tests', () => {
// expect(await installer.convertInstallVersion('8.0')).toBe('8.0.6');
// expect(await installer.convertInstallVersion('8.1')).toBe('8.1.2');
expect(await installer.convertInstallVersion('7.3.8')).toBe('7.3.8');
expect(await installer.convertInstallVersion('8.3')).toBe('8.3.0');
// expect(await installer.convertInstallVersion('8.2snapshot')).toBe('8.2snapshot');
});
});
28,065 changes: 13,904 additions & 14,161 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

37 changes: 18 additions & 19 deletions dist/licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -511,29 +511,28 @@ THE SOFTWARE.

mime-db
MIT
(The MIT License)

Copyright (c) 2014 Jonathan Ong <[email protected]>
Copyright (c) 2015-2022 Douglas Christopher Wilson <[email protected]>
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
Copyright (c) 2014 Jonathan Ong [email protected]

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


mime-types
Expand Down
7 changes: 7 additions & 0 deletions lib/apt-install-php-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,10 @@ sudo phpdismod -s cli xdebug

sudo bash -c 'echo "opcache.enable_cli=1" >> /etc/php/'$version'/cli/conf.d/10-opcache.ini'
sudo bash -c 'echo "apc.enable_cli=1" >> /etc/php/'$version'/cli/conf.d/20-apcu.ini'

if [[ `echo "$version >= 8.1" | bc` == 1 ]]
then
sudo bash -c 'echo "opcache.enable = 1" >> /etc/php/'$version'/cli/conf.d/10-opcache.ini'
sudo bash -c 'echo "opcache.jit = tracing" >> /etc/php/'$version'/cli/conf.d/10-opcache.ini'
sudo bash -c 'echo "opcache.jit_buffer_size = 128M" >> /etc/php/'$version'/cli/conf.d/10-opcache.ini'
fi
16 changes: 14 additions & 2 deletions lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertInstallVersion = exports.hasPatchVersion = exports.hasAptVersion = exports.installPhp = void 0;
const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec"));
const path = __importStar(require("path"));
const semver = __importStar(require("semver"));
Expand All @@ -44,11 +45,18 @@ const PHP_RELEASES_URL = 'https://www.php.net/releases/index.php?json=true';
function installPhp(version) {
return __awaiter(this, void 0, void 0, function* () {
const installVersion = yield convertInstallVersion(version);
core.info(`Installing PHP ${installVersion}`);
if (process.platform === 'linux') {
const hasPatch = hasPatchVersion(version);
core.info(`hasPatchVersion(${version}): ${hasPatch}`);
const hasApt = hasAptVersion(version);
core.info(`hasAptVersion(${version}): ${hasApt}`);
if (!hasPatchVersion(version) && hasAptVersion(version)) {
core.info(`Installing PHP ${version} via apt`);
return yield exec.exec(path.join(__dirname, '../lib', 'apt-install-php-ubuntu.sh'), [new Number(version).toFixed(1)]);
}
else {
core.info(`Installing PHP ${installVersion} via phpenv`);
return yield exec.exec(path.join(__dirname, '../lib', 'phpenv-install-php-ubuntu.sh'), [installVersion]);
}
}
Expand All @@ -72,7 +80,7 @@ function hasAptVersion(version) {
return false;
}
}
return semver.satisfies(Semver.version, '5.6 || <=7.4 || <= 8.2');
return semver.satisfies(Semver.version, '5.6 || <=7.4 || <= 8.3');
}
exports.hasAptVersion = hasAptVersion;
function hasPatchVersion(version) {
Expand All @@ -99,7 +107,9 @@ function convertInstallVersion(version) {
return '7.3.30';
}
try {
const json = (yield superagent_1.default.get(`${PHP_RELEASES_URL}&version=${version}`).then(response => response.body));
const json = (yield superagent_1.default
.get(`${PHP_RELEASES_URL}&version=${version}`)
.then(response => response.body));
if (json.version === undefined) {
throw new Error('version is undefined');
}
Expand Down Expand Up @@ -129,6 +139,8 @@ function convertInstallVersion(version) {
return '8.1.3';
case '8.2':
return '8.2.0';
case '8.3':
return '8.3.0';
default:
return version;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/setup-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const phpSpec = core.getInput('php-version', { required: true });
console.log(`##Installing PHP ${phpSpec}`);
core.info(`Installing PHP ${phpSpec}`);
const exitCode = yield (0, installer_1.installPhp)(phpSpec);
if (exitCode !== 0) {
throw new Error(`An error occurred while installing PHP(Code: ${exitCode}`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-php",
"version": "4.0.0",
"version": "4.0.1",
"private": true,
"description": "setup php action",
"main": "dist/index.js",
Expand Down
19 changes: 15 additions & 4 deletions src/installer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as path from 'path';
import * as semver from 'semver';
Expand All @@ -7,13 +8,21 @@ const PHP_RELEASES_URL = 'https://www.php.net/releases/index.php?json=true';

export async function installPhp(version: string): Promise<number> {
const installVersion = await convertInstallVersion(version);

core.info(`Installing PHP ${installVersion}`);
if (process.platform === 'linux') {
const hasPatch = hasPatchVersion(version);
core.info(`hasPatchVersion(${version}): ${hasPatch}`);
const hasApt = hasAptVersion(version);
core.info(`hasAptVersion(${version}): ${hasApt}`);
if (!hasPatchVersion(version) && hasAptVersion(version)) {
core.info(`Installing PHP ${version} via apt`);
return await exec.exec(
path.join(__dirname, '../lib', 'apt-install-php-ubuntu.sh'),
[new Number(version).toFixed(1)]
);
} else {
core.info(`Installing PHP ${installVersion} via phpenv`);
return await exec.exec(
path.join(__dirname, '../lib', 'phpenv-install-php-ubuntu.sh'),
[installVersion]
Expand Down Expand Up @@ -42,7 +51,7 @@ export function hasAptVersion(version: string): boolean {
return false;
}
}
return semver.satisfies(Semver.version, '5.6 || <=7.4 || <= 8.2');
return semver.satisfies(Semver.version, '5.6 || <=7.4 || <= 8.3');
}
export function hasPatchVersion(version: string): boolean {
const Semver = semver.coerce(version);
Expand Down Expand Up @@ -72,9 +81,9 @@ export async function convertInstallVersion(version: string): Promise<string> {
return '7.3.30';
}
try {
const json = (await superagent.get(
`${PHP_RELEASES_URL}&version=${version}`
).then(response => response.body)) as PHPReleaseJson;
const json = (await superagent
.get(`${PHP_RELEASES_URL}&version=${version}`)
.then(response => response.body)) as PHPReleaseJson;

if (json.version === undefined) {
throw new Error('version is undefined');
Expand Down Expand Up @@ -105,6 +114,8 @@ export async function convertInstallVersion(version: string): Promise<string> {
return '8.1.3';
case '8.2':
return '8.2.0';
case '8.3':
return '8.3.0';
default:
return version;
}
Expand Down
2 changes: 1 addition & 1 deletion src/setup-php.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {installPhp} from './installer';
async function run() {
try {
const phpSpec = core.getInput('php-version', {required: true});
console.log(`##Installing PHP ${phpSpec}`);
core.info(`Installing PHP ${phpSpec}`);
const exitCode = await installPhp(phpSpec);
if (exitCode !== 0) {
throw new Error(
Expand Down

0 comments on commit 6b9aab7

Please sign in to comment.