Skip to content

Commit

Permalink
Merge pull request #14 from diddlesnaps/fix-action-yml-booleans
Browse files Browse the repository at this point in the history
Fix action yml booleans
  • Loading branch information
Dani Llewellyn authored Nov 21, 2022
2 parents f2a67ea + 7caee6a commit a549534
Show file tree
Hide file tree
Showing 5 changed files with 3,908 additions and 6,071 deletions.
18 changes: 5 additions & 13 deletions __tests__/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ for (const [base, arch, channel] of [
'/data',
...platform,
'--env',
'SNAPCRAFT_BUILD_ENVIRONMENT=host',
'--env',
`SNAPCRAFT_IMAGE_INFO={"build_url":"https://github.com/user/repo/actions/runs/42"}`,
'--env',
'SNAPCRAFT_BUILD_INFO=1',
Expand Down Expand Up @@ -143,8 +141,6 @@ test('SnapcraftBuilder.build can disable build info', async () => {
'--workdir',
'/data',
'--env',
'SNAPCRAFT_BUILD_ENVIRONMENT=host',
'--env',
`SNAPCRAFT_IMAGE_INFO={"build_url":"https://github.com/user/repo/actions/runs/42"}`,
'--env',
'USE_SNAPCRAFT_CHANNEL=stable',
Expand Down Expand Up @@ -196,8 +192,6 @@ test('SnapcraftBuilder.build can pass additional arguments', async () => {
'--workdir',
'/data',
'--env',
'SNAPCRAFT_BUILD_ENVIRONMENT=host',
'--env',
`SNAPCRAFT_IMAGE_INFO={"build_url":"https://github.com/user/repo/actions/runs/42"}`,
'--env',
'USE_SNAPCRAFT_CHANNEL=stable',
Expand Down Expand Up @@ -253,13 +247,11 @@ test('SnapcraftBuilder.outputSnap returns the first snap', async () => {
.mockImplementation(
async (path: string): Promise<string[]> => ['one.snap', 'two.snap']
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const execMock = jest.spyOn(exec, 'exec').mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const warning = jest
.spyOn(core, 'warning')
.mockImplementation((_message: string | Error): void => {})
Expand Down
63 changes: 25 additions & 38 deletions __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ test('ensureDockerExperimental is no-op if experimental already set', async () =
async (filename: fs.PathLike | fs.promises.FileHandle): Promise<Buffer> =>
Buffer.from(`{"experimental": true}`)
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const execMock = jest.spyOn(exec, 'exec').mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)

await tools.ensureDockerExperimental()

Expand All @@ -43,23 +41,16 @@ test('ensureDockerExperimental is no-op if experimental already set', async () =
test("ensureDockerExperimental sets experimental mode and restarts docker if configuration file doesn't exist", async () => {
expect.assertions(3)

const accessMock = jest
.spyOn(fs.promises, 'access')
.mockImplementation(
async (
filename: fs.PathLike,
mode?: number | undefined
): Promise<void> => {
throw new Error('not found')
}
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const accessMock = jest.spyOn(fs.promises, 'access').mockImplementation(
async (filename: fs.PathLike, mode?: number | undefined): Promise<void> => {
throw new Error('not found')
}
)
const execMock = jest.spyOn(exec, 'exec').mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)

await tools.ensureDockerExperimental()

Expand Down Expand Up @@ -92,13 +83,11 @@ test('ensureDockerExperimental sets experimental mode and restarts docker if not
async (filename: fs.PathLike | fs.promises.FileHandle): Promise<Buffer> =>
Buffer.from(`{}`)
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const execMock = jest.spyOn(exec, 'exec').mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)

await tools.ensureDockerExperimental()

Expand Down Expand Up @@ -132,13 +121,11 @@ test('ensureDockerExperimental sets experimental mode and restarts docker if exp
async (filename: fs.PathLike | fs.promises.FileHandle): Promise<Buffer> =>
Buffer.from(`{"experimental": false}`)
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const execMock = jest.spyOn(exec, 'exec').mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)

await tools.ensureDockerExperimental()

Expand Down
10 changes: 5 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
path:
description: 'The location of the Snapcraft project. Defaults to the base of the repository'
default: '.'
required: yes
required: true
build-info:
description: >
Whether to include build information in the resulting snap.
Expand All @@ -21,7 +21,7 @@ inputs:
Proprietary applications may want to disable this due to
the information leakage.
default: 'true'
required: no
required: false
snapcraft-channel:
description: >
The Snapcraft channel to use
Expand All @@ -30,15 +30,15 @@ inputs:
to build the project. This parameter can be used to instead
select a different channel such as beta, candidate, or edge.
default: 'stable'
required: no
required: false
snapcraft-args:
description: >
Additional arguments to pass to Snapcraft
Some experimental Snapcraft features are disabled by default and
must be turned on via a `--enable-experimental-*` command line
argument. This parameter can be used to turn on such features.
required: no
required: false
architecture:
description: >
The architecture to build with Snapcraft
Expand All @@ -50,7 +50,7 @@ inputs:
You may only specify one architecture at a time so it's best to
combine this with the build matrix feature of GitHub Actions.
default: 'amd64'
required: yes
required: true
outputs:
snap:
description: 'The file name of the resulting snap.'
Expand Down
Loading

0 comments on commit a549534

Please sign in to comment.