Commit Graph

15 Commits

Author SHA1 Message Date
Fraser Waters aa59a7e72f Fix TestNPMInstallCmd 2023-05-29 14:16:23 +01:00
Robbie McKinstry bc7a73436e
Tests: Trim file extension for Windows 2023-05-26 15:59:41 -04:00
Robbie McKinstry 6a9cf0d153
Fix typo in tests 2023-05-26 12:31:01 -04:00
Robbie McKinstry da17bfe24d
Update sdk/nodejs/npm/npm_test.go
Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
2023-05-26 11:45:39 -04:00
Robbie McKinstry ff0e13c5e0
Add unit test for npm installation. 2023-05-26 11:43:22 -04:00
Robbie McKinstry 0251902d50
Abstract package manager behavior behind interface.
This PR moves the logic of `Install` and `Pack` behind an interface
for each of the supported package managers. We now dynamically dispatch
to an NPM implementation for NPM installation WLOG yarn.
2023-05-24 12:55:02 -04:00
Abhinav Gupta 7aa5b77a0c
all: Reformat with gofumpt
Per team discussion, switching to gofumpt.

[gofumpt][1] is an alternative, stricter alternative to gofmt.
It addresses other stylistic concerns that gofmt doesn't yet cover.

  [1]: https://github.com/mvdan/gofumpt

See the full list of [Added rules][2], but it includes:

- Dropping empty lines around function bodies
- Dropping unnecessary variable grouping when there's only one variable
- Ensuring an empty line between multi-line functions
- simplification (`-s` in gofmt) is always enabled
- Ensuring multi-line function signatures end with
  `) {` on a separate line.

  [2]: https://github.com/mvdan/gofumpt#Added-rules

gofumpt is stricter, but there's no lock-in.
All gofumpt output is valid gofmt output,
so if we decide we don't like it, it's easy to switch back
without any code changes.

gofumpt support is built into the tooling we use for development
so this won't change development workflows.

- golangci-lint includes a gofumpt check (enabled in this PR)
- gopls, the LSP for Go, includes a gofumpt option
  (see [installation instrutions][3])

  [3]: https://github.com/mvdan/gofumpt#installation

This change was generated by running:

```bash
gofumpt -w $(rg --files -g '*.go' | rg -v testdata | rg -v compilation_error)
```

The following files were manually tweaked afterwards:

- pkg/cmd/pulumi/stack_change_secrets_provider.go:
  one of the lines overflowed and had comments in an inconvenient place
- pkg/cmd/pulumi/destroy.go:
  `var x T = y` where `T` wasn't necessary
- pkg/cmd/pulumi/policy_new.go:
  long line because of error message
- pkg/backend/snapshot_test.go:
  long line trying to assign three variables in the same assignment

I have included mention of gofumpt in the CONTRIBUTING.md.
2023-03-03 09:00:24 -08:00
Abhinav Gupta 1158d4acee
all: Drop ioutil
Stop using io/ioutil across the entire repository.
The io/ioutil package was deprecated in Go 1.16 (2021-02)
with replacements provided in other packages.
Specifically:

    ioutil.Discard   => io.Discard
    ioutil.NopCloser => io.NopCloser
    ioutil.ReadAll   => io.ReadAll
    ioutil.ReadFile  => os.ReadFile
    ioutil.TempDir   => os.MkdirTemp
    ioutil.TempFile  => os.CreateTemp
    ioutil.WriteFile => os.WriteFile

This change switches all of these entities
across the repository.

Following this change,
the only references to ioutil are in schema files:

    % rg -l ioutil
    pkg/codegen/testing/test/testdata/aws-4.26.0.json
    pkg/codegen/testing/test/testdata/aws-4.36.0.json
    pkg/codegen/testing/test/testdata/aws-4.37.1.json
    pkg/codegen/testing/test/testdata/aws-5.4.0.json
    pkg/codegen/testing/test/testdata/aws-5.16.2.json

The bulk of this change was generated automatically
with manual touch ups afterwards.
2023-01-06 16:35:14 -08:00
Eng Zer Jun 48eff4676a
test: use T.TempDir to create temporary test directory
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-12-03 15:17:08 +08:00
Aaron Friel 7bef1b717e ci: Prevent yarn mutex timeout by single-threading yarn commands 2022-09-14 10:07:21 -07:00
Eng Zer Jun 19d84ef1f3
test: use `T.Setenv` to set env vars in tests ()
This commit replaces `os.Setenv` with `t.Setenv` in tests. The
environment variable is automatically restored to its original value
when the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.Setenv
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-07-24 10:41:44 +01:00
Ian Wahbe f3e430a1da
Respond to SIGINT during plugin install ()
* Respond to SIGINT

With the current state of the PR, crash on SIGINT. This is progress.

* Don't crash responding to SIGINT

* Close on cancel instead of terminate

* CL

* Fix lint

* Add ctx for node

* Be consistent for test context
2022-06-09 14:57:56 -07:00
Aaron Friel ed2923653c ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
Evan Boyle 6ae6cc45b7
skip installing dev dependencies for nodejs plugin setup () 2021-06-02 11:09:03 -07:00
Justin Van Patten 46c7c327dd
Install plugin dependencies ()
When installing a plugin, if it contains a `PulumiPlugin.yaml` file with a `runtime` value of `nodejs` or `python`, install dependencies for the plugin.

For Node.js, `npm install` is run (or `yarn install` if `PULUMI_PREFER_YARN` is set).

For Python, a virtual environment is created and deps installed into it.
2020-09-14 13:54:26 -07:00