mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-09-28 09:43:56 +00:00
fix: Hugo package naming fix (#688)
## Summary Rebases the Hugo package naming fix from #609 on top of the current `main` branch, including the installer flow added in #687. - Derive Hugo release asset OS and architecture naming conventions from the requested Hugo version. - Apply those conventions when selecting OS and architecture segments, including the 0.102.x macOS universal boundary, 0.103+ downcased OS names, Windows zip assets, and Linux ARM assets. - Add table-driven tests for pre-0.102, 0.102.x, and 0.103+ naming behavior, plus URL coverage for the corrected release asset names. ## Changes - Add `getConventions` to centralize version-based release asset naming decisions. - Update `getOS` and `getArch` to use convention flags for macOS, lower-case OS names, standardized architecture names, and the Windows ARM support boundary. - Update `getURL` to generate candidate URLs for downcased Windows and Linux assets, and for darwin universal archives. - Wire convention detection into `installer` before generating candidate Hugo release asset URLs. - Expand unit coverage for OS, architecture, convention, and URL behavior. ## Checklist - [x] I have read the latest README and followed the instructions. - [x] I have added or updated tests for behavior changes. - [x] README.md and action.yml updates are not needed because inputs and action metadata are unchanged. - [x] I have run the relevant verification commands. ## References - Rebased follow-up for https://github.com/peaceiris/actions-hugo/pull/609 - References https://github.com/peaceiris/actions-hugo/issues/605 and https://github.com/peaceiris/actions-hugo/issues/608 - Based on `main` after https://github.com/peaceiris/actions-hugo/pull/687 ## Verification - [x] `RUNNER_TEMP=/private/tmp npm run all` - [ ] `npm run build` was not run because this branch does not update bundled output and current `main` removed `lib/index.js`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Version-aware conventions control OS and architecture naming, including macOS universal asset support and expanded darwin/macOS patterns. * **Refactor** * Conventions centralized and applied across installer and URL generation; OS/arch inputs accept varied casing and naming variants. * **Tests** * Expanded, data-driven parameterized tests for conventions, OS/arch mappings, URL variants, and error cases. * Replaced network stubs with deterministic fetch-mock helpers for test isolation. [](https://app.coderabbit.ai/change-stack/peaceiris/actions-hugo/pull/688) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Michael T Lombardi <michael.t.lombardi@gmail.com> Co-authored-by: codefactor-io <support@codefactor.io> Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
co-authored by
Michael T Lombardi
codefactor-io
Codex
parent
189731ef00
commit
b1937e141c
+130
-10
@@ -1,15 +1,135 @@
|
||||
import getArch from '../src/get-arch';
|
||||
|
||||
describe('getArch', () => {
|
||||
test('processor architecture', () => {
|
||||
expect(getArch('x64')).toBe('64bit');
|
||||
expect(getArch('arm')).toBe('ARM');
|
||||
expect(getArch('arm64')).toBe('ARM64');
|
||||
});
|
||||
const groups = [
|
||||
{
|
||||
condition: 'when hugo version < 0.102.0',
|
||||
conventions: {
|
||||
arch: {
|
||||
darwinUniversal: false,
|
||||
droppedWindowsArmSupport: false,
|
||||
standardizedNaming: false
|
||||
},
|
||||
os: {
|
||||
renamedMacOS: false,
|
||||
downcasedAll: false
|
||||
}
|
||||
},
|
||||
tests: [
|
||||
{arch: 'x64', os: 'linux', expected: '64bit'},
|
||||
{arch: 'x64', os: 'darwin', expected: '64bit'},
|
||||
{arch: 'x64', os: 'macOS', expected: '64bit'},
|
||||
{arch: 'x64', os: 'windows', expected: '64bit'},
|
||||
{arch: 'arm', os: 'linux', expected: 'ARM'},
|
||||
{arch: 'arm', os: 'darwin', expected: 'ARM'},
|
||||
{arch: 'arm', os: 'macOS', expected: 'ARM'},
|
||||
{arch: 'arm', os: 'windows', expected: 'ARM'},
|
||||
{arch: 'arm64', os: 'linux', expected: 'ARM64'},
|
||||
{arch: 'arm64', os: 'darwin', expected: 'ARM64'},
|
||||
{arch: 'arm64', os: 'macOS', expected: 'ARM64'},
|
||||
{arch: 'arm64', os: 'windows', expected: 'ARM64'}
|
||||
]
|
||||
},
|
||||
{
|
||||
condition: 'when hugo version === 0.102.z',
|
||||
conventions: {
|
||||
arch: {
|
||||
darwinUniversal: true,
|
||||
droppedWindowsArmSupport: true,
|
||||
standardizedNaming: false
|
||||
},
|
||||
os: {
|
||||
renamedMacOS: false,
|
||||
downcasedAll: false
|
||||
}
|
||||
},
|
||||
tests: [
|
||||
{arch: 'x64', os: 'linux', expected: '64bit'},
|
||||
{arch: 'x64', os: 'macOS', expected: 'universal'},
|
||||
{arch: 'x64', os: 'windows', expected: '64bit'},
|
||||
{arch: 'arm', os: 'linux', expected: 'ARM'},
|
||||
{arch: 'arm', os: 'macOS', expected: 'universal'},
|
||||
{arch: 'arm', os: 'windows', throws: true},
|
||||
{arch: 'arm64', os: 'linux', expected: 'ARM64'},
|
||||
{arch: 'arm64', os: 'macOS', expected: 'universal'},
|
||||
{arch: 'arm64', os: 'windows', expected: 'ARM64'}
|
||||
]
|
||||
},
|
||||
{
|
||||
condition: 'when hugo version >= 0.103.0',
|
||||
conventions: {
|
||||
arch: {
|
||||
darwinUniversal: true,
|
||||
droppedWindowsArmSupport: true,
|
||||
standardizedNaming: true
|
||||
},
|
||||
os: {
|
||||
renamedMacOS: true,
|
||||
downcasedAll: true
|
||||
}
|
||||
},
|
||||
tests: [
|
||||
{arch: 'x64', os: 'linux', expected: 'amd64'},
|
||||
{arch: 'x64', os: 'macOS', expected: 'universal'},
|
||||
{arch: 'x64', os: 'windows', expected: 'amd64'},
|
||||
{arch: 'arm', os: 'linux', expected: 'arm'},
|
||||
{arch: 'arm', os: 'macOS', expected: 'universal'},
|
||||
{arch: 'arm', os: 'windows', throws: true},
|
||||
{arch: 'arm64', os: 'linux', expected: 'arm64'},
|
||||
{arch: 'arm64', os: 'macOS', expected: 'universal'},
|
||||
{arch: 'arm64', os: 'windows', expected: 'arm64'}
|
||||
]
|
||||
},
|
||||
{
|
||||
condition: 'when the architecture is unsupported for the action',
|
||||
conventions: {
|
||||
arch: {
|
||||
darwinUniversal: false,
|
||||
droppedWindowsArmSupport: false,
|
||||
standardizedNaming: false
|
||||
},
|
||||
os: {
|
||||
renamedMacOS: false,
|
||||
downcasedAll: false
|
||||
}
|
||||
},
|
||||
tests: [{arch: 'mips', os: 'linux', throws: true}]
|
||||
}
|
||||
];
|
||||
|
||||
test('exception', () => {
|
||||
expect(() => {
|
||||
getArch('mips');
|
||||
}).toThrow('mips is not supported');
|
||||
});
|
||||
const passingTests = groups.flatMap(group =>
|
||||
group.tests
|
||||
.filter(example => !example.throws)
|
||||
.map(example => ({
|
||||
...example,
|
||||
condition: group.condition,
|
||||
conventions: group.conventions
|
||||
}))
|
||||
);
|
||||
|
||||
const throwingTests = groups.flatMap(group =>
|
||||
group.tests
|
||||
.filter(example => example.throws)
|
||||
.map(example => ({
|
||||
...example,
|
||||
condition: group.condition,
|
||||
conventions: group.conventions
|
||||
}))
|
||||
);
|
||||
|
||||
test.each(passingTests)(
|
||||
'$condition: $os on $arch returns $expected',
|
||||
({arch, os, conventions, expected}) => {
|
||||
expect(getArch(arch, os, conventions)).toBe(expected);
|
||||
}
|
||||
);
|
||||
|
||||
test.each(throwingTests)(
|
||||
'$condition: $os on $arch throws as not supported',
|
||||
({arch, os, conventions}) => {
|
||||
expect(() => {
|
||||
getArch(arch, os, conventions);
|
||||
}).toThrow(`${arch} is not supported`);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user