From e4957bfc06a0bb93d589c31666ea0b235df3f61b Mon Sep 17 00:00:00 2001 From: Zaid Ajaj Date: Thu, 6 Oct 2022 16:30:18 +0200 Subject: [PATCH 1/3] Add winget and msi install checks in download cron job --- .github/workflows/download-pulumi-cron.yml | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/download-pulumi-cron.yml b/.github/workflows/download-pulumi-cron.yml index d2985c28061f..1252f9b70a10 100644 --- a/.github/workflows/download-pulumi-cron.yml +++ b/.github/workflows/download-pulumi-cron.yml @@ -94,6 +94,23 @@ jobs: run: | echo "Expected version ${{ steps.vars.outputs.expected-version }} but found ${{ steps.vars.outputs.installed-version }}" exit 1 + windows-winget-install: + name: Install Pulumi with WinGet on Windows + runs-on: windows-latest + steps: + - name: winget install pulumi + rune: winget install pulumi + - name: Pulumi Version Details + id: vars + shell: bash + run: | + echo "::set-output name=installed-version::$(pulumi version)" + echo "::set-output name=expected-version::v$(curl -sS https://www.pulumi.com/latest-version)" + - name: Error if incorrect version found + if: ${{ steps.vars.outputs.expected-version != steps.vars.outputs.installed-version }} + run: | + echo "Expected version ${{ steps.vars.outputs.expected-version }} but found ${{ steps.vars.outputs.installed-version }}" + exit 1 windows-direct-install: name: Install Pulumi via script on Windows runs-on: windows-latest @@ -126,6 +143,18 @@ jobs: Invoke-WebRequest https://get.pulumi.com/releases/sdk/pulumi-v${latestVersion}-windows-x64.zip -OutFile $tempZip - run: ls -la shell: bash + windows-verify-msi-download-link: + name: Verify Direct MSI Download link on Windows + runs-on: windows-latest + steps: + - name: Direct Download + shell: pwsh + run: | + $latestVersion = (Invoke-WebRequest -UseBasicParsing https://www.pulumi.com/latest-version).Content.Trim() + $tempMsi = New-Item -Type File (Join-Path $env:TEMP ([System.IO.Path]::ChangeExtension(([System.IO.Path]::GetRandomFileName()), "msi"))) + Invoke-WebRequest https://github.com/pulumi/pulumi-winget/releases/download/v${latestVersion}/pulumi-${latestVersion}-windows-x64.msi -OutFile $tempMsi + - run: ls -la + shell: bash install-via-gha: name: Install via GHA on ${{ matrix.os }} runs-on: ${{ matrix.os }} From c86a067a6f8ea653a8f2d576c084e4c70d0e3305 Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Thu, 6 Oct 2022 22:39:52 +0100 Subject: [PATCH 2/3] Fix cloning from ADO repos Small path bug, "git clone" by default clones to a new folder based on the last part of the repo name. So running something like `pulumi new https://fraser0275@dev.azure.com/fraser0275/fraser/_git/fraser` resulted in us making a folder like /tmp/pulumi-templates-1234/fraser with all the templates in it. That last part of the path was unexpected, because when we use gogit it clones directly into the target directory we give it. Simple fix to just add `.` to the git clone command. I also added some logging while I was about here, given it helped me work out this issue. --- changelog/pending/20221006--cli-new--fix-ado-repos.yaml | 4 ++++ sdk/go/common/util/gitutil/git.go | 4 +++- sdk/go/common/workspace/templates.go | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 changelog/pending/20221006--cli-new--fix-ado-repos.yaml diff --git a/changelog/pending/20221006--cli-new--fix-ado-repos.yaml b/changelog/pending/20221006--cli-new--fix-ado-repos.yaml new file mode 100644 index 000000000000..5af91212f69a --- /dev/null +++ b/changelog/pending/20221006--cli-new--fix-ado-repos.yaml @@ -0,0 +1,4 @@ +changes: +- type: fix + scope: cli/new + description: Fix cloning templates from Azure DevOps repos. diff --git a/sdk/go/common/util/gitutil/git.go b/sdk/go/common/util/gitutil/git.go index f8227ab466bf..f51b0d80d58a 100644 --- a/sdk/go/common/util/gitutil/git.go +++ b/sdk/go/common/util/gitutil/git.go @@ -32,6 +32,7 @@ import ( "github.com/go-git/go-git/v5/storage/memory" "github.com/pkg/errors" "github.com/pulumi/pulumi/sdk/v3/go/common/util/fsutil" + "github.com/pulumi/pulumi/sdk/v3/go/common/util/logging" ) // VCSKind represents the hostname of a specific type of VCS. @@ -280,6 +281,7 @@ func GitCloneAndCheckoutCommit(url string, commit plumbing.Hash, path string) er } func GitCloneOrPull(rawurl string, referenceName plumbing.ReferenceName, path string, shallow bool) error { + logging.V(10).Infof("Attempting to clone from %s at ref %s", rawurl, referenceName) if u, err := url.Parse(rawurl); err == nil && u.Hostname() == AzureDevOpsHostName { // system-installed git is used to clone Azure DevOps repositories // due to https://github.com/go-git/go-git/issues/64 @@ -346,7 +348,7 @@ func gitCloneOrPullSystemGit(url string, referenceName plumbing.ReferenceName, p if _, err := os.Stat(filepath.Join(path, ".git")); os.IsNotExist(err) { // Repo does not exist, clone it. gitArgs = []string{ - "clone", url, + "clone", url, ".", } // For shallow clones, use a depth of 1. if shallow { diff --git a/sdk/go/common/workspace/templates.go b/sdk/go/common/workspace/templates.go index 334ba1b99357..43a5a8761895 100644 --- a/sdk/go/common/workspace/templates.go +++ b/sdk/go/common/workspace/templates.go @@ -30,6 +30,7 @@ import ( "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" "github.com/pulumi/pulumi/sdk/v3/go/common/util/gitutil" + "github.com/pulumi/pulumi/sdk/v3/go/common/util/logging" ) const ( @@ -373,8 +374,11 @@ func RetrieveGitFolder(rawurl string, path string) (string, error) { if err != nil { return "", fmt.Errorf("failed to get git ref: %w", err) } - if ref != "" { + logging.V(10).Infof( + "Attempting to fetch from %s at commit %s@%s for subdirectory '%s'", + url, ref, commit, subDirectory) + if ref != "" { // Different reference attempts to cycle through // We default to master then main in that order. We need to order them to avoid breaking // already existing processes for repos that already have a master and main branch. @@ -405,6 +409,7 @@ func RetrieveGitFolder(rawurl string, path string) (string, error) { // Verify the sub directory exists. fullPath := filepath.Join(path, filepath.FromSlash(subDirectory)) + logging.V(10).Infof("Cloned %s at commit %s@%s to %s", url, ref, commit, fullPath) info, err := os.Stat(fullPath) if err != nil { return "", err From f9fa5dd9513568504d4e427049a6ecdb5300375e Mon Sep 17 00:00:00 2001 From: Zaid Ajaj Date: Thu, 6 Oct 2022 19:11:25 +0200 Subject: [PATCH 3/3] typo --- .github/workflows/download-pulumi-cron.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/download-pulumi-cron.yml b/.github/workflows/download-pulumi-cron.yml index 1252f9b70a10..4eeaeff61f99 100644 --- a/.github/workflows/download-pulumi-cron.yml +++ b/.github/workflows/download-pulumi-cron.yml @@ -99,7 +99,7 @@ jobs: runs-on: windows-latest steps: - name: winget install pulumi - rune: winget install pulumi + run: winget install pulumi - name: Pulumi Version Details id: vars shell: bash