Commit Graph

28 Commits

Author SHA1 Message Date
Stefan M
a3fb7e6abe [go] Added support for 1.22 and updated Go minor versions of 1.19, 1.20 and 1.21 (#11156)
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Vedant <83997633+vedantmgoyal9@users.noreply.github.com>
2024-04-04 00:47:57 -07:00
Nathan Rajlich
73b112b1f7 [build-utils] Add getOsRelease() and getProvidedRuntime() functions (#11370)
Adds two new helper functions that custom runtimes can utilize in order
to determine whether they should use `provided.al2` or `provided.al2023`
Lambda "runtime" value, based on the build environment.

The new `getProvidedRuntime()` helper function is being used in
`@vercel/go`, so that Go endpoints may be used when the `20.x` Node
Version project setting is used.
2024-04-02 20:30:06 -07:00
Nathan Rajlich
c82a55c460 [tests] Use AL2 build container for relevant e2e tests (#11329)
* Forces the AL2 build container image for fixtures that depend on it,
via `engines.node` in package.json for most cases.
* The `testDeployment()` function was updated to send
`projectSettings.nodeVersion` in the POST body, to mimic the behavior in
CLI.
* For Go, Ruby, and Python tests, the `projectSettings.nodeVersion`
property is set "globally" in the Jest setup file, so that individual
fixtures didn't need to be adjusted.
2024-03-27 12:19:30 -07:00
Chris Barber
5e6ef3d569 Enable source maps in tests (#10725)
The `tsconfig` files were unified with a common configuration in https://github.com/vercel/vercel/pull/10667 including disabling source maps. The source maps greatly increase the distribution size, but they are invaluable when the tests run, so this PR enables source maps for tests including adding a `tsconfig.json` where absent.

Linear: https://linear.app/vercel/issue/ZERO-364/enable-sourcemaps-in-all-testtsconfigjson-files
2023-10-17 15:15:29 +00:00
Ethan Arrowood
9bb3067de2 [go] add support for Go 1.21.0 (#10552)
as titled

updates a test to check for runtime version

---------

Co-authored-by: Nathan Rajlich <n@n8.io>
2023-09-20 12:30:38 -06:00
Chris Barber
6784e77516 [go] Update to esbuild script (#10468)
Co-authored-by: Nathan Rajlich <n@n8.io>
2023-09-08 17:00:40 -05:00
Sean Massa
0490a7733b [tests] install root typescript version 4.9.5 and standardize on that version (#9858)
This add a root-level `typescript` version that matches the one used throughout for VS Code (and other IDEs) to use when browsing the code. After this PR merges, you will be able to set VS Code's TypeScript version to match the project's version.

This will remove issues where the IDE says TypeScript compilation is good to go, but `pnpm build` disagrees.

If there's a better way to allow this, please suggest it!

---

To enable:

<img width="849" alt="Screenshot 2023-04-25 at 4 28 22 PM" src="https://user-images.githubusercontent.com/41545/234408245-205b3260-7b1d-4c43-a531-d616915dbefb.png">

Then:

<img width="1015" alt="Screenshot 2023-04-25 at 4 29 20 PM" src="https://user-images.githubusercontent.com/41545/234408271-4e7b4ec8-0be3-4743-afd7-813a267c0756.png">
2023-04-27 08:13:53 +00:00
Chris Barber
38eb0bca04 [go] Support 'go.work' file and resolve shared deps relative to work path (#9708)
This PR fixes a few issues related to `vc dev`.

1. Create a default `go.work` file in the cache dir when building the `vercel-dev-server-go` executable
2. Copy the existing `go.mod` file into the cache dir and update any "replace" relative paths
3. Split the "build" logic into separate functions for the legacy "main" package build and the `go.mod` build

Additionally, it fixes:

1. `vc build`: pass in `build.env` from `vercel.json`
2. Fix several tests to work with `vc dev` and `vc build`

Linear: https://linear.app/vercel/issue/VCCLI-638/vc-dev-go-builder-cant-resolve-workspace-dependencies

The user that reported the issue has tested this build and seems to fix their use case: https://github.com/vercel/vercel/issues/9393#issuecomment-1490726785.
2023-04-13 17:59:47 +00:00
Vedant
9712640fe3 [go] Add support for Go 1.20 (#9367)
Co-authored-by: Chris Barber <chris.barber@vercel.com>
2023-03-16 14:11:49 -05:00
Chris Barber
0dd3711f63 [go] Go builder improvements (#9576)
This PR fixes a handful of Go builder issues all related to the selected Golang version being used to build the function:

- `go.mod` version ignored for `vc build` and `vc dev`, uses system `PATH` version only
- `vc dev` fails if `go.mod` does not exist
- If the analyze bin doesn’t exist, downloads golang into `.vercel/cache/golang` instead of a global shared dir
- When running `vc dev`, doesn’t reuse go build code/common settings
- go tidy fails when `go.mod` set to 1.19 or 1.20, but 1.18 or older is installed
- `vc build` builds wrong arch on Apple Silicon/arm64
- `vc build` on Windows doesn't properly resolve "builds" in `vercel.json` due to posix separator issue
- `vc build` on Windows fails with `package <pkg/name> is not in GOROOT` due to posix separator issue
- Removed `actions/setup-go` from all test workflows

I added a test that tests the `go tidy` issue.
2023-03-16 19:05:09 +00:00
Steven
fdf7fd6784 [go] Add support for Go 1.19 (#9343)
![image](https://user-images.githubusercontent.com/229881/215526900-fef3e4e0-d1a6-4327-b68f-d8bb9068e2a0.png)
2023-01-30 17:08:10 +00:00
Sean Massa
30503d0a3f [go] remove unused, breaking watchlist from Go builder (#8633) 2022-09-26 14:31:36 -05:00
Nathan Rajlich
9d7d822da3 [tests] Add test for path segments when go.mod is present (#7361)
Path segment previously were not working when a `go.mod` file is present. This was fixed likely by https://github.com/vercel/vercel/pull/8291, so now this PR is just a test to ensure this case stays working.
2022-09-14 19:10:49 +00:00
Sean Massa
7c1c089a70 [tests] rename go test function (#8458)
This function name can be anything, but the current one is confusing. This is what the function gets renamed to during compilation. Let's change it back to avoid confusion.
2022-08-25 15:11:05 +00:00
Sean Massa
abfe817f86 [go] ignore bad go handlers and rename functions with more precision (#8422)
Co-authored-by: Steven <steven@ceriously.com>
2022-08-23 10:14:21 -05:00
Sean Massa
4fe489edad Revert "Revert "[go] add lambda wrapper support to the go runtime"" (#8407)
Co-authored-by: Craig Andrews <craig.andrews@vercel.com>
Co-authored-by: Craig Andrews <44933829+craigandrews@users.noreply.github.com>
2022-08-16 11:54:44 -05:00
Sean Massa
40df88b483 Revert "add test for main.go scenario"
This reverts commit 75c4f45b73.
2022-08-16 03:03:11 -05:00
Sean Massa
75c4f45b73 add test for main.go scenario 2022-08-16 03:01:12 -05:00
Steven
65ae2a289e Revert "[go] add lambda wrapper support to the go runtime" (#8385)
Revert "[go] add lambda wrapper support to the go runtime (#8350)"

This reverts commit 4c230c8436.
2022-08-12 10:51:43 -04:00
Craig Andrews
4c230c8436 [go] add lambda wrapper support to the go runtime (#8350)
Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
2022-08-09 16:08:20 -05:00
Sean Massa
33aefdc029 [go] fix function name conflict (#8299)
Co-authored-by: Steven <steven@ceriously.com>
2022-08-08 17:07:02 -05:00
Sean Massa
ac5b259c11 [go] refactor away use of downloaded result (#8291)
Review Notes: Turn off diff whitespace.

### Refactor

This PR refactors away the use of the result of `download` for a couple of reasons:
- Keeping `files` and `downloadedFiles` in sync with the file system (like when we rename a file that starts with a bracket) is easy to forget to do, causing bugs
- Nate says that `files` is something we've wanted to move away from using anyway
- It simplifies the code in a few places
- It was getting in the way of other fixes that need to be made

We do still call `download`, but it should be a no-op most of the time.

As a consequence of these changes, this PR also addresses:
- the builder no longer leaves build artifacts around, in many cases
- the builder can compile files that start with brackets again; routes don't seem to allow this to file to respond to a dynamic segments yet, though

### Next Steps

Upcoming PRs will resolve builder issues:

- bracket endpoints responding to dynamic segments
- exported function name conflict handling
- compilation targets should only apply to the source code build, not the analyze go utility

### Operating In-place

We also now have a cleanup step that clears out created files, created directories, and undoes file renames. This fixes an issue where multiple builds on the same directory would fail. It also cleans the user's project code when they are using `vc build`.

Ideally, we'd probably copy all of the code to a separate location, then freely do filesystem operations there. It's not clear to me if this is preferred for large projects because it would have to happen once per endpoint: 100 Go files would cause 10,000 (100 * 100) file copies (or symlinks). 

It has to copy once per endpoint because we potentially need all of the files around in case any of them are imported. If we had nft-style tracing for Go, we could copy only what we needed.

This gets more complex in the next step where the exported function names will be renamed during compilation to fix the name conflict issue.
2022-08-04 01:11:35 +00:00
Sean Massa
d296064386 [go] remove meta.isDev references and restore partial tests (#8287)
Remove `meta.isDev` checks inside the `build` function because it's never set there. Instead, `startDevServer` would be used.

Also restored the Go tests in a partial form. Will fix the Go builder issues and make sure those features are tested completely in follow-up PRs.
2022-08-01 19:52:34 +00:00
Steven
b5b792e42f [tests] Update tests to run with vercel cli tarball (#8257)
This PR update the tests suite to wait for Vercel CLI tarball and then use that tarball to run E2E tests.

This is valuable because it will package all the packages in this monorepo to make the tests follow more closely what will happen in production once merged.

Since the current "Find Changes" step takes about 2 minutes, we run that first (it happens concurrently with the tarball preparation). Then once we complete "Find Changes" we wait for the tarball but it will likely be ready by that point since it also takes about 2 minutes. After both of those steps, the E2E tests continue as usual but with the `VERCEL_CLI_VERSION` set to the tarball.

- Related to #7967 
- Closes #8245 
- Closes #8227
2022-07-27 17:56:03 -04:00
Steven
c14e5689f1 [tests] Skip broken go test (#7809)
This test was added several years ago, before the monorepo in https://github.com/vercel/vercel/pull/2812 but it was never working correctly due to the way zero config behaves differently than the test with `builds` in vercel.json

We can fix it in a follow up PR
2022-05-16 14:44:09 -04:00
QianyuPan
d63e8d3187 [go] Add support for version 1.18 (#7590)
Go 1.18 has been released, but I find that I can't deploy my project on Vercel when `go.mod` has `go 1.18` in it.

1.18 adds some very useful features. It would be very valuable for developers to have Vercel support 1.18.
2022-04-14 19:37:01 -04:00
Steven
db8e36e04c [go] Add support for version 1.17 (#7002)
* Support more Go versions

Co-authored-by: Stefan M <StefMa@users.noreply.github.com>
2021-11-15 13:36:26 -05:00
ernestd
cfae7ec3c2 [all] Remove now prefix in packages (#5928)
* remove prefix from codeowners

* remove references from ignore files

* Remove prefix from package json and tests

* Add run js without prefixes

* Rename package folders

* Delete auto generated test files

* Remove now-node in integration test

* Put back deleted vercel json files

* Remove eol

* Add styfle suggestion to comment in utils/run.js

Co-authored-by: Steven <steven@ceriously.com>
2021-03-05 16:55:30 -08:00