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', () => { 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 () => { it('checking getInput', async () => {
process.env['test'] = 'cache-extensions'; process.env['test'] = 'setup-php';
process.env['undefined'] = ''; expect(await utils.getInput('test', false)).toBe('setup-php');
expect(await utils.getInput('test', false)).toBe('cache-extensions');
expect(await utils.getInput('undefined', false)).toBe('');
expect(await utils.getInput('cache-extensions', false)).toBe( expect(await utils.getInput('cache-extensions', false)).toBe(
'cache-extensions' 'cache-extensions'
); );
expect(await utils.getInput('DoesNotExist', false)).toBe(''); 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 () => { it('checking filterExtensions', async () => {

55
dist/index.js vendored
View File

@@ -1054,8 +1054,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); 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)); 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. * Function to get inputs from both with and env annotations.
* *
@@ -1063,16 +1078,39 @@ const core = __importStar(__webpack_require__(470));
* @param mandatory * @param mandatory
*/ */
async function getInput(name, mandatory) { async function getInput(name, mandatory) {
const input = process.env[name]; const input = core.getInput(name);
switch (input) { const env_input = await readEnv(name);
case '': switch (true) {
case undefined: case input != '':
return core.getInput(name, { required: mandatory });
default:
return 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; 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 * Function to filter extensions
* *
@@ -1687,8 +1725,7 @@ const utils = __importStar(__webpack_require__(163));
*/ */
async function run() { async function run() {
try { try {
let version = await utils.getInput('php-version', true); const version = await utils.parseVersion(await utils.getInput('php-version', true));
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
const extensions = await utils.filterExtensions(await utils.getInput('extensions', true)); const extensions = await utils.filterExtensions(await utils.getInput('extensions', true));
const key = await utils.getInput('key', true); const key = await utils.getInput('key', true);
const script_path = path.join(__dirname, '../src/extensions.sh'); 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", "name": "cache-extensions",
"version": "1.2.0", "version": "1.3.0",
"private": false, "private": false,
"description": "Cache extensions in GitHub Actions", "description": "Cache extensions in GitHub Actions",
"main": "dist/index.js", "main": "dist/index.js",
@@ -29,18 +29,18 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.14", "@types/jest": "^26.0.14",
"@types/node": "^14.11.2", "@types/node": "^14.11.8",
"@typescript-eslint/eslint-plugin": "^4.3.0", "@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.3.0", "@typescript-eslint/parser": "^4.4.1",
"@zeit/ncc": "^0.22.3", "@zeit/ncc": "^0.22.3",
"eslint": "^7.10.0", "eslint": "^7.11.0",
"eslint-config-prettier": "^6.12.0", "eslint-config-prettier": "^6.12.0",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.0.2", "eslint-plugin-jest": "^24.1.0",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0", "husky": "^4.3.0",
"jest": "^26.4.2", "jest": "^26.5.3",
"jest-circus": "^26.4.2", "jest-circus": "^26.5.3",
"prettier": "^2.1.2", "prettier": "^2.1.2",
"ts-jest": "^26.4.1", "ts-jest": "^26.4.1",
"typescript": "^4.0.3" "typescript": "^4.0.3"

View File

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

View File

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

View File

@@ -6,8 +6,8 @@ Core
ctype ctype
curl curl
date date
dba
dom dom
enchant
exif exif
FFI FFI
fileinfo fileinfo
@@ -21,10 +21,12 @@ iconv
ioncube ioncube
intl intl
json json
ldap
libxml libxml
mbstring mbstring
mysqli mysqli
mysqlnd mysqlnd
odbc
openssl openssl
pcntl pcntl
pcov pcov
@@ -32,11 +34,14 @@ pcre
PDO PDO
oci8 oci8
PDO_OCI PDO_OCI
pdo_dblib
pdo_mysql pdo_mysql
PDO_ODBC
pdo_pgsql pdo_pgsql
pdo_sqlite pdo_sqlite
pgsql pgsql
Phar Phar
phpdbg_webhelper
posix posix
pspell pspell
readline readline
@@ -46,6 +51,7 @@ shmop
SimpleXML SimpleXML
soap soap
sockets sockets
sodium
SPL SPL
sqlite3 sqlite3
standard standard
@@ -54,9 +60,9 @@ sysvsem
sysvshm sysvshm
tidy tidy
tokenizer tokenizer
xdebug
xml xml
xmlreader xmlreader
xmlrpc
xmlwriter xmlwriter
xsl xsl
Zend OPcache Zend OPcache
@@ -69,4 +75,3 @@ blackfire
[Zend Modules] [Zend Modules]
Zend OPcache Zend OPcache
Xdebug 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 calendar
Core Core
ctype ctype
cubrid
curl curl
date date
dba
dom dom
enchant
exif exif
FFI FFI
fileinfo fileinfo
@@ -22,10 +21,12 @@ iconv
ioncube ioncube
intl intl
json json
ldap
libxml libxml
mbstring mbstring
mysqli mysqli
mysqlnd mysqlnd
odbc
openssl openssl
pcntl pcntl
pcov pcov
@@ -33,11 +34,14 @@ pcre
PDO PDO
oci8 oci8
PDO_OCI PDO_OCI
pdo_dblib
pdo_mysql pdo_mysql
PDO_ODBC
pdo_pgsql pdo_pgsql
pdo_sqlite pdo_sqlite
pgsql pgsql
Phar Phar
phpdbg_webhelper
posix posix
pspell pspell
readline readline
@@ -47,6 +51,7 @@ shmop
SimpleXML SimpleXML
soap soap
sockets sockets
sodium
SPL SPL
sqlite3 sqlite3
standard standard
@@ -55,9 +60,9 @@ sysvsem
sysvshm sysvshm
tidy tidy
tokenizer tokenizer
xdebug
xml xml
xmlreader xmlreader
xmlrpc
xmlwriter xmlwriter
xsl xsl
Zend OPcache 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 calendar
Core Core
ctype ctype
cubrid
curl curl
date date
dba
dom dom
enchant
exif exif
FFI FFI
fileinfo fileinfo
@@ -22,10 +21,12 @@ iconv
ioncube ioncube
intl intl
json json
ldap
libxml libxml
mbstring mbstring
mysqli mysqli
mysqlnd mysqlnd
odbc
openssl openssl
pcntl pcntl
pcov pcov
@@ -33,11 +34,14 @@ pcre
PDO PDO
oci8 oci8
PDO_OCI PDO_OCI
pdo_dblib
pdo_mysql pdo_mysql
PDO_ODBC
pdo_pgsql pdo_pgsql
pdo_sqlite pdo_sqlite
pgsql pgsql
Phar Phar
phpdbg_webhelper
posix posix
pspell pspell
readline readline
@@ -47,6 +51,7 @@ shmop
SimpleXML SimpleXML
soap soap
sockets sockets
sodium
SPL SPL
sqlite3 sqlite3
standard standard
@@ -55,9 +60,9 @@ sysvsem
sysvshm sysvshm
tidy tidy
tokenizer tokenizer
xdebug
xml xml
xmlreader xmlreader
xmlrpc
xmlwriter xmlwriter
xsl xsl
Zend OPcache Zend OPcache
@@ -70,4 +75,3 @@ blackfire
[Zend Modules] [Zend Modules]
Zend OPcache Zend OPcache
Xdebug 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 fs from 'fs';
import * as core from '@actions/core'; 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. * Function to get inputs from both with and env annotations.
* *
@@ -11,13 +26,36 @@ export async function getInput(
name: string, name: string,
mandatory: boolean mandatory: boolean
): Promise<string> { ): Promise<string> {
const input = process.env[name]; const input = core.getInput(name);
switch (input) { const env_input = await readEnv(name);
case '': switch (true) {
case undefined: case input != '':
return core.getInput(name, {required: mandatory});
default:
return 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';
}
} }
} }