Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
11118: ci: Update post-release PR to align with release process r=AaronFriel a=AaronFriel

As the release process now includes a "freeze PR" which updates `.version` _prior_ to release, the post-release PR shouldn't attempt to make the same change, as it causes a merge conflict.

This removes the notion of "next-version" from the CI scripts, as that post-release PR was the only place it was used.

The post-release PR can also be auto-merged, so `queue-merge` is set to true.

11249: ci: Reduce Windows test parallelism r=AaronFriel a=AaronFriel

Increases likelihood of CI passing on Windows due to longstanding CPU exhaustion bug on runners. (GitHub support ticket 1791026 on my account.)



11284: Make convert's pcl output yaml agnostic r=Frassle a=Frassle

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

We're going to use convert for more data sources than just YAML (e.g. hcl, arm, etc). So we don't want the PCL output option to be YAML specific given it should be usable for any input source.


11288: [cli] Update the survey module r=pgavlin a=pgavlin

Pick up the bugfix to AlecAivazis/survey#228.

This also provides a cleaner API for setting survey icons.

11289: [cli] Add a newline in the refresh confirmation prompt r=pgavlin a=pgavlin

The lack of a newline causes the prompt to wrap in terminals that are fewer than 120 or so columns wide. The wrapping confuses the survey package's redraw, which causes the repeated prompts each time the survey is redrawn (i.e. on every keypress). Removing the wrapping by adding a newline avoids this issue.

Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
Co-authored-by: Fraser Waters <fraser@pulumi.com>
Co-authored-by: Pat Gavlin <pat@pulumi.com>
  • Loading branch information
4 people committed Nov 8, 2022
6 parents ed05626 + 8b1b37d + 699a64a + 8d85edd + 6126991 + c3a7f8d commit 74cb8b8
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 133 deletions.
20 changes: 0 additions & 20 deletions .github/scripts/get-next-version

This file was deleted.

7 changes: 0 additions & 7 deletions .github/workflows/ci-info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ on:
version:
description: "Version to produce"
value: ${{ jobs.info.outputs.version }}
next-version:
description: "Next version to produce"
value: ${{ jobs.info.outputs.next-version }}
release-notes:
description: "Release notes for CHANGELOG"
value: ${{ jobs.info.outputs.release-notes }}
Expand All @@ -38,7 +35,6 @@ jobs:
contents: read
outputs:
version: "${{ fromJSON(steps.version.outputs.version) }}"
next-version: "${{ fromJSON(steps.version.outputs.next-version) }}"
release-notes: "${{ fromJSON(steps.notes.outputs.release-notes) }}"
env:
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
Expand All @@ -65,9 +61,6 @@ jobs:
fi
./.github/scripts/set-output version "${PULUMI_VERSION}"
NEXT_VERSION="$(.github/scripts/get-next-version "${PLAIN_VERSION}")"
./.github/scripts/set-output next-version "${NEXT_VERSION}"
- uses: actions/setup-go@v3
with:
go-version: '>=1.19.0' # decoupled from version sets, used by changelog tool
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ci-run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ jobs:
echo "$TOOL_BIN" | tee -a "$GITHUB_PATH"
command -v tar
tar --version
- name: Reduce Windows test parallelism
if: ${{ runner.os == 'Windows' }}
run: |
echo "GO_TEST_PARALLELISM=4" >> "$GITHUB_ENV"
echo "GO_TEST_PKG_PARALLELISM=1" >> "$GITHUB_ENV"
# For debugging:
ps aux
- name: "macOS use coreutils"
if: ${{ runner.os == 'macOS' }}
run: |
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ jobs:
# with:
# ref: ${{ github.ref }}
# version: ${{ needs.info.outputs.version }}
# next-version: ${{ needs.info.outputs.next-version }}
# release-notes: ${{ needs.info.outputs.release-notes }}
# version-set: ${{ needs.matrix.outputs.version-set }}
# queue-merge: false
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
runs-on: ubuntu-latest
outputs:
version: "${{ fromJSON(steps.version.outputs.version) }}"
next-version: "${{ fromJSON(steps.version.outputs.next-version) }}"
steps:
- uses: actions/checkout@v3
# Uses release ref (tag)
Expand All @@ -30,17 +29,14 @@ jobs:
./.github/scripts/set-output version "${PULUMI_VERSION}"
NEXT_VERSION="$(.github/scripts/get-next-version "${PULUMI_VERSION}")"
./.github/scripts/set-output next-version "${NEXT_VERSION}"
release:
name: release
needs: [info]
uses: ./.github/workflows/release.yml
with:
ref: ${{ github.event.release.tag_name }}
version: ${{ needs.info.outputs.version }}
next-version: ${{ needs.info.outputs.next-version }}
release-notes: ${{ github.event.release.body }}
queue-merge: true
run-dispatch-commands: true
secrets: inherit
17 changes: 5 additions & 12 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ on:
required: false
description: "Commit to branch from, if not the tag"
type: string
next-version:
required: true
description: "Version to bump files to"
type: string
release-notes:
required: true
description: "Release notes to publish"
Expand All @@ -48,25 +44,22 @@ jobs:
- name: Create PR
env:
PULUMI_VERSION: ${{ inputs.version }}
NEXT_VERSION: ${{ inputs.next-version }}
RELEASE_NOTES: ${{ inputs.release-notes }}
QUEUE_MERGE: ${{ inputs.queue-merge }}
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
run: |
set -euo pipefail
git switch --create "automation/release-v${PULUMI_VERSION}-v${NEXT_VERSION}"
git switch --create "automation/release-v${PULUMI_VERSION}"
echo -en "# Changelog\n\n${RELEASE_NOTES}\n\n$(tail -n+3 CHANGELOG.md)" > ./CHANGELOG.md
./.github/scripts/update-versions "${NEXT_VERSION}"
git config user.name github-actions
git config user.email github-actions@github.com
rm ./changelog/pending/*.yaml || true
git add -A
git commit -m "Prepare for next release (v${NEXT_VERSION})"
git commit -m "chore: changelog for v${PULUMI_VERSION}"
# Update go module dependencies
(
Expand All @@ -75,7 +68,7 @@ jobs:
)
make tidy
git add -A
git commit -m "Update dependencies"
git commit -m "chore: post-release go.mod updates"
# Publish pkg module on another tag.
git tag "pkg/v${PULUMI_VERSION}"
Expand All @@ -84,9 +77,9 @@ jobs:
PR_BODY=""
if [ "${QUEUE_MERGE}" = "true" ]; then
PR_BODY="bors r+"
PR_BODY="bors merge"
fi
gh pr create \
--title "prepare for next release (v${NEXT_VERSION})" \
--title "Changelog and go.mod updates for v${PULUMI_VERSION}" \
--body "${PR_BODY}"
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ on:
required: false
description: "Commit to branch from, if not the tag"
type: string
next-version:
required: true
description: "Version to bump files to"
type: string
release-notes:
required: true
description: "Release notes to publish"
Expand Down Expand Up @@ -148,9 +144,8 @@ jobs:
with:
ref: ${{ inputs.ref }}
version: ${{ inputs.version }}
next-version: ${{ inputs.next-version }}
release-notes: ${{ inputs.release-notes }}
queue-merge: false
queue-merge: ${{ inputs.queue-merge }}
secrets: inherit

dispatch:
Expand Down
17 changes: 8 additions & 9 deletions pkg/backend/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"os"
"strings"

survey "gopkg.in/AlecAivazis/survey.v1"
surveycore "gopkg.in/AlecAivazis/survey.v1/core"
survey "github.com/AlecAivazis/survey/v2"
surveycore "github.com/AlecAivazis/survey/v2/core"

"github.com/pulumi/pulumi/pkg/v3/backend/display"
"github.com/pulumi/pulumi/pkg/v3/engine"
Expand All @@ -31,7 +31,6 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
sdkDisplay "github.com/pulumi/pulumi/sdk/v3/go/common/display"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/result"
)
Expand Down Expand Up @@ -146,8 +145,10 @@ func confirmBeforeUpdating(kind apitype.UpdateKind, stack Stack,
var response string

surveycore.DisableColor = true
surveycore.QuestionIcon = ""
surveycore.SelectFocusIcon = opts.Display.Color.Colorize(colors.BrightGreen + ">" + colors.Reset)
surveyIcons := survey.WithIcons(func(icons *survey.IconSet) {
icons.Question = survey.Icon{}
icons.SelectFocus = survey.Icon{Text: opts.Display.Color.Colorize(colors.BrightGreen + ">" + colors.Reset)}
})

choices := []string{string(yes), string(no)}

Expand All @@ -168,18 +169,16 @@ func confirmBeforeUpdating(kind apitype.UpdateKind, stack Stack,
if kind == apitype.RefreshUpdate {
prompt += "\n" +
opts.Display.Color.Colorize(colors.SpecImportant+
"No resources will be modified as part of this refresh; just your stack's state will be."+
"No resources will be modified as part of this refresh; just your stack's state will be.\n"+
colors.Reset)
}

cmdutil.EndKeypadTransmitMode()

// Now prompt the user for a yes, no, or details, and then proceed accordingly.
if err := survey.AskOne(&survey.Select{
Message: prompt,
Options: choices,
Default: string(no),
}, &response, nil); err != nil {
}, &response, surveyIcons); err != nil {
return result.FromError(fmt.Errorf("confirmation cancelled, not proceeding with the %s: %w", kind, err))
}

Expand Down
47 changes: 14 additions & 33 deletions pkg/cmd/pulumi/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,39 +81,22 @@ func newConvertCmd() *cobra.Command {
return cmd
}

// runConvert converts a Pulumi program from YAML into PCL without generating a full pcl.Program
func runConvertPcl(cwd string, outDir string) result.Result {
host, err := newPluginHost()
if err != nil {
return result.FromError(fmt.Errorf("could not create plugin host: %w", err))
}
defer contract.IgnoreClose(host)
loader := schema.NewPluginLoader(host)
_, template, diags, err := yamlgen.LoadTemplate(cwd)
if err != nil {
return result.FromError(err)
}

if diags.HasErrors() {
return result.FromError(diags)
}

programText, diags, err := yamlgen.ConvertTemplateIL(template, loader)
if err != nil {
return result.FromError(err)
}

if outDir != "." {
err := os.MkdirAll(outDir, 0755)
// pclGenerateProject writes out a pcl.Program directly as .pp files
func pclGenerateProject(directory string, project workspace.Project, p *pcl.Program) error {
if directory != "." {
err := os.MkdirAll(directory, 0755)
if err != nil {
return result.FromError(fmt.Errorf("could not create output directory: %w", err))
return fmt.Errorf("could not create output directory: %w", err)
}
}

outputFile := path.Join(outDir, "main.pp")
err = ioutil.WriteFile(outputFile, []byte(programText), 0600)
if err != nil {
return result.FromError(fmt.Errorf("could not write output program: %w", err))
// We don't write out the Pulumi.yaml for PCL, just the .pp files.
for file, source := range p.Source() {
outputFile := path.Join(directory, file)
err := ioutil.WriteFile(outputFile, []byte(source), 0600)
if err != nil {
return fmt.Errorf("could not write output program: %w", err)
}
}

return nil
Expand All @@ -136,11 +119,9 @@ func runConvert(cwd string, language string, outDir string, generateOnly bool) r
projectGenerator = yamlgen.GenerateProject
case "pulumi", "pcl":
if cmdutil.IsTruthy(os.Getenv("PULUMI_DEV")) {
// since we don't need Eject to get the full program,
// we can just convert the YAML directly to PCL
return runConvertPcl(cwd, outDir)
projectGenerator = pclGenerateProject
break
}

fallthrough

default:
Expand Down
10 changes: 3 additions & 7 deletions pkg/cmd/pulumi/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (

"gopkg.in/yaml.v3"

survey "github.com/AlecAivazis/survey/v2"
surveycore "github.com/AlecAivazis/survey/v2/core"
"github.com/opentracing/opentracing-go"
"github.com/spf13/cobra"
survey "gopkg.in/AlecAivazis/survey.v1"
surveycore "gopkg.in/AlecAivazis/survey.v1/core"

"github.com/pulumi/pulumi/pkg/v3/backend"
"github.com/pulumi/pulumi/pkg/v3/backend/display"
Expand Down Expand Up @@ -814,8 +814,6 @@ func chooseTemplate(templates []workspace.Template, opts display.Options) (works

// Customize the prompt a little bit (and disable color since it doesn't match our scheme).
surveycore.DisableColor = true
surveycore.QuestionIcon = ""
surveycore.SelectFocusIcon = opts.Color.Colorize(colors.BrightGreen + ">" + colors.Reset)

var selectedOption workspace.Template

Expand All @@ -826,14 +824,12 @@ func chooseTemplate(templates []workspace.Template, opts display.Options) (works
message := fmt.Sprintf("\rPlease choose a template (%d/%d shown):\n", pageSize, nopts)
message = opts.Color.Colorize(colors.SpecPrompt + message + colors.Reset)

cmdutil.EndKeypadTransmitMode()

var option string
if err := survey.AskOne(&survey.Select{
Message: message,
Options: options,
PageSize: pageSize,
}, &option, nil); err != nil {
}, &option, surveyIcons(opts.Color)); err != nil {
return workspace.Template{}, errors.New(chooseTemplateErr)
}

Expand Down
10 changes: 3 additions & 7 deletions pkg/cmd/pulumi/policy_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"sort"
"strings"

survey "github.com/AlecAivazis/survey/v2"
surveycore "github.com/AlecAivazis/survey/v2/core"
"github.com/opentracing/opentracing-go"
"github.com/pulumi/pulumi/pkg/v3/backend/display"
"github.com/pulumi/pulumi/pkg/v3/engine"
Expand All @@ -33,8 +35,6 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
"github.com/spf13/cobra"
survey "gopkg.in/AlecAivazis/survey.v1"
surveycore "gopkg.in/AlecAivazis/survey.v1/core"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -335,21 +335,17 @@ func choosePolicyPackTemplate(templates []workspace.PolicyPackTemplate,

// Customize the prompt a little bit (and disable color since it doesn't match our scheme).
surveycore.DisableColor = true
surveycore.QuestionIcon = ""
surveycore.SelectFocusIcon = opts.Color.Colorize(colors.BrightGreen + ">" + colors.Reset)
message := "\rPlease choose a template:"
message = opts.Color.Colorize(colors.SpecPrompt + message + colors.Reset)

options, optionToTemplateMap := policyTemplatesToOptionArrayAndMap(templates)

cmdutil.EndKeypadTransmitMode()

var option string
if err := survey.AskOne(&survey.Select{
Message: message,
Options: options,
PageSize: optimalPageSize(optimalPageSizeOpts{nopts: len(options)}),
}, &option, nil); err != nil {
}, &option, surveyIcons(opts.Color)); err != nil {
return workspace.PolicyPackTemplate{}, errors.New(chooseTemplateErr)
}
return optionToTemplateMap[option], nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/pulumi/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"os"
"strings"

survey "github.com/AlecAivazis/survey/v2"
terminal "github.com/AlecAivazis/survey/v2/terminal"
"github.com/spf13/cobra"
survey "gopkg.in/AlecAivazis/survey.v1"
terminal "gopkg.in/AlecAivazis/survey.v1/terminal"

"github.com/pulumi/pulumi/pkg/v3/backend"
"github.com/pulumi/pulumi/pkg/v3/backend/display"
Expand Down

0 comments on commit 74cb8b8

Please sign in to comment.