Skip to content

Commit

Permalink
Perform partial build if BUILD_REFNAME is HEAD
Browse files Browse the repository at this point in the history
Closes gh-31
  • Loading branch information
rwinch committed Jul 9, 2024
1 parent b2b9f74 commit 4427a4b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/partial-build-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports.register = function ({ config = {} }) {
}
if (isBranch && version.endsWith('-SNAPSHOT')) version = version.slice(0, -9)
const versionsInManifest = Object.values(siteManifestData.components)[0].versions
if (!(version in versionsInManifest && isBranch === !!versionsInManifest[version].prerelease)) {
if (!isAuthorMode && !(version in versionsInManifest && isBranch === !!versionsInManifest[version].prerelease)) {
const category = require('path').basename(module.id, '.js')
await fsp.writeFile(ospath.join(playbook.dir, '.full-build'), '')
console.log(`${category}: version ${version} not previously built; reverting to full build`)
Expand Down
22 changes: 22 additions & 0 deletions test/partial-build-extension-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,28 @@ describe('partial-build-extension', () => {
})
})

it('should rewrite content sources when SNAPSHOT version not found if refname is HEAD', async () => {
const playBookDir = WORK_DIR
await fsp.mkdir(ospath.join(WORK_DIR, '.git'), { recursive: true })
await runScenario({
refname: 'HEAD',
version: '7.0.0-SNAPSHOT',
expectedRefs: { branches: ['HEAD'], tags: [], url: '.' },
playbookDir: playBookDir,
})
})

it('should rewrite content sources when release version not found if refname is HEAD', async () => {
const playBookDir = WORK_DIR
await fsp.mkdir(ospath.join(WORK_DIR, '.git'), { recursive: true })
await runScenario({
refname: 'HEAD',
version: '7.0.0',
expectedRefs: { branches: ['HEAD'], tags: [], url: '.' },
playbookDir: playBookDir,
})
})

it('should error if refname is HEAD and version undefined', async () => {
expect(await trapAsyncError(() => runScenario({ refname: 'HEAD' }))).to.throw(
'When using author mode version is required. Specify config.version or env BUILD_VERSION'
Expand Down

0 comments on commit 4427a4b

Please sign in to comment.