Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ with:
| `release-tag` | The tag to use when building the extension; there must be an existing draft release for the tag | `true` | - |
| `github-token` | The GitHub token to use. Usually `${{ secrets.GITHUB_TOKEN }}` would be fine for most cases. | `true` | - |
| `configure-flags` | If you need to pass additional flags to the `./configure` command, specify them here | `false` | `''` |
| `build-path` | Path to the extension source directory containing `config.m4`, relative to repo root | `false` | `'.'` |

### Outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ inputs:
description: 'Flags to pass to ./configure'
required: false
default: ''
build-path:
description: 'Path to the extension source directory containing config.m4 (relative to repo root)'
required: false
default: '.'
release-tag:
description: 'The tag to use for the release'
required: true
Expand Down
14 changes: 9 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30261,10 +30261,12 @@ async function determineExtensionNameFromComposerJson() {
async function buildExtension() {
core.info("Building the extension...");
const configureFlags = core.getInput("configure-flags").split(' ');
const buildPath = core.getInput("build-path") || ".";
const opts = buildPath !== "." ? { cwd: buildPath } : {};

await exec.exec("phpize");
await exec.exec("./configure", configureFlags);
await exec.exec("make");
await exec.exec("phpize", [], opts);
await exec.exec("./configure", configureFlags, opts);
await exec.exec("make", [], opts);
}

async function determinePhpVersionFromPhpConfig() {
Expand Down Expand Up @@ -30406,9 +30408,11 @@ async function main() {

await module.exports.buildExtension();

await exec.exec("ls", ["-l", "modules"]);
const buildPath = core.getInput("build-path") || ".";
const modulesDir = path.join(buildPath, "modules");
await exec.exec("ls", ["-l", modulesDir]);

await exec.exec(`zip -j ${extPackageName} modules/${extSoFile}`);
await exec.exec("zip", ["-j", extPackageName, path.join(modulesDir, extSoFile)]);

await module.exports.uploadReleaseAsset(releaseTag, extPackageName);

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

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ async function determineExtensionNameFromComposerJson() {
async function buildExtension() {
core.info("Building the extension...");
const configureFlags = core.getInput("configure-flags").split(' ');
const buildPath = core.getInput("build-path") || ".";
const opts = buildPath !== "." ? { cwd: buildPath } : {};

await exec.exec("phpize");
await exec.exec("./configure", configureFlags);
await exec.exec("make");
await exec.exec("phpize", [], opts);
await exec.exec("./configure", configureFlags, opts);
await exec.exec("make", [], opts);
}

async function determinePhpVersionFromPhpConfig() {
Expand Down Expand Up @@ -198,9 +200,11 @@ async function main() {

await module.exports.buildExtension();

await exec.exec("ls", ["-l", "modules"]);
const buildPath = core.getInput("build-path") || ".";
const modulesDir = path.join(buildPath, "modules");
await exec.exec("ls", ["-l", modulesDir]);

await exec.exec(`zip -j ${extPackageName} modules/${extSoFile}`);
await exec.exec("zip", ["-j", extPackageName, path.join(modulesDir, extSoFile)]);

await module.exports.uploadReleaseAsset(releaseTag, extPackageName);

Expand Down
60 changes: 53 additions & 7 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,32 @@ describe('determineZendThreadSafeMode', () => {
});

describe('buildExtension', () => {
test('builds the extension with configure params', async () => {
core.getInput.mockReturnValue('--enable-test --with-foo=/foo/bar');
test('builds the extension with configure params and default build path', async () => {
core.getInput.mockImplementation((name) => {
if (name === 'configure-flags') return '--enable-test --with-foo=/foo/bar';
if (name === 'build-path') return '.';
return '';
});

await action.buildExtension();

expect(exec.exec).toHaveBeenCalledWith('phpize', [], {});
expect(exec.exec).toHaveBeenCalledWith('./configure', ['--enable-test', '--with-foo=/foo/bar'], {});
expect(exec.exec).toHaveBeenCalledWith('make', [], {});
});

test('builds the extension with custom build path', async () => {
core.getInput.mockImplementation((name) => {
if (name === 'configure-flags') return '--enable-test';
if (name === 'build-path') return 'some/ext/path';
return '';
});

await action.buildExtension();

expect(exec.exec).toHaveBeenCalledWith('phpize');
expect(exec.exec).toHaveBeenCalledWith('./configure', ['--enable-test', '--with-foo=/foo/bar']);
expect(exec.exec).toHaveBeenCalledWith('make');
expect(exec.exec).toHaveBeenCalledWith('phpize', [], { cwd: 'some/ext/path' });
expect(exec.exec).toHaveBeenCalledWith('./configure', ['--enable-test'], { cwd: 'some/ext/path' });
expect(exec.exec).toHaveBeenCalledWith('make', [], { cwd: 'some/ext/path' });
});
});

Expand Down Expand Up @@ -463,7 +481,7 @@ describe('extensionDetails', () => {
});

describe('main', () => {
test('main builds and uploads extension', async () => {
test('main builds and uploads extension with default build path', async () => {
jest.spyOn(action, 'extensionDetails').mockResolvedValue({
releaseTag: '1.2.3',
extSoFile: 'foo.so',
Expand All @@ -472,12 +490,40 @@ describe('main', () => {
jest.spyOn(action, 'buildExtension').mockResolvedValue();
jest.spyOn(action, 'uploadReleaseAsset').mockResolvedValue();
jest.spyOn(exec, 'exec').mockResolvedValue();
core.getInput.mockImplementation((name) => {
if (name === 'build-path') return '.';
return '';
});

await action.main();

expect(action.buildExtension).toHaveBeenCalled();
expect(action.uploadReleaseAsset).toHaveBeenCalledWith('1.2.3', 'php_foo-1.2.3_php8.1-x86_64-linux-glibc-debug-zts.zip');
expect(exec.exec).toHaveBeenCalledWith('ls', ['-l', 'modules']);
expect(exec.exec).toHaveBeenCalledWith('zip', ['-j', 'php_foo-1.2.3_php8.1-x86_64-linux-glibc-debug-zts.zip', 'modules/foo.so']);
expect(core.setOutput).toHaveBeenCalledWith('package-path', 'php_foo-1.2.3_php8.1-x86_64-linux-glibc-debug-zts.zip');
});

test('main builds and uploads extension with custom build path', async () => {
jest.spyOn(action, 'extensionDetails').mockResolvedValue({
releaseTag: '1.2.3',
extSoFile: 'foo.so',
extPackageName: 'php_foo-1.2.3_php8.1-x86_64-linux-glibc-debug-zts.zip',
});
jest.spyOn(action, 'buildExtension').mockResolvedValue();
jest.spyOn(action, 'uploadReleaseAsset').mockResolvedValue();
jest.spyOn(exec, 'exec').mockResolvedValue();
core.getInput.mockImplementation((name) => {
if (name === 'build-path') return 'src/php/ext/grpc';
return '';
});

await action.main();

expect(action.buildExtension).toHaveBeenCalled();
expect(action.uploadReleaseAsset).toHaveBeenCalledWith('1.2.3', 'php_foo-1.2.3_php8.1-x86_64-linux-glibc-debug-zts.zip');
expect(exec.exec).toHaveBeenCalledWith('zip -j php_foo-1.2.3_php8.1-x86_64-linux-glibc-debug-zts.zip modules/foo.so');
expect(exec.exec).toHaveBeenCalledWith('ls', ['-l', 'src/php/ext/grpc/modules']);
expect(exec.exec).toHaveBeenCalledWith('zip', ['-j', 'php_foo-1.2.3_php8.1-x86_64-linux-glibc-debug-zts.zip', 'src/php/ext/grpc/modules/foo.so']);
expect(core.setOutput).toHaveBeenCalledWith('package-path', 'php_foo-1.2.3_php8.1-x86_64-linux-glibc-debug-zts.zip');
});
});