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

Support install-only workflow. #834

Merged
merged 9 commits into from Mar 9, 2023
Merged

Support install-only workflow. #834

merged 9 commits into from Mar 9, 2023

Conversation

RobbieMcKinstry
Copy link
Contributor

This commit adds an install command option which halts execution after the Pulumi CLI is installed. This attempts to replicate the @pulumi/setup-pulumi action. To test this, most logic in main() was moved to a separate file that can be imported in a test context, unlike main.ts, which executes main() during resolution.

Fixes #686

README.md Outdated Show resolved Hide resolved
@@ -1,7 +1,53 @@
import * as pulumiCli from "../libs/pulumi-cli";
import { login } from '../login';
// import * as loginModule from '../login';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code

src/run.ts Outdated Show resolved Hide resolved
@RobbieMcKinstry
Copy link
Contributor Author

@Frassle I still need to rebase but otherwise I'm ready for another review. This commit message explains how I embraced your suggestion and the design constraints on this changeset.

@pulumi-bot
Copy link

pulumi-bot commented Mar 8, 2023

Hi 👋

Thank you for this contribution!
Due to security reasons, we only allow updating the dist/** files with our own workflows.

@abhinav abhinav force-pushed the mckinstry/install-only branch 3 times, most recently from 28bed6a to ea6cbc9 Compare March 8, 2023 19:17
abhinav added a commit that referenced this pull request Mar 8, 2023
If the tests use the pulumi installed on the GitHub workers,
then they can potentially mask bugs in the action's install step,
which is what happened in #834.
@abhinav abhinav changed the base branch from master to abhinav/ci-remove-pulumi March 8, 2023 19:49
Copy link
Contributor

abhinav commented Mar 8, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@abhinav
Copy link
Contributor

abhinav commented Mar 8, 2023

Updates:

  • Undid the refactor moving code to run.ts because that made it difficult to review the changes.
  • Fixed a bug where the CLI was not installed for regular run commands. The job passed for all but macOS because of that bug previously because macOS workers don't have pulumi installed on workers by default. Created ci/test: Don't use pre-installed Pulumi #877 to prevent this in the future.
  • Added a test to verify the install-only workflow.
  • Updated README to reflect new changes.
  • Updated action.yml to mark 'command' and 'stack' optional

@abhinav abhinav requested a review from a team March 8, 2023 19:53
Base automatically changed from abhinav/ci-remove-pulumi to master March 9, 2023 01:14
abhinav added a commit that referenced this pull request Mar 9, 2023
If the tests use the pulumi installed on the GitHub workers,
then they can potentially mask bugs in the action's install step,
which is what happened in #834.
RobbieMcKinstry and others added 7 commits March 8, 2023 17:14
This commit adds support for an install-only workflow.
If command is not specified, this will halt execution
after the CLI is installed.

This attempts to replicate the @pulumi/setup-pulumi action.

To test this, most logic in main() was moved to a separate file which
can be imported in a test context, unlike main.ts, which executes
main() during resolution.
Adds a test to verify that the action can run
in install-only mode.
Makes reviewing this PR easier by undoing the refactor.
The job was broken because in adding support for install-only
we neglected to run the install in the run case.
Marks `command` and `stack-name` as optional.
Updates guidance in README about install-only mode.
There's something smelly about using the ValidationError
to decide whether we should run in install-only or action mode.

Switch to a plain value returned by runtimes.validate
(it has a success: bool field)
and use that to decide if we're in install-only or full mode.

This gets rid of the extraneous `else throw` as well,
because the install-only mode will never throw an exception.
Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with writing actions or this codebase, but I read over the change and it generally LGTM, aside from some minor questions.

CHANGELOG.md Outdated
Comment on lines 19 to 20
- feat: Add support for an `install` command, similar to
[setup-pulumi](https://github.com/marketplace/actions/setup-pulumi)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this listed under 3.2.1 and not HEAD?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, probably because there was a release since this change was made and git merge decided to put it in the old position. Good catch.

CHANGELOG.md Outdated
- feat: Add support for an `install` command, similar to
[setup-pulumi](https://github.com/marketplace/actions/setup-pulumi)

--
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's with this trailing --?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this was added. Will fix.
(Somehow I didn't look over the changelog thoroughly.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figured out where the -- came from.
The -- separates the unreleased section from the rest. (https://github.com/pulumi/actions/blob/master/CONTRIBUTING.md)
However, because the original changelog entry was added below a then-unreleased entry,
when git merged these changes with master, it placed this entry under the original unreleased entry.

@@ -3,6 +3,53 @@ import { login } from '../login';

const spy = jest.spyOn(pulumiCli, 'run');

const installConfig: Record<string, string> = {
command: undefined,
pulumiVersion: "^4",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this ^4 vs. ^3?

Copy link
Contributor

@abhinav abhinav Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely because the test wanted to verify with a non-default value.
However, I also see that this test doesn't actually verify the result at all.
I'm going to use something older (^2?) here and update the test to verify that the non-default value is picked up.

The test only verifies the truthiness of the value.
Change it to verify the actual result.

This also caught a bug in the test:
It was using `pulumiVersion`, not `pulumi-version`,
which is the name of the actual input.
@abhinav abhinav merged commit 3ace4a6 into master Mar 9, 2023
@abhinav abhinav deleted the mckinstry/install-only branch March 9, 2023 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support an Installation-Only Workflow
5 participants