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

pulumi-version-file only works in install-only mode #1215

Closed
gustavkj opened this issue Jul 1, 2024 · 2 comments · Fixed by #1218
Closed

pulumi-version-file only works in install-only mode #1215

gustavkj opened this issue Jul 1, 2024 · 2 comments · Fixed by #1218
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Milestone

Comments

@gustavkj
Copy link

gustavkj commented Jul 1, 2024

What happened?

It seems that the pulumi-version-file input argument only works in install-only mode. I do not think this is expected behavior according to the documentation in the readme or in the PR: #1204

When in non-install-only mode

When running the following action config:

      - name: Preview <project-name> changes
        uses: pulumi/actions@v5
        env:
          PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
        with:
          command: preview
          work-dir: ./projects/<project>
          comment-on-pr: true
          stack-name: prod
          pulumi-version-file: ./.pulumi.version
          cloud-url: ${{ steps.backend-url.outputs.result }}

I get this output:

> Run pulumi/actions@v5
  
Configured range: 
Matched version: v3.121.0
Install destination is /home/ubuntu/.pulumi
Successfully deleted pre-existing /home/ubuntu/.pulumi/bin
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/ubuntu/.pulumi -f /opt/actions-runner/_work/_temp/6800d063-e7de-41b2-86b5-d307745b54ce
Logging into s3://<i-removed-this>
pulumi preview on prod

Just to test, the content of the .pulumi.version file is:

3.120.0

When in install-only mode

      - name: Install Pulumi
        uses: pulumi/actions@v5
        with:
          pulumi-version-file: ./.pulumi.version
      - name: Preview <project-name> changes
        uses: pulumi/actions@v5
        env:
          PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
        with:
          command: preview
          work-dir: ./projects/<project>
          comment-on-pr: true
          stack-name: prod
          pulumi-version-file: ./.pulumi.version
          cloud-url: ${{ steps.backend-url.outputs.result }}

Output:

# Install Pulumi
> Run pulumi/actions@v5
Configured range: 3.120.0
Matched version: v3.120.0
Install destination is /home/ubuntu/.pulumi
Successfully deleted pre-existing /home/ubuntu/.pulumi/bin
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/ubuntu/.pulumi -f /opt/actions-runner/_work/_temp/3cadc875-d728-485a-b0d5-18bd5df5536d
Pulumi has been successfully installed. Exiting.

# Preview <project-name> changes
> Run pulumi/actions@v5
Configured range: 
/opt/actions-runner/_work/_tool/pulumi/3.120.0/x64/pulumi version
v3.120.0
Pulumi version 3.120.0 has a known issue. Proceeding to download
Matched version: v3.121.0
Install destination is /home/ubuntu/.pulumi
Successfully deleted pre-existing /home/ubuntu/.pulumi/bin
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/ubuntu/.pulumi -f /opt/actions-runner/_work/_temp/1ea31476-34e3-48d1-874b-89a2915cc197
Logging into s3://<i-removed-this>
pulumi preview on prod

Example

The example comes from a GHES repo, but the following does not work:

When running the following action config:

      - name: Preview <project-name> changes
        uses: pulumi/actions@v5
        env:
          PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
        with:
          command: preview
          work-dir: ./projects/<project>
          comment-on-pr: true
          stack-name: prod
          pulumi-version-file: ./.pulumi.version
          cloud-url: ${{ steps.backend-url.outputs.result }}

I get this output:

> Run pulumi/actions@v5
  
Configured range: 
Matched version: v3.121.0
Install destination is /home/ubuntu/.pulumi
Successfully deleted pre-existing /home/ubuntu/.pulumi/bin
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/ubuntu/.pulumi -f /opt/actions-runner/_work/_temp/6800d063-e7de-41b2-86b5-d307745b54ce
Logging into s3://<i-removed-this>
pulumi preview on prod

Just to test, the content of the .pulumi.version file is:

3.120.0

Output of pulumi about

CLI          
Version      3.121.0
Go Version   go1.22.4
Go Compiler  gc

Plugins
KIND      NAME    VERSION
resource  aws     6.42.0
language  nodejs  unknown
resource  tls     5.0.3

Host     
OS       ubuntu
Version  22.04
Arch     x86_64

This project is written in nodejs: executable='/home/<user>/.nvm/versions/node/v18.20.3/bin/node' version='v18.20.3'

Backend        
Name           <computer-name>
URL            s3://<s3-bucket>
User           <user>
Organizations  
Token type     personal

Additional context

In the config.ts file pulumi-version-file input is only read in makeInstallationConfig:

const versionFile = getInput('pulumi-version-file');

installationConfig is only valid when command is undefined, so in main.ts the if statement checking downloadConfig.success is skipped when not in install-only mode:

actions/src/main.ts

Lines 23 to 28 in 760956a

const downloadConfig = makeInstallationConfig();
if (downloadConfig.success) {
await installOnly(downloadConfig.value);
core.info('Pulumi has been successfully installed. Exiting.');
return;
}

So, when not in install-only mode, then full config does not use pulumi-version-file. Also, I suspect getInput('pulumi-version') returns an empty string causing pulumiVersion to be an empty string, rather than ^3 (I'm thinking this because of the outputted line Configured range: which should end with the value from pulumiVersion).

actions/src/main.ts

Lines 32 to 34 in 760956a

const config = await makeConfig();
core.debug('Configuration is loaded');
runAction(config);

actions/src/main.ts

Lines 43 to 44 in 760956a

const runAction = async (config: Config): Promise<void> => {
await pulumiCli.downloadCli(config.pulumiVersion);

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@gustavkj gustavkj added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jul 1, 2024
@justinvp
Copy link
Member

justinvp commented Jul 2, 2024

Thanks for opening the issue!

@justinvp justinvp removed the needs-triage Needs attention from the triage team label Jul 2, 2024
@justinvp justinvp added this to the 0.107 milestone Jul 2, 2024
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Jul 11, 2024
@pulumi-bot
Copy link

This issue has been addressed in PR #1218 and shipped in release v5.3.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants