Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support multiple built-charm-path #156

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
2 changes: 1 addition & 1 deletion dist/upload-charm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42541,7 +42541,7 @@ class UploadCharmAction {
yield this.snap.install('charmcraft', this.charmcraftChannel);
process.chdir(this.charmPath);
const charms = this.builtCharmPath
? [this.builtCharmPath]
? this.builtCharmPath.split(',').map((path) => path.trim())
: yield this.charmcraft.pack(this.destructive);
const overrides = this.overrides;
const imageResults = yield this.charmcraft.uploadResources(overrides);
Expand Down
24 changes: 19 additions & 5 deletions src/actions/upload-charm/upload-charm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ describe('the upload charm action', () => {
builtCharmPath: '',
}, // charmcraft pack produces two files
{ charmcraftPackOutput: [], builtCharmPath: '/path/to/prebuilt.charm' }, // built-charm-path input option is provided
{
charmcraftPackOutput: [],
builtCharmPath: '/path/to/prebuilt1.charm,/path/to/prebuilt2.charm',
}, // Multiple comma paths
{
charmcraftPackOutput: [],
builtCharmPath: '/path/to/prebuilt1.charm, /path/to/prebuilt2.charm',
}, // Multiple comma paths with spaces
].forEach(({ charmcraftPackOutput, builtCharmPath }) => {
it('should call charmcraft upload correct number of times with correct parameters', async () => {
jest.spyOn(core, 'getInput').mockImplementation((inputOption) => {
Expand Down Expand Up @@ -45,12 +53,18 @@ describe('the upload charm action', () => {
await action.run();

if (builtCharmPath) {
expect(action.charmcraft.upload).toHaveBeenCalledTimes(1);
expect(action.charmcraft.upload).toHaveBeenCalledWith(
builtCharmPath,
'something',
['f1', 'f2', 'f1', 'f2', 'f1', 'f2'],
const expectedPaths = builtCharmPath.split(',').map((p) => p.trim());
expect(action.charmcraft.upload).toHaveBeenCalledTimes(
expectedPaths.length,
);
expectedPaths.forEach((expectedPath, index) => {
expect(action.charmcraft.upload).toHaveBeenNthCalledWith(
index + 1,
expectedPath,
'something',
['f1', 'f2', 'f1', 'f2', 'f1', 'f2'],
);
});
} else {
expect(action.charmcraft.upload).toHaveBeenCalledTimes(
charmcraftPackOutput.length,
Expand Down
2 changes: 1 addition & 1 deletion src/actions/upload-charm/upload-charm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class UploadCharmAction {
process.chdir(this.charmPath!);

const charms = this.builtCharmPath
? [this.builtCharmPath]
? this.builtCharmPath.split(',').map((path) => path.trim())
: await this.charmcraft.pack(this.destructive);

const overrides = this.overrides!;
Expand Down
2 changes: 1 addition & 1 deletion upload-charm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ If you want to use a new resource, you'll have to cut a new resource revision **
| Key | Description | Required |
| -------------------- | ---------------------------------------------------------------------------------------------------------------- | -------- |
| `charm-path` | Path to the charm we want to publish. Defaults to the current working directory. | |
| `built-charm-path` | Path to a pre-built charm we want to publish. | |
| `built-charm-path` | Path to one or more pre-built charms as comma-separated values. | |
| `channel` | Channel on charmhub to publish the charm in. Defaults to `latest/edge`. | |
| `credentials` | Credentials [exported](https://juju.is/docs/sdk/remote-env-auth) using `charmcraft login --export`. | ✔️ |
| `destructive-mode` | Whether or not to pack using destructive mode. Defaults to `true`. | |
Expand Down
5 changes: 4 additions & 1 deletion upload-charm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ inputs:
built-charm-path:
required: false
description: |
Path to a pre-built charm.
Path to one or more pre-built charms as comma-separated values.
If provided, charmcraft pack will not be executed.
- Single charm: `/tmp/build/my-charm.charm`
- Multiple charms: `/tmp/build/my-charm.charm,/tmp/build/my-charm_amd64.charm`
charmcraft-channel:
required: false
default: 'latest/stable'
Expand Down
Loading