Commit Graph

75 Commits

Author SHA1 Message Date
Yuta Saito 820c2afab7
Add --bundle-path option to `carton test` (#358)
* Add --skip-build option to carton test to delegate building to users

* Add test case for --skip-build

* Rename --skip-build to --bundle-path to allow specifying binary path

* Update Sources/CartonCLI/Commands/Test.swift

Co-authored-by: Max Desiatov <max@desiatov.com>

* Rename --bundle-path to --prebuilt-test-bundle-path

* Update Sources/CartonCLI/Commands/Test.swift

Co-authored-by: Max Desiatov <max@desiatov.com>

Co-authored-by: Max Desiatov <max@desiatov.com>
2022-05-30 16:04:03 +00:00
Max Desiatov 7ef43954cc
Fix linter error in `Builder.swift` (#356) 2022-05-28 20:27:06 +09:00
Max Desiatov 1ba7dd5d82
Use JSKit runtime from SwiftPM resources (#335)
* Use JSKit runtime from SwiftPM resources

* Fix Node.js test runner

* Remove unused webpack npm packages

* Update Swift version in `.swiftformat`

* Fix browser and Node.js CJS/ESM handling

* Fix one of the tests, add CI time limit

* Use Tokamak `update-jskit` branch to fix tests

* Use latest Vapor with `.mjs` content-type fix

* Use dynamic import to detect JSKit presence

* Fix missing `runtimeConstructor` reference

* Update `StaticArchive.swift`

* Reduce the diff

* Address PR feedback

* Fix Node.js <-> JSKit integration test

* Update SwiftPM dependencies

* Fix comment typo in `testNode.js`

* Reuse `__stack_sanitizer` across entrypoints
2022-05-20 13:12:45 +01:00
Yuta Saito b9dab08e86
Fix JavaScriptBigIntSupport compatibility issue (#338)
* Refactoring the use of `DestinationEnvironment` and `Environment`

`Environment` shouldn't specify the concrete environment, but the type
of environments enough for build planning.

* Lower i64 imports only for WASI oriented things
2022-05-18 23:18:54 +09:00
Max Desiatov 6e3dfe62cd
Set `compatibleJSKitVersion` to 0.14.0 2022-05-03 12:25:20 +01:00
Yuta Saito 1f2aeffcc8
Enable reactor model only when not building as a command (#314) 2022-04-11 10:20:21 +01:00
Yuta Saito 9c4021d262
Several fixes for 5.6 toolchain (#310)
- Reactor model support
- Update sanitizer support object

This is required to resolve https://github.com/TokamakUI/Tokamak/pull/475
2022-04-09 13:37:34 +00:00
Max Desiatov a15023d881
Bump JavaScriptKit dependency to 0.13.0 (#306) 2022-04-01 08:53:53 +01:00
yonihemi b89d7c79dd
Use libSwiftPM 5.6 to parse manifests (#302)
* Upgrade SwiftPM to 5.6. Use libSwiftPM to parse manifests.

* Use SwiftWasm's swiftc
2022-03-28 18:13:23 +08:00
Yuta Saito 4ca0cdf939
Add -Xswiftc option for each build commands (#300) 2022-03-20 12:14:35 +09:00
yonihemi f5b8e63abe
Fix crash for packages with `executableTarget` (#296)
* Infer executable targets' source folder

* Don't initialize FSWatch without watchable paths

* Update Sources/CartonKit/Server/Server.swift

Co-authored-by: Max Desiatov <max@desiatov.com>

* Update Sources/CartonKit/Server/Server.swift

Co-authored-by: Max Desiatov <max@desiatov.com>
2022-02-21 10:18:03 +00:00
yonihemi 7bd54d6c0c
Bump JavaScriptKit and Tokamak (#294) 2022-02-16 11:02:53 +00:00
Max Desiatov 74a49c1aa8
Use `async`/`await` and actors instead of Combine (#283)
This makes our codebase smaller by ~80 lines and arguably more readable. Also removes OpenCombine dependency.

* Use `async`/`await` and actors instead of Combine

* Remove OpenCombine dependency

* Fix progress animation not updated

* Stop building with Swift 5.4, clean up terminal output

* Update requirements in `README.md`

* Add `description` to `InvalidResponseCode`

* Fix Linux build error

* Rename `main.swift` to `Main.swift`

* Work around IR/TDB warnings

* Pass IR/TDB arguments correctly to `swift build`

* Support `async` process runner in `carton-release`

* Use Xcode 13.2.1 on macOS

* Pass TDB/IR flags to `swift test` as well

* Make `Install` command async

* Add doc comments, handle subsequent rebuilds
2022-01-17 09:04:44 +00:00
Max Desiatov 367f0bc01f
Add ICU linker flags to all build invocation (#270)
Resolves https://github.com/swiftwasm/carton/issues/268.
2021-12-01 13:47:53 +01:00
Max Desiatov 0e163ec9aa
Use SwiftWasm 5.5.0, bump version to 0.12.0 (#266)
`async-http-client` package is now pinned to 1.6.4, as 1.7.0 and later versions caused issues with toolchain downloads (see https://github.com/swift-server/async-http-client/issues/488 for more details).

I've also updated toolchain downloader code to bubble up download errors, which previously were hidden and made it very hard to diagnose these issues.

* Use SwiftWasm 5.5.0, bump version to 0.12.0

* Pin AHC to 1.8.0

* Pin AHC to 1.6.4, always remove downloaded archives

* Fix `defer` build issue
2021-11-24 17:14:42 +01:00
yonihemi 4514347a25
Update JavaScriptKit to v0.11.1 (#265)
* Update JavaScriptKit to v0.11.1

* Update static.zip URL
2021-11-23 17:02:41 +08:00
Max Desiatov 596730b005
Update dependencies, add support for SwiftWasm 5.5 (#263)
I've dropped support for Swift 5.2, and SwiftLint now requires Xcode 12.5.1, which is unavailable on macOS 10.15 with GitHub Actions. This makes it impossible to test with Swift 5.3 on CI, so I'm bumping the required version to Swift 5.4.

Resolves https://github.com/swiftwasm/carton/issues/262.

* Update dependencies, add support for SwiftWasm 5.5

* Bump dependencies in `.github/workflows/swift.yml`

* Add explicit dependency on `NIOFoundationCompat`

* Lower Splash version to 0.15 for Swift 5.3 compat

* Update DefaultToolchain.swift

* Update swift.yml

* Revert "Lower Splash version to 0.15 for Swift 5.3 compat"

This reverts commit 6e04a7f158.

* Require Swift 5.4 in `Package.swift`

* Update README.md

* Use older 5.5 snapshot, unblock tests on failure

* Update DefaultToolchain.swift

* Select correct CPU architecture when downloading

* Disable hanging test

* Use latest 5.5 toolchain

* Use 2021-11-16 snapshot of SwiftWasm 5.5

* Add missing linker flags, re-enable browser test

* Address PR feedback
2021-11-18 13:59:32 +01:00
Max Desiatov cdcdd7f82c
Disable `--enable-test-discovery` for old versions (#257) 2021-09-08 09:16:55 +01:00
Max Desiatov 6da6dade9f
Update JSKit and Tokamak versions in templates (#243) 2021-05-29 21:45:13 +01:00
Max Desiatov ae8015413b
Fix `carton dev` crashing with SO sanitizer (#239)
Previously, the file we need to include with the build to enable the stack overflow sanitizer was written as a temporary file. This didn't happen though on watcher rebuilds with `carton dev` and caused crashes when a code line containing `try!` relying on this file to be present was executed.

I think it's easier and more efficient to bundle this file in the `static.zip` file that already includes our JS entrypoints. We require `static.zip` to be downloaded and unpacked successfully into `~/.carton/static` before every build anyway. It makes more sense to sense the sanitizer file in `~/.carton/static/so_sanitizer.wasm` and use that instead writing and deleting it at a temporary path on every build.

I've also updated the JSKit dependency and cleaned up some linter warnings by moving large tuple values into a separate `BuildDescription` type.
2021-05-24 12:03:38 +01:00
Yuta Saito 1acf9c3ad7
Integrate stack sanitizer (#230)
* Update WasmTransformer

* Add build flavor to determine build options

* Enable stack overflow sanitizer pass

* Embed import entry in binary

* Remove sanitize support from bundle command

* Update WasmTransformer and add --stack-first option

* Fix carton-release hash-archive for CartonKit renaming

* Run carton-release hash-archive

* Update WasmTransformer

* Use run-p

* Use matrix in CI

* Build and install pre-released resource

* Exclude fixture directory from linting

* Fix failing tests

* Turn off sanitizer on test command
2021-04-18 16:45:10 +09:00
thecb4 4b062aef86
Add tests for `sdk versions` and `sdk local` commands (#218)
* Added tests for version and local

* Debugging versions tests on ci

* Added brew install for swiftenv

* Changed fetchAllSwiftVersions to return empty array if .swiftenv/versions doesnt exist

* Remove commented out code. Removed debug flag for versions test

* Removed swiftenv from Brewfile

Co-authored-by: thecb4 <cavelle@tehcb4.io>
2021-02-01 20:27:37 -05:00
thecb4 c9250c3b01
Add test for `carton sdk install` (#217)
* Added test for sdk install

* Removed commented out code

Co-authored-by: thecb4 <cavelle@tehcb4.io>
2021-01-29 16:01:36 -05:00
yonihemi 4ef7b5339e
Use libSwiftPM instead of custom model types (#194)
* Use libSwiftPM instead of custom model types #120

* Update SwiftPM dependencies

* Add wrapper to handle discrepancy between encoded and decoded Manifest

* Try to fix 5.2 dependency resolving

* Try to fix 5.2 dependency resolving

Co-authored-by: Max Desiatov <max@desiatov.com>
2021-01-20 23:31:16 +08:00
Max Desiatov 116840c746
Fix browser testing for Safari, update tasks.json (#202)
* Fix browser testing for Safari, update tasks.json

* Remove autodiff code from `TestApp/main.swift`
2021-01-04 06:52:07 -05:00
thecb4 d7352b5a25
Add Dev tests and fix hard coded paths (#192)
* Added Dev tests and fixed hard coded paths, fixes #183

* Fixed Path dependency in 5.2 Package

* Removed mxcl/Path dependency

* Removed mxcl/Path dependency, Added confirmation of file existence in Init test

* Added sdk install head of init command test

* Moved carton sdk install to static setup method for tests

* Moved carton sdk install to static setup method for tests

* Moved carton sdk install to static setup method for tests

* Moved carton sdk install to static setup method for tests

* Moved carton sdk install to static setup method for tests

* changed order of actions for github automations to support testing

* modified test run to exclude release

* changed sdk install to run per test

* adjusted github workflows to create carton sdk folders

* adjusted github workflows to use /home/runner instead of root

* adjusted test to wait for sdk installation

* adjusted ubuntu tests for passing

* adjusted Dockerfile to run tests

* added tmate session for debugging

* Removed tmate session, added directory creation for carton sdk and sym link

* Adjusted order of commands for runner

* Fixed mkdir from worker to runner

* Added more terminal output for debugging

* Added more terminal output for debugging

* Added more terminal output for debugging

* Added more terminal output for debugging

* Added more terminal output for debugging

* Fixed hard coded paths

* Removed test investigation fixtures

* Removed test investigation fixtures

Co-authored-by: thecb4 <cavelle@tehcb4.io>
2020-12-24 03:49:28 -05:00
Max Desiatov ac19a7e868
Fix parsing system targets in `Package.swift` (#189)
This will unblock making CI work in TokamakUI/Tokamak#333.
2020-12-17 13:09:10 +00:00
Jed Fox 1af4f5a6d0
Add support for Chrome and Safari stack traces (#186) 2020-12-07 15:31:29 -05:00
Max Desiatov 646ce1c2e1
Bump versions of libraries in `Template.swift` (#182) 2020-12-04 11:41:01 +00:00
Max Desiatov 09a4e67e9e
Serve main bundle resources from root directory (#176)
This is required to make the `Image` view work as described in https://github.com/TokamakUI/Tokamak/pull/155#issuecomment-723677472.

* Demangle and print Firefox stacktraces in terminal

* Update the entrypoints archive URL, rename file

* Add missing newline to `ProcessRunner.swift`

* Remove redundant `console.log` call from `dev.js`

* Detect destination env from `User-Agent` header

* Silence linter in tests where it can't be avoided

* Add support for basic testing in browsers

* Add a browser message on finish, shut down server

* Serve main bundle resources from root directory

* Fix archive hashes, bump JSKit in TestApp to 0.9.0

* Add comments to clarify behavior

* Fix typo in doc comment in `Package.swift`
2020-12-01 16:20:46 +00:00
Max Desiatov ef402e71e8
Use FileDownloadDelegate from the AHC package (#171)
`FileDownloadDelegate` was introduced in https://github.com/swift-server/async-http-client/pull/275, which almost directly mirrors the implementation in `carton`. Now that it's available in a released version of AHC, let's delete some code here and replace it with the version from that package.
2020-12-01 11:05:15 +00:00
Max Desiatov 1c15282114
Bump JSKit, add support for testing in browsers (#173)
Resolves https://github.com/swiftwasm/carton/issues/42.

Also updates JavaScriptKit dependency to 0.9.0.

* Demangle and print Firefox stacktraces in terminal

* Update the entrypoints archive URL, rename file

* Add missing newline to `ProcessRunner.swift`

* Remove redundant `console.log` call from `dev.js`

* Detect destination env from `User-Agent` header

* Silence linter in tests where it can't be avoided

* Add support for basic testing in browsers

* Add a browser message on finish, shut down server

* Update JavaScriptKit to 0.9.0
2020-12-01 11:04:37 +00:00
Max Desiatov 377aa7617a
Demangle and print Firefox stack traces in terminal (#162)
This currently supports only Firefox, parsing of stack traces for other browsers will be added in separate PRs.

Resolves a part of #26.

* Demangle and print Firefox stacktraces in terminal

* Update the entrypoints archive URL, rename file

* Add missing newline to `ProcessRunner.swift`

* Remove redundant `console.log` call from `dev.js`

* Detect destination env from `User-Agent` header

* Silence linter in tests where it can't be avoided

* Remove use of grey color in stacktrace output
2020-11-27 11:49:39 +00:00
Yuta Saito d13e7bad2e
Support system installed toolchain (#157)
* Support system installed toolchain

* Fix linux build

* Apply latest swiftformat

* Apply suggestions from code review

Co-authored-by: Max Desiatov <max@desiatov.com>

* Update Sources/SwiftToolchain/ToolchainResolver.swift

Co-authored-by: Max Desiatov <max@desiatov.com>

Co-authored-by: Max Desiatov <max@desiatov.com>
2020-11-07 21:29:00 +09:00
Max Desiatov ac97210433
Fix handling of test bundles with .wasm extension (#153)
After https://github.com/apple/swift-package-manager/pull/3013 was merged and cherry-picked for our 5.3 snapshots (starting with `wasm-5.3-SNAPSHOT-2020-11-02-a`), `carton test` needs to handle the `.wasm` extension in test products.
2020-11-05 21:34:59 +00:00
Max Desiatov cbc04fb4f0
Build only test product and its deps for testing (#150)
Every Swift package with test targets has an implicit test product with `"\(package.name)PackageTests"` name. `swift build --build-tests` builds all products in a given package including the implicit test product. This doesn't work in situations where some of the products can't be compiled for Wasm, even when they are excluded with `condition: .when(platforms: [.macOS, .linux])` from test dependencies. This prevents tests from being built at all in such packages. OpenCombine is the primary victim of this problem.

Fortunately, the implicit test product can be accessed through the `--product` option passed to `swift build`. When using that option, only the test product and its dependencies are built. Products (and therefore their underlying targets) that aren't needed for tests are excluded from such builds. We should explicitly pass `--product` option to `swift build` instead of `--build-tests` in the `carton test` implementation to resolve the issue.

I've also added a new task to `tasks.json` that I previously used for testing `carton dev -v`.

`Dockerfile` has been updated to use the same toolchain as it does in `DefaultToolchain.swift`.

* Build only test product and its deps for testing

* Reuse product name interpolation

* Update `Dockerfile`
2020-11-02 13:52:33 +00:00
Max Desiatov 8f140d05f3
Apply formatting w/ latest version of SwiftFormat 2020-11-01 17:13:28 +00:00
Yuta Saito 0ee05ba7a9
Update toolchain and remove extra compiler flags (#147)
* Update toolchain version and remove extra compiler flags

* Ignore .swiftpm
2020-10-31 16:57:52 +09:00
Max Desiatov b1f01a437b
Fix handling of binaries with `.wasm` extension (#148)
Latest toolchains produce binaries with the `.wasm` extension which `carton` can't handle yet.
2020-10-30 16:50:59 +00:00
Carson Katri 1e286b4828
Pretty print `carton test` output (#144) 2020-10-28 11:06:55 -04:00
Yuta Saito 88a8e956f4
Stop using destination.json (#141)
* Remove unnecessary linker flags

* Remove destination json

* Import CoreFoundation explicitly to link it

* Remove Destination.swift model file

* Restore triple option

* Update default toolchain

* Workaround until https://github.com/swiftwasm/swift/pull/2097

* Revert "Workaround until https://github.com/swiftwasm/swift/pull/2097"

This reverts commit 285d2ae7aa.

* Update toolchain version

* Warn use of --destination

* Apply suggestions from code review

Co-authored-by: Max Desiatov <max@desiatov.com>

Co-authored-by: Max Desiatov <max@desiatov.com>
2020-10-28 19:57:28 +09:00
Max Desiatov ea810786d4
Make `checkAndLog` look in Xcode toolchains path 2020-10-22 17:58:38 +01:00
Max Desiatov 566e3419e2
Bump JavaScriptKit to 0.8, stop checking revision (#139)
Other than a simple bump, we shouldn't check for the revision anymore. Now the recommended way to specify this dependency is only with a semantic version constraint.
2020-10-22 15:49:45 +01:00
Max Desiatov 55013181aa
Add support for signed `.pkg` archives on macOS (#137)
`carton` can't install toolchains from `.pkg` archives at the moment, and the latest toolchain snapshots are distributed exclusively as signed `.pkg` for macOS.

Parts of `ToolchainManagement.swift` related to toolchain installation were moved to `ToolchainInstallation.swift`.

* Add support for signed `.pkg` archives on macOS

* Bump toolchain version to `2020-10-21`
2020-10-22 15:48:56 +01:00
Max Desiatov 4635766c61
Fix support for Ubuntu 20.04, use GHA for SwiftLint (#134)
Resolves #114.

As support for SwiftLint in Danger seems a bit buggy (causing duplicate warning comments sometimes), this PR calls SwiftLint through a separate action that displays warnings only in the PR diff and hopefully in better way.

* Add support for Ubuntu 20.04

* Refine formatting

* Move SwiftLint to a separate GitHub Action

* Fix linker warnings

* Remove `danger.yml` and `Dangerfile.swift`

* Remove `--strict` argument from `swiftlint.yml`

* Update README.md
2020-10-21 14:27:50 +01:00
Max Desiatov 08956baf1d
Add separate Builder class, use WasmTransformer (#131)
Resolves #127.

* Add separate Builder class, use WasmTransformer

* Don't apply the transformer in non-browser environments

* Fix macOS Swift 5.2 build failure

* Fix Package.swift errors

* Fix cyclic dependency in `Package.swift`

* Bump WasmTransformer requirement to 0.0.1

* Rename `case wasmer` to `case other`
2020-10-21 08:48:03 +01:00
Max Desiatov 703078dd83
Bump toolchain, use `--enable-test-discovery` (#130)
In the latest 5.3 toolchain all known issues with IndexStoreDB and SwiftPM support were resolved.

Resolves the second point of #42.

Thanks to this you no longer need to maintain `LinuxMain.swift` and `XCTestManifests.swift` files in your test suites, so these are deleted from the test app `Tests` directory.
2020-10-20 09:29:25 +01:00
Max Desiatov fc14c28f0c
Fix sysroot typo in `ToolchainManagement.swift` 2020-10-19 09:56:07 +01:00
Max Desiatov 567baac2d5
Bump default toolchain, make i64 bug reproducible (#128)
`TestApp/.swift-version` is removed as it was mostly duplicating the default toolchain version. Downloads of recent toolchains is fixed now with the new `macos` tarball suffix that replaces `osx`. `TestApp/main.swift` is updated to make #127 easily reproducible.
2020-10-14 22:00:42 +01:00
Carson Katri 97a7e4fbac
Pretty print diagnostics (#122) 2020-10-14 07:26:31 -04:00