Skip to content

Commit

Permalink
Add PI_GEN_RELEASE parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
usimd committed Nov 11, 2023
1 parent 5ea0d57 commit afbea9f
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 104 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ tries to make sure the stage is respected and its changes are included in the fi
# exist, it will be created (including its parents).
pi-gen-dir: pi-gen

# The release name to use in `/etc/issue.txt`. The default should only be used for
# official Raspberry Pi builds.
pi-gen-release: Raspberry Pi reference

# GitHub repository to fetch pi-gen from, must be a fork from RPi-Distro/pi-gen.
pi-gen-repository: RPi-Distro/pi-gen

Expand Down
4 changes: 2 additions & 2 deletions __test__/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Run pi-gen build', () => {

await expect(
async () => await build('pi-gen', DEFAULT_CONFIG)
).rejects.toThrowError()
).rejects.toThrow()
})

it('throws error if pi-gen build yields failed result', async () => {
Expand Down Expand Up @@ -57,6 +57,6 @@ describe('Run pi-gen build', () => {
const conf = {...DEFAULT_CONFIG}
conf.enableNoobs = 'true'
await build('pi-gen', conf)
expect(core.setOutput).toBeCalledTimes(2)
expect(core.setOutput).toHaveBeenCalledTimes(2)
})
})
13 changes: 8 additions & 5 deletions __test__/clone-pigen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,22 @@ describe('Cloning pi-gen repo', () => {
const clone = clonePigen(repo, targetDir, ref)

if (!succeed) {
await expect(clone).rejects.toThrowError()
await expect(clone).rejects.toThrow()
} else {
await expect(clone).resolves.not.toThrowError()
await expect(clone).resolves.not.toThrow()
}

expect(githubMock.rest.repos.get).toBeCalledWith({
expect(githubMock.rest.repos.get).toHaveBeenCalledWith({
owner: repo.split('/')[0],
repo: repo.split('/')[1]
})

if (succeed) {
expect(Git.getInstance).toBeCalledWith(targetDir, token, verbose)
expect(gitMock.clone).toBeCalledWith(`https://github.com/${repo}`, ref)
expect(Git.getInstance).toHaveBeenCalledWith(targetDir, token, verbose)
expect(gitMock.clone).toHaveBeenCalledWith(
`https://github.com/${repo}`,
ref
)
}
})
})
4 changes: 2 additions & 2 deletions __test__/configure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Configure', () => {
})

it('throws error if no image name present', async () => {
await expect(async () => await configure()).rejects.toThrowError()
await expect(async () => await configure()).rejects.toThrow()
})

it('creates a stage array from user config', async () => {
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('Configure', () => {

await configure()

expect(core.info).toBeCalledWith(
expect(core.info).toHaveBeenCalledWith(
expect.not.stringContaining('secretpassword')
)
})
Expand Down
6 changes: 3 additions & 3 deletions __test__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Git', () => {

await Git.getInstance('.', token)

expect(exec.getExecOutput).toBeCalledWith(
expect(exec.getExecOutput).toHaveBeenCalledWith(
expect.stringMatching(/git$/),
[
'config',
Expand All @@ -56,7 +56,7 @@ describe('Git', () => {
],
expect.anything()
)
expect(fs.promises.writeFile).toBeCalledWith(
expect(fs.promises.writeFile).toHaveBeenCalledWith(
expect.stringMatching(new RegExp('.git/config$')),
'AUTHORIZATION: basic eC1hY2Nlc3MtdG9rZW46MTIzNDU2Nzg5MA=='
)
Expand Down Expand Up @@ -116,6 +116,6 @@ describe('Git', () => {
const git = await Git.getInstance('.', '')
await expect(
async () => await git.clone('any-repo', 'non-existing-ref')
).rejects.toThrowError()
).rejects.toThrow()
})
})
2 changes: 1 addition & 1 deletion __test__/install-dependencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Install host dependencies', () => {

await installHostDependencies('test-package', 'test-module')

expect(exec.getExecOutput).toBeCalledWith(
expect(exec.getExecOutput).toHaveBeenCalledWith(
expect.stringMatching(/.*sudo$/),
expect.arrayContaining(['test-package']),
expect.anything()
Expand Down
2 changes: 1 addition & 1 deletion __test__/pi-gen-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('PiGenConfig', () => {
piGenConfig[property as keyof PiGenConfig] = value
await expect(
async () => await validateConfig(piGenConfig)
).rejects.toThrowError()
).rejects.toThrow()
}
)
})
10 changes: 5 additions & 5 deletions __test__/pi-gen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('PiGen', () => {
async piGenPath => {
await expect(
async () => await PiGen.getInstance(piGenPath, DEFAULT_CONFIG)
).rejects.toThrowError()
).rejects.toThrow()
}
)

Expand All @@ -66,7 +66,7 @@ describe('PiGen', () => {

await expect(
async () => await PiGen.getInstance('pi-gen-dir', DEFAULT_CONFIG)
).rejects.toThrowError()
).rejects.toThrow()
})

it('mounts all stage paths as Docker volumes', async () => {
Expand All @@ -83,7 +83,7 @@ describe('PiGen', () => {
} as PiGenConfig)
await piGen.build()

expect(exec.getExecOutput).toBeCalledWith(
expect(exec.getExecOutput).toHaveBeenCalledWith(
'"./build-docker.sh"',
['-c', `/${piGenDir}/config`],
expect.objectContaining({
Expand All @@ -107,7 +107,7 @@ describe('PiGen', () => {
} as PiGenConfig)
await piGen.build()

expect(exec.getExecOutput).toBeCalledWith(
expect(exec.getExecOutput).toHaveBeenCalledWith(
'"./build-docker.sh"',
['-c', `/${piGenDir}/config`],
expect.objectContaining({
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('PiGen', () => {
await expect(
async () =>
await PiGen.getInstance('', {stageList: [] as string[]} as PiGenConfig)
).rejects.toThrowError()
).rejects.toThrow()
})

it('configures NOOBS export for stages that export images', async () => {
Expand Down
8 changes: 5 additions & 3 deletions __test__/remove-container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Remove container', () => {

await removeContainer(testContainer)

expect(exec.getExecOutput).toBeCalledWith(
expect(exec.getExecOutput).toHaveBeenCalledWith(
expect.stringMatching(/.*docker$/),
['rm', '-v', testContainer],
expect.objectContaining({
Expand All @@ -32,11 +32,13 @@ describe('Remove container', () => {

await removeContainer(testContainer)

expect(exec.getExecOutput).toBeCalledWith(
expect(exec.getExecOutput).toHaveBeenCalledWith(
expect.anything(),
expect.anything(),
expect.objectContaining({silent: false})
)
expect(core.info).toBeCalledWith(expect.stringContaining(testContainer))
expect(core.info).toHaveBeenCalledWith(
expect.stringContaining(testContainer)
)
})
})
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
image-name:
description: Final image name.
required: true
pi-gen-release:
description: The release name to use in `/etc/issue.txt`. The default should only be used for official Raspberry Pi builds.
required: false
default: Raspberry Pi reference
use-qcow2:
description: |
Use qcow2 images to reduce space and runtime requirements.
Expand Down
6 changes: 4 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

127 changes: 47 additions & 80 deletions dist/licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@ The above copyright notice and this permission notice shall be included in all c

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@fastify/busboy
MIT
Copyright Brian White. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

@octokit/auth-token
MIT
The MIT License
Expand Down Expand Up @@ -255,16 +277,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


@vercel/ncc
MIT
Copyright 2018 ZEIT, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ansi-colors
MIT
The MIT License (MIT)
Expand Down Expand Up @@ -781,32 +793,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


node-fetch
MIT
The MIT License (MIT)

Copyright (c) 2016 David Frank

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



once
ISC
The ISC License
Expand Down Expand Up @@ -839,9 +825,6 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


tr46
MIT

tunnel
MIT
The MIT License (MIT)
Expand All @@ -867,6 +850,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


undici
MIT
MIT License

Copyright (c) Matteo Collina and Undici contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


universal-user-agent
ISC
# [ISC License](https://spdx.org/licenses/ISC)
Expand All @@ -891,47 +899,6 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


webidl-conversions
BSD-2-Clause
# The BSD 2-Clause License

Copyright (c) 2014, Domenic Denicola
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


whatwg-url
MIT
The MIT License (MIT)

Copyright (c) 2015–2016 Sebastian Mayr

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


wrappy
ISC
The ISC License
Expand Down
2 changes: 2 additions & 0 deletions src/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export async function configure(): Promise<PiGenConfig> {
DEFAULT_CONFIG.exportLastStageOnly
userConfig.dockerOpts = core.getInput('docker-opts')
userConfig.setfcap = core.getInput('setfcap') ?? DEFAULT_CONFIG.setfcap
userConfig.piGenRelease =
core.getInput('pi-gen-release') ?? DEFAULT_CONFIG.piGenRelease

await validateConfig(userConfig)

Expand Down
2 changes: 2 additions & 0 deletions src/pi-gen-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as io from '@actions/io'

export interface PiGenConfig {
imgName: string
piGenRelease: string
release: string
deployCompression: string
compressionLevel: string
Expand Down Expand Up @@ -33,6 +34,7 @@ export interface PiGenConfig {

export const DEFAULT_CONFIG: PiGenConfig = {
imgName: 'test',
piGenRelease: 'Raspberry Pi reference',
release: 'bullseye',
deployCompression: 'zip',
compressionLevel: '6',
Expand Down

0 comments on commit afbea9f

Please sign in to comment.