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 actions/release-tag-creation/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ runs:
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
INPUT_PLUGIN: ${{ inputs.plugin }}
ACTION_PATH: ${{ github.action_path }}
run: node "$ACTION_PATH/main.ts"

Expand Down
36 changes: 36 additions & 0 deletions actions/release-tag-creation/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { describe, expect, it } from 'vitest';

import { resolvePluginConfig } from './plugin-config.ts';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: this file never imports main.ts; it only re-tests resolvePluginConfig, which plugin-config.test.ts already covers (koko is now in both). getPlugin()'s default/trim and the 'plugin is validated before git ls-remote' order in run() are untested. Because main.ts ends with a bare run();, consider the same split as #60 (run-main.ts entrypoint), then test run() with INPUT_PLUGIN=koko and assert process.exit(1) and that spawnSync was never called.


describe('plugin validation in main.ts context', () => {
it('resolvePluginConfig is imported and used for early validation', () => {
expect(resolvePluginConfig('core')).toEqual({
pluginFile: 'elementor.php',
versionConstant: 'ELEMENTOR_VERSION',
updateReadme: true,
updateElementorTestedUpTo: false,
});

expect(resolvePluginConfig('pro')).toEqual({
pluginFile: 'elementor-pro.php',
versionConstant: 'ELEMENTOR_PRO_VERSION',
updateReadme: false,
updateElementorTestedUpTo: true,
});
});

it('resolvePluginConfig throws on invalid plugin value "koko"', () => {
expect(() => resolvePluginConfig('koko')).toThrow(
'plugin must be "core" or "pro", got "koko"',
);
});

it.each(['', 'Core', 'PRO', 'elementor', 'invalid'])(
'resolvePluginConfig throws on invalid plugin value "%s"',
(invalidPlugin) => {
expect(() => resolvePluginConfig(invalidPlugin)).toThrow(
'plugin must be "core" or "pro"',
);
},
);
});
9 changes: 9 additions & 0 deletions actions/release-tag-creation/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
checkVersionIsNext,
fetchCompanionTag,
} from './current-version-validation.ts';
import { resolvePluginConfig } from './plugin-config.ts';

// ─── I/O helpers ──────────────────────────────────────────────────────────────

Expand All @@ -21,6 +22,10 @@ export function getVersion(): string {
return version;
}

export function getPlugin(): string {
return (process.env['INPUT_PLUGIN'] ?? 'core').trim();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: getPlugin() trims, but update-version-files.ts reads INPUT_PLUGIN via getEnv() without trimming. A value like " pro " passes this early check and then fails in 'Update version files' (after the release-branch checkout), which is the late failure this PR is meant to prevent. Either drop .trim() here so both steps reject it at step 2, or trim in update-version-files.ts as well.

}

export function setOutput(name: string, value: string): void {
const outputFile = process.env['GITHUB_OUTPUT'];

Expand Down Expand Up @@ -101,6 +106,10 @@ export function deriveBranch(channel: 'stable' | 'beta'): string {
export function run(): void {
try {
const version = getVersion();
const plugin = getPlugin();

resolvePluginConfig(plugin);
console.log(`✅ Plugin input is valid: ${plugin}`);

validateFormat(version);
checkCurrentTagDoesNotExist(version);
Expand Down
2 changes: 1 addition & 1 deletion actions/release-tag-creation/plugin-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('resolvePluginConfig', () => {
});
});

it.each(['', 'Core', 'elementor'])('throws on "%s"', (plugin) => {
it.each(['', 'Core', 'elementor', 'koko'])('throws on "%s"', (plugin) => {
expect(() => resolvePluginConfig(plugin)).toThrow(
'plugin must be "core" or "pro"',
);
Expand Down
Loading