Skip to content

Commit

Permalink
Merge branch 'main' into node20
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Oct 20, 2024
2 parents 03b3d4d + 37dfb61 commit b0b68c1
Show file tree
Hide file tree
Showing 282 changed files with 14,275 additions and 13,423 deletions.
4 changes: 2 additions & 2 deletions .github/.kodiak.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ notify_on_conflict = false
# Without this, only branches that are passing CI will get updated.
# The benefit of this config is that PRs that we want to automerge, but
# have failed because the test suite is flaky will get stuck, unless someone
# presses the Update Branch button manually, or re-triggers the Github workflow
# presses the Update Branch button manually, or re-triggers the GitHub workflow
# for tests again. This causes delays in getting easy PRs in.
always = true

Expand All @@ -28,7 +28,7 @@ always = true
# (i.e. PRs with the "pr: automerge" label, which is configured above).
# This label allows PR authors to keep their PR branch up-to-date without
# opting into Kodiak's automerge feature. This is useful if you want to use
# Github's AutoMerge feature instead.
# GitHub's AutoMerge feature instead.
autoupdate_label = "pr: autoupdate"

[merge.message]
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/turborepo-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:

- name: Run cargo clippy
run: |
cargo groups clippy turborepo-libraries --features rustls-tls -- --deny clippy::all
cargo clippy --workspace --features rustls-tls -- --deny clippy::all
- name: Run ast-grep lints
run: |
Expand Down Expand Up @@ -260,7 +260,7 @@ jobs:

- name: Run cargo check
run: |
cargo groups check turborepo-libraries
cargo check --workspace
rust_test:
needs: [rust_check]
Expand Down Expand Up @@ -308,8 +308,12 @@ jobs:
run: |
if [ -z "${RUSTC_WRAPPER}" ]; then
unset RUSTC_WRAPPER
fi
cargo groups test turborepo-libraries
fi
if [ "$RUNNER_OS" == "Windows" ]; then
cargo test --workspace --exclude turborepo-napi
else
cargo test --workspace
fi
shell: bash
env:
SCCACHE_BUCKET: turborepo-sccache
Expand Down
43 changes: 32 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Thanks for your interest in contributing to Turbo!

- [Rust](https://www.rust-lang.org/tools/install)
- [cargo-groups](https://github.com/nicholaslyang/cargo-groups)
- NodeJS v18
- npm v10.5.0 (note: this is determined by the GitHub Actions CI, when in doubt, look at what the runner is using)
- capnproto
- protoc

### Linux Dependencies

Expand All @@ -48,7 +52,8 @@ Turborepo uses `reqwest`, a Rust HTTP client, to make requests to the Turbo API.
implementations: `rustls` and `native-tls`. `rustls` is a pure Rust implementation of TLS, while `native-tls`
is a wrapper around OpenSSL. Turborepo allows users to select which implementation they want with the `native-tls`
and `rustls-tls` features. By default, the `rustls-tls` feature is selected---this is done so that `cargo build` works
out of the box. If you wish to select `native-tls`, you may do so by passing `--no-default-features --features native-tls`
out of the box. If you wish to select `native-tls`, you may do so by passing
`--no-default-features --features native-tls`
to the build command.

### Running Turborepo Tests
Expand All @@ -71,10 +76,6 @@ Then from the root directory, you can run:
```bash
pnpm test -- --filter=cli
```
- A single Go unit test (see more [in the Go docs](https://pkg.go.dev/cmd/go#hdr-Test_packages))
```bash
cd cli && go test ./[path/to/package/]
```
- Rust unit tests ([install `nextest` first](https://nexte.st/book/pre-built-binaries.html))
```bash
cargo nextest run -p turborepo-lib --features rustls-tls
Expand All @@ -96,6 +97,19 @@ Then from the root directory, you can run:

Note: this is not through turbo, so you'll have to build turbo yourself first.
- Updating Integration Tests
```
turbo run build --filter=cli
pnpm --filter turborepo-tests-integration test:interactive
```
You can pass a test name to run a single test, or a directory to run all tests in that directory.
```
pnpm --filter turborepo-tests-integration test:interactive tests/turbo-help.t
```
- Example tests
```bash
pnpm test -- --filter=turborepo-tests-examples -- <example-name> <packagemanager>
Expand All @@ -104,15 +118,17 @@ Then from the root directory, you can run:
## Debugging Turborepo
1. Install `go install github.com/go-delve/delve/cmd/dlv@latest`
1. In VS Code's "Run and Debug" tab, select `Build Basic` to start debugging the initial launch of `turbo` against the `build` target of the Basic Example. This task is configured in [launch.json](./.vscode/launch.json).
1. In VS Code's "Run and Debug" tab, select `Build Basic` to start debugging the initial launch of `turbo` against the
`build` target of the Basic Example. This task is configured in [launch.json](./.vscode/launch.json).
## Benchmarking Turborepo
Follow the instructions in the [`benchmark/README.md`](./benchmark/README.md).
## Updating `turbo`
You might need to update `packages/turbo` in order to support a new platform. When you do that you will need to link the module in order to be able to continue working. As an example, with `npm link`:
You might need to update `packages/turbo` in order to support a new platform. When you do that you will need to link the
module in order to be able to continue working. As an example, with `npm link`:
```sh
cd ~/repos/vercel/turbo/packages/turbo
Expand Down Expand Up @@ -146,8 +162,10 @@ Here's a checklist of testing strategies to cover:
There are also multiple installation scenarios worth testing:
- Global-only. `turbo` is installed as global binary, no local `turbo` in repository.
- Local-only. `turbo` is installed as local binary, no global `turbo` in PATH. turbo` is invoked via a root package script.
- Global + local. `turbo` is installed as global binary, and local `turbo` in repository. Global `turbo` delegates to local `turbo`
- Local-only. `turbo` is installed as local binary, no global `turbo` in PATH. turbo` is invoked via a root package
script.
- Global + local. `turbo` is installed as global binary, and local `turbo` in repository. Global `turbo` delegates to
local `turbo`
Here are a few repositories that you can test on:
Expand All @@ -164,15 +182,18 @@ See [the publishing guide](./release.md#release-turborepo).
## Creating a new release blog post
Creating a new release post can be done via a turborepo generator. Run the following command from anywhere within the repo:
Creating a new release post can be done via a turborepo generator. Run the following command from anywhere within the
repo:
```bash
turbo generate run "blog - release post"
```
This will walk you through creating a new blog post from start to finish.
NOTE: If you would like to update the stats (github stars / npm downloads / time saved) for an existing blog post that has yet to be published (useful if time has passed since the blog post was created, and up to date stats are required before publishing) - run:
NOTE: If you would like to update the stats (GitHub stars / npm downloads / time saved) for an existing blog post that
has yet to be published (useful if time has passed since the blog post was created, and up to date stats are required
before publishing) - run:
```bash
turbo generate run "blog - "blog - update release post stats"
Expand Down
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Turborepo is used by the world's leading companies. Check out the [Turborepo Sho

## Updates

Follow [@turborepo](https://x.com/turborepo) on X and for project updates.
Follow [@turborepo](https://x.com/turborepo) on X for project updates.

## Authors

Expand Down
2 changes: 1 addition & 1 deletion buildcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This project is rather cookbook combing various projects into one. Special to [o

## Docker

Docker images are available on both [Github](https://ghcr.io/goreleaser/goreleaser-cross) and [Docker hub](https://hub.docker.com/r/goreleaser/goreleaser-cross).
Docker images are available on both [GitHub](https://ghcr.io/goreleaser/goreleaser-cross) and [Docker hub](https://hub.docker.com/r/goreleaser/goreleaser-cross).

Images from version v1.17.4 are multi-arch. Supported host are listed in the table below

Expand Down
2 changes: 1 addition & 1 deletion crates/turbo-trace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
mod import_finder;
mod tracer;

pub use tracer::{TraceError, Tracer};
pub use tracer::{TraceError, TraceResult, Tracer};
2 changes: 1 addition & 1 deletion crates/turbo-trace/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main() -> Result<(), PathError> {
.map(|f| AbsoluteSystemPathBuf::from_unknown(&abs_cwd, f))
.collect();

let tracer = Tracer::new(abs_cwd, files, args.ts_config)?;
let tracer = Tracer::new(abs_cwd, files, args.ts_config);

let result = tracer.trace();

Expand Down
6 changes: 3 additions & 3 deletions crates/turbo-trace/src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ impl Tracer {
cwd: AbsoluteSystemPathBuf,
files: Vec<AbsoluteSystemPathBuf>,
ts_config: Option<Utf8PathBuf>,
) -> Result<Self, PathError> {
) -> Self {
let ts_config =
ts_config.map(|ts_config| AbsoluteSystemPathBuf::from_unknown(&cwd, ts_config));

let seen = HashSet::new();

Ok(Self {
Self {
files,
seen,
ts_config,
source_map: Rc::new(SourceMap::default()),
})
}
}

pub fn trace(mut self) -> TraceResult {
Expand Down
41 changes: 40 additions & 1 deletion crates/turborepo-api-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub trait CacheClient {
&self,
hash: &str,
artifact_body: impl tokio_stream::Stream<Item = Result<bytes::Bytes>> + Send + Sync + 'static,
body_len: usize,
duration: u64,
tag: Option<&str>,
token: &str,
Expand Down Expand Up @@ -372,6 +373,7 @@ impl CacheClient for APIClient {
&self,
hash: &str,
artifact_body: impl tokio_stream::Stream<Item = Result<bytes::Bytes>> + Send + Sync + 'static,
body_length: usize,
duration: u64,
tag: Option<&str>,
token: &str,
Expand Down Expand Up @@ -403,6 +405,7 @@ impl CacheClient for APIClient {
.header("Content-Type", "application/octet-stream")
.header("x-artifact-duration", duration.to_string())
.header("User-Agent", self.user_agent.clone())
.header("Content-Length", body_length)
.body(stream);

if allow_auth {
Expand Down Expand Up @@ -805,10 +808,11 @@ mod test {
use std::time::Duration;

use anyhow::Result;
use bytes::Bytes;
use turborepo_vercel_api_mock::start_test_server;
use url::Url;

use crate::{APIClient, Client};
use crate::{APIClient, CacheClient, Client};

#[tokio::test]
async fn test_do_preflight() -> Result<()> {
Expand Down Expand Up @@ -898,4 +902,39 @@ mod test {
let err = APIClient::handle_403(response).await;
assert_eq!(err.to_string(), "unknown status forbidden: Not authorized");
}

#[tokio::test]
async fn test_content_length() -> Result<()> {
let port = port_scanner::request_open_port().unwrap();
let handle = tokio::spawn(start_test_server(port));
let base_url = format!("http://localhost:{}", port);

let client = APIClient::new(
&base_url,
Some(Duration::from_secs(200)),
None,
"2.0.0",
true,
)?;
let body = b"hello world!";
let artifact_body = tokio_stream::once(Ok(Bytes::copy_from_slice(body)));

client
.put_artifact(
"eggs",
artifact_body,
body.len(),
123,
None,
"token",
None,
None,
)
.await?;

handle.abort();
let _ = handle.await;

Ok(())
}
}
1 change: 1 addition & 0 deletions crates/turborepo-auth/src/auth/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ mod tests {
> + Send
+ Sync
+ 'static,
_body_len: usize,
_duration: u64,
_tag: Option<&str>,
_token: &str,
Expand Down
1 change: 1 addition & 0 deletions crates/turborepo-auth/src/auth/sso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ mod tests {
> + Send
+ Sync
+ 'static,
_body_len: usize,
_duration: u64,
_tag: Option<&str>,
_token: &str,
Expand Down
3 changes: 2 additions & 1 deletion crates/turborepo-auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl Token {
/// * `valid_message_fn` - An optional callback that gets called if the
/// token is valid. It will be passed the user's email.
// TODO(voz): This should do a `get_user` or `get_teams` instead of the caller
// doing it. The reason we don't do it here is becuase the caller
// doing it. The reason we don't do it here is because the caller
// needs to do printing and requires the user struct, which we don't want to
// return here.
pub async fn is_valid<T: Client + TokenClient + CacheClient>(
Expand Down Expand Up @@ -431,6 +431,7 @@ mod tests {
> + Send
+ Sync
+ 'static,
_body_len: usize,
_duration: u64,
_tag: Option<&str>,
_token: &str,
Expand Down
1 change: 1 addition & 0 deletions crates/turborepo-cache/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl HTTPCache {
.put_artifact(
hash,
progress,
bytes,
duration,
tag.as_deref(),
&self.api_auth.token,
Expand Down
4 changes: 4 additions & 0 deletions crates/turborepo-ci/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ impl Vendor {
Self::infer().map(|v| v.name)
}

pub fn is(name: &str) -> bool {
Self::infer().map_or(false, |v| v.name == name)
}

pub fn get_constant() -> Option<&'static str> {
Self::infer().map(|v| v.constant)
}
Expand Down
Loading

0 comments on commit b0b68c1

Please sign in to comment.