Skip to content

Commit 3f83fa4

Browse files
authored
Merge pull request #2 from anthropics/setup-artifactory-publishing
ci: add Artifactory publishing workflow
2 parents 2c22000 + 71f8658 commit 3f83fa4

8 files changed

Lines changed: 143 additions & 5 deletions

File tree

.github/workflows/publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Security notes:
2+
# - GitHub-owned actions (actions/checkout) use tag pins
3+
# - Third-party actions (jfrog/setup-jfrog-cli) are pinned to full commit SHAs
4+
# - Rust toolchain comes from the runner's pre-installed rustup
5+
# - The publish environment requires the anthropic-1.49.0 branch
6+
name: Publish to Artifactory
7+
8+
on:
9+
push:
10+
branches:
11+
- anthropic-1.49.0
12+
13+
permissions:
14+
contents: read
15+
id-token: write
16+
17+
jobs:
18+
publish:
19+
runs-on: ubuntu-latest
20+
environment: publish
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Setup Rust
25+
run: |
26+
rustup default stable
27+
rustup show
28+
29+
- name: Setup JFrog CLI
30+
uses: jfrog/setup-jfrog-cli@ff5cb544114ffc152db9cea1cd3d5978d5074946 # v4.5.11
31+
env:
32+
JF_URL: https://artifactory.infra.ant.dev
33+
with:
34+
oidc-provider-name: github
35+
oidc-audience: jfrog-github
36+
37+
- name: Configure Cargo
38+
run: |
39+
ARTIFACTORY_TOKEN=$(jf config show | grep "Access Token" | awk '{print $3}')
40+
mkdir -p ~/.cargo
41+
cat >> ~/.cargo/config.toml << EOF
42+
[registries.crates-internal]
43+
index = "sparse+https://artifactory.infra.ant.dev/artifactory/api/cargo/crates-internal/index/"
44+
credential-provider = ["cargo:token"]
45+
EOF
46+
# TODO: Consider adding crates-io source replacement through Artifactory proxy
47+
# once OIDC token read access to the crates-io proxy is confirmed.
48+
# For now, cargo resolves dependencies from public crates.io directly.
49+
cargo login --registry crates-internal <<< "Bearer ${ARTIFACTORY_TOKEN}"
50+
51+
- name: Publish tokio to Artifactory
52+
run: |
53+
cd tokio
54+
cargo publish --registry crates-internal --allow-dirty

ANTHROPIC.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Anthropic Tokio Fork
2+
3+
This is Anthropic's fork of [tokio](https://github.com/tokio-rs/tokio), published to our internal Artifactory registry as `crates-internal`.
4+
5+
## Version Convention
6+
7+
Versions follow the `+anthropic.N` suffix convention per `go/fork`:
8+
- `1.49.0+anthropic.1` = tokio 1.49.0 + stall detection feature
9+
10+
## Features Added
11+
12+
### `stall-detection`
13+
14+
Detects when a tokio worker thread is stalled (blocked in a task poll for too long) and reports diagnostics including stack traces via `tracing`.
15+
16+
```rust
17+
let rt = tokio::runtime::Builder::new_multi_thread()
18+
.enable_stall_detection()
19+
.stall_detection_poll_interval(Duration::from_millis(100))
20+
.stall_detection_escalation_threshold(Duration::from_secs(10))
21+
.build()
22+
.unwrap();
23+
```
24+
25+
## Publishing
26+
27+
Publishing happens automatically when changes are pushed to the `anthropic-1.49.0` branch. The GitHub Actions workflow uses OIDC authentication with Artifactory.
28+
29+
### Prerequisites
30+
31+
1. The `anthropics/tokio` repo must be added to the OIDC config in `anthropics/terraform-config`
32+
2. A `publish-cli` GitHub environment must be configured in repo settings
33+
3. The `jfrog/setup-jfrog-cli` action must be allowed in repo settings
34+
35+
## Using in the Monorepo
36+
37+
In the workspace `Cargo.toml`:
38+
39+
```toml
40+
[patch.crates-io]
41+
tokio = { version = "1.49.0+anthropic.1", registry = "crates-internal" }
42+
```

CLAUDE.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Anthropic Tokio Fork - Development Guide
2+
3+
## Version Bumping
4+
5+
Every PR merged to an `anthropic-*` branch MUST bump the `+anthropic.N` version suffix.
6+
Increment `N` by 1 from whatever the current value is.
7+
8+
### Files to update
9+
10+
All publishable crates need matching version suffixes:
11+
12+
- `tokio/Cargo.toml` - main tokio crate
13+
- `tokio-macros/Cargo.toml` - proc macros
14+
- `tokio-stream/Cargo.toml` - stream utilities
15+
- `tokio-test/Cargo.toml` - test utilities
16+
- `tokio-util/Cargo.toml` - additional utilities
17+
18+
Example: if current versions end in `+anthropic.3`, update them all to `+anthropic.4`.
19+
20+
### Version format
21+
22+
`<upstream_version>+anthropic.<N>`
23+
24+
Examples:
25+
- `1.49.0+anthropic.1` (first anthropic release based on tokio 1.49.0)
26+
- `1.49.0+anthropic.2` (second anthropic release)
27+
28+
The `+anthropic.N` suffix is a semver build metadata tag — it does not affect dependency resolution but uniquely identifies our builds in Artifactory.
29+
30+
## Publishing
31+
32+
Publishing to the `crates-internal` Artifactory registry happens automatically via GitHub Actions when changes are pushed to an `anthropic-*` branch. See `.github/workflows/publish.yml`.
33+
34+
## Stall Detection Feature
35+
36+
The `stall-detection` feature is our primary addition. See `ANTHROPIC.md` for user-facing documentation.
37+
38+
Key implementation files:
39+
- `tokio/src/runtime/stall_detection.rs` - monitor thread, signal handler, frame-pointer walker
40+
- `tokio/src/runtime/scheduler/multi_thread/worker.rs` - generation counter increments
41+
- `tokio/src/runtime/metrics/worker.rs` - WorkerMetrics fields
42+
- `tokio/src/runtime/builder.rs` - builder API methods

tokio-macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "tokio-macros"
44
# - Remove path dependencies
55
# - Update CHANGELOG.md.
66
# - Create "tokio-macros-x.y.z" git tag.
7-
version = "2.6.0"
7+
version = "2.6.0+anthropic.1"
88
edition = "2021"
99
rust-version = "1.71"
1010
authors = ["Tokio Contributors <team@tokio.rs>"]

tokio-stream/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "tokio-stream"
44
# - Remove path dependencies
55
# - Update CHANGELOG.md.
66
# - Create "tokio-stream-0.1.x" git tag.
7-
version = "0.1.17"
7+
version = "0.1.17+anthropic.1"
88
edition = "2021"
99
rust-version = "1.71"
1010
authors = ["Tokio Contributors <team@tokio.rs>"]

tokio-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "tokio-test"
44
# - Remove path dependencies
55
# - Update CHANGELOG.md.
66
# - Create "tokio-test-0.4.x" git tag.
7-
version = "0.4.4"
7+
version = "0.4.4+anthropic.1"
88
edition = "2021"
99
rust-version = "1.71"
1010
authors = ["Tokio Contributors <team@tokio.rs>"]

tokio-util/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "tokio-util"
44
# - Remove path dependencies
55
# - Update CHANGELOG.md.
66
# - Create "tokio-util-0.7.x" git tag.
7-
version = "0.7.17"
7+
version = "0.7.17+anthropic.1"
88
edition = "2021"
99
rust-version = "1.71"
1010
authors = ["Tokio Contributors <team@tokio.rs>"]

tokio/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name = "tokio"
66
# - README.md
77
# - Update CHANGELOG.md.
88
# - Create "v1.x.y" git tag.
9-
version = "1.49.0"
9+
version = "1.49.0+anthropic.1"
1010
edition = "2021"
1111
rust-version = "1.71"
1212
authors = ["Tokio Contributors <team@tokio.rs>"]

0 commit comments

Comments
 (0)