2 Commits
1.2.0 ... 1.3.0

Author SHA1 Message Date
Shivam Mathur
3809746e7d Merge pull request #16 from shivammathur/develop
1.3.0
2020-10-13 14:29:02 +05:30
Shivam Mathur
f55a0043ab Add support for PHP 8.1
Add support for alias latest

Bump version to 1.3.0
2020-10-13 14:22:54 +05:30
13 changed files with 904 additions and 579 deletions

View File

@@ -7,15 +7,28 @@ jest.mock('@actions/core', () => ({
}));
describe('Utils tests', () => {
it('checking readEnv', async () => {
process.env['test'] = 'setup-php';
expect(await utils.readEnv('test')).toBe('setup-php');
expect(await utils.readEnv('undefined')).toBe('');
});
it('checking getInput', async () => {
process.env['test'] = 'cache-extensions';
process.env['undefined'] = '';
expect(await utils.getInput('test', false)).toBe('cache-extensions');
expect(await utils.getInput('undefined', false)).toBe('');
process.env['test'] = 'setup-php';
expect(await utils.getInput('test', false)).toBe('setup-php');
expect(await utils.getInput('cache-extensions', false)).toBe(
'cache-extensions'
);
expect(await utils.getInput('DoesNotExist', false)).toBe('');
expect(async () => {
await utils.getInput('DoesNotExist', true);
}).rejects.toThrow('Input required and not supplied: DoesNotExist');
});
it('checking parseVersion', async () => {
expect(await utils.parseVersion('7')).toBe('7.0');
expect(await utils.parseVersion('7.4')).toBe('7.4');
expect(await utils.parseVersion('latest')).toBe('7.4');
});
it('checking filterExtensions', async () => {

55
dist/index.js vendored
View File

@@ -1054,8 +1054,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.filterExtensions = exports.getInput = void 0;
exports.filterExtensions = exports.parseVersion = exports.getInput = exports.readEnv = void 0;
const core = __importStar(__webpack_require__(470));
/**
* Function to read environment variable and return a string value.
*
* @param property
*/
async function readEnv(property) {
const value = process.env[property];
switch (value) {
case undefined:
return '';
default:
return value;
}
}
exports.readEnv = readEnv;
/**
* Function to get inputs from both with and env annotations.
*
@@ -1063,16 +1078,39 @@ const core = __importStar(__webpack_require__(470));
* @param mandatory
*/
async function getInput(name, mandatory) {
const input = process.env[name];
switch (input) {
case '':
case undefined:
return core.getInput(name, { required: mandatory });
default:
const input = core.getInput(name);
const env_input = await readEnv(name);
switch (true) {
case input != '':
return input;
case input == '' && env_input != '':
return env_input;
case input == '' && env_input == '' && mandatory:
throw new Error(`Input required and not supplied: ${name}`);
default:
return '';
}
}
exports.getInput = getInput;
/**
* Function to parse PHP version.
*
* @param version
*/
async function parseVersion(version) {
switch (version) {
case 'latest':
return '7.4';
default:
switch (true) {
case version.length > 1:
return version.slice(0, 3);
default:
return version + '.0';
}
}
}
exports.parseVersion = parseVersion;
/**
* Function to filter extensions
*
@@ -1687,8 +1725,7 @@ const utils = __importStar(__webpack_require__(163));
*/
async function run() {
try {
let version = await utils.getInput('php-version', true);
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
const version = await utils.parseVersion(await utils.getInput('php-version', true));
const extensions = await utils.filterExtensions(await utils.getInput('extensions', true));
const key = await utils.getInput('key', true);
const script_path = path.join(__dirname, '../src/extensions.sh');

1057
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "cache-extensions",
"version": "1.2.0",
"version": "1.3.0",
"private": false,
"description": "Cache extensions in GitHub Actions",
"main": "dist/index.js",
@@ -29,18 +29,18 @@
},
"devDependencies": {
"@types/jest": "^26.0.14",
"@types/node": "^14.11.2",
"@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/parser": "^4.3.0",
"@types/node": "^14.11.8",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.1",
"@zeit/ncc": "^0.22.3",
"eslint": "^7.10.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.12.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.0.2",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0",
"jest": "^26.4.2",
"jest-circus": "^26.4.2",
"jest": "^26.5.3",
"jest-circus": "^26.5.3",
"prettier": "^2.1.2",
"ts-jest": "^26.4.1",
"typescript": "^4.0.3"

View File

@@ -8,9 +8,10 @@ import * as utils from './utils';
*/
export async function run(): Promise<void> {
try {
let version: string = await utils.getInput('php-version', true);
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
const extensions = await utils.filterExtensions(
const version: string = await utils.parseVersion(
await utils.getInput('php-version', true)
);
const extensions: string = await utils.filterExtensions(
await utils.getInput('extensions', true)
);
const key: string = await utils.getInput('key', true);

View File

@@ -1,12 +1,11 @@
linux_extension_dir() {
apiv=$1
old_versions_linux="5.[4-5]"
if [ "$version" = "5.3" ]; then
echo "/home/runner/php/5.3.29/lib/php/extensions/no-debug-non-zts-$apiv"
elif [[ "$version" =~ $old_versions_linux ]]; then
elif [[ "$version" =~ $old_versions ]]; then
echo "/usr/lib/php5/$apiv"
elif [ "$version" = "8.0" ]; then
echo "/usr/local/php/8.0/lib/php/extensions/no-debug-non-zts-$apiv"
elif [[ "$version" =~ $nightly_versions ]]; then
echo "/usr/local/php/$version/lib/php/extensions/no-debug-non-zts-$apiv"
else
echo "/usr/lib/php/$apiv"
fi
@@ -33,6 +32,7 @@ get_apiv() {
7.2) echo "20170718" ;;
7.3) echo "20180731" ;;
7.4) echo "20190902" ;;
8.0) echo "20200930" ;;
*)
php_h="https://raw.githubusercontent.com/php/php-src/master/main/php.h"
curl -sSL --retry 5 "$php_h" | grep "PHP_API_VERSION" | cut -d' ' -f 3
@@ -73,6 +73,8 @@ extensions=$1
key=$2
version=$3
os=$(uname -s)
old_versions="5.[4-5]"
nightly_versions="8.[0-1]"
if [ "$os" = "Linux" ]; then
release=$(lsb_release -s -c)
os=$os-$release
@@ -88,7 +90,7 @@ else
os="Windows"
dir='C:\\tools\\php\\ext'
fi
if [ "$version" = "8.0" ]; then
if [[ "$version" =~ $nightly_versions ]]; then
key="$key-20200930"
fi
key="$os"-ext-"$version"-$(echo -n "$extensions-$key" | openssl dgst -sha256 | cut -d ' ' -f 2)

View File

@@ -6,8 +6,8 @@ Core
ctype
curl
date
dba
dom
enchant
exif
FFI
fileinfo
@@ -21,10 +21,12 @@ iconv
ioncube
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcov
@@ -32,11 +34,14 @@ pcre
PDO
oci8
PDO_OCI
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
phpdbg_webhelper
posix
pspell
readline
@@ -46,6 +51,7 @@ shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
@@ -54,9 +60,9 @@ sysvsem
sysvshm
tidy
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
@@ -69,4 +75,3 @@ blackfire
[Zend Modules]
Zend OPcache
Xdebug

View File

@@ -0,0 +1,77 @@
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
ioncube
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcov
pcre
PDO
oci8
PDO_OCI
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
phpdbg_webhelper
posix
pspell
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xdebug
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
phalcon3
phalcon4
blackfire
[Zend Modules]
Zend OPcache
Xdebug

View File

@@ -4,11 +4,10 @@ bz2
calendar
Core
ctype
cubrid
curl
date
dba
dom
enchant
exif
FFI
fileinfo
@@ -22,10 +21,12 @@ iconv
ioncube
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcov
@@ -33,11 +34,14 @@ pcre
PDO
oci8
PDO_OCI
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
phpdbg_webhelper
posix
pspell
readline
@@ -47,6 +51,7 @@ shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
@@ -55,9 +60,9 @@ sysvsem
sysvshm
tidy
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache

View File

@@ -0,0 +1,77 @@
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
ioncube
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcov
pcre
PDO
oci8
PDO_OCI
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
phpdbg_webhelper
posix
pspell
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xdebug
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
phalcon3
phalcon4
blackfire
[Zend Modules]
Zend OPcache
Xdebug

View File

@@ -4,11 +4,10 @@ bz2
calendar
Core
ctype
cubrid
curl
date
dba
dom
enchant
exif
FFI
fileinfo
@@ -22,10 +21,12 @@ iconv
ioncube
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcov
@@ -33,11 +34,14 @@ pcre
PDO
oci8
PDO_OCI
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
phpdbg_webhelper
posix
pspell
readline
@@ -47,6 +51,7 @@ shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
@@ -55,9 +60,9 @@ sysvsem
sysvshm
tidy
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
@@ -70,4 +75,3 @@ blackfire
[Zend Modules]
Zend OPcache
Xdebug

View File

@@ -0,0 +1,77 @@
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
ioncube
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcov
pcre
PDO
oci8
PDO_OCI
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
phpdbg_webhelper
posix
pspell
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xdebug
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
phalcon3
phalcon4
blackfire
[Zend Modules]
Zend OPcache
Xdebug

View File

@@ -1,6 +1,21 @@
import * as fs from 'fs';
import * as core from '@actions/core';
/**
* Function to read environment variable and return a string value.
*
* @param property
*/
export async function readEnv(property: string): Promise<string> {
const value = process.env[property];
switch (value) {
case undefined:
return '';
default:
return value;
}
}
/**
* Function to get inputs from both with and env annotations.
*
@@ -11,13 +26,36 @@ export async function getInput(
name: string,
mandatory: boolean
): Promise<string> {
const input = process.env[name];
switch (input) {
case '':
case undefined:
return core.getInput(name, {required: mandatory});
default:
const input = core.getInput(name);
const env_input = await readEnv(name);
switch (true) {
case input != '':
return input;
case input == '' && env_input != '':
return env_input;
case input == '' && env_input == '' && mandatory:
throw new Error(`Input required and not supplied: ${name}`);
default:
return '';
}
}
/**
* Function to parse PHP version.
*
* @param version
*/
export async function parseVersion(version: string): Promise<string> {
switch (version) {
case 'latest':
return '7.4';
default:
switch (true) {
case version.length > 1:
return version.slice(0, 3);
default:
return version + '.0';
}
}
}