Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add Support for Buildless #2

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,108 @@ jobs:

${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"

buildless-cloud:
runs-on: ubuntu-latest
needs: build

env:
BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }}
RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache

steps:
- uses: actions/checkout@v4

- name: Install Buildless CLI
shell: bash
run: |
echo "Coming soon."

- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: "stable"

- uses: actions/download-artifact@v3
with:
name: integration-tests
path: /home/runner/.cargo/bin/
- name: Chmod for binary
run: chmod +x ${SCCACHE_PATH}

- name: Test
run: cargo clean && cargo build

- name: Output
run: |
${SCCACHE_PATH} --show-stats

${SCCACHE_PATH} --show-stats | grep buildless

- name: Test Twice for Cache Read
run: cargo clean && cargo build

- name: Output
run: |
${SCCACHE_PATH} --show-stats

${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"

buildless-agent:
runs-on: ubuntu-latest
needs: build

env:
BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }}
RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache

steps:
- uses: actions/checkout@v4

- name: Install Buildless
shell: bash
run: |
echo "Coming soon."

- name: Start Buildless Agent
shell: bash
run: |
echo "Coming soon."

- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: "stable"

- uses: actions/download-artifact@v3
with:
name: integration-tests
path: /home/runner/.cargo/bin/
- name: Chmod for binary
run: chmod +x ${SCCACHE_PATH}

- name: Test
run: cargo clean && cargo build

- name: Output
run: |
${SCCACHE_PATH} --show-stats

${SCCACHE_PATH} --show-stats | grep buildless

- name: Test Twice for Cache Read
run: cargo clean && cargo build

- name: Output
run: |
${SCCACHE_PATH} --show-stats

${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"

- name: Stop Buildless Agent
shell: bash
run: |
echo "Coming soon."

test-mock-msvc:
runs-on: windows-2019
env:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
edition = "2021"
name = "sccache"
rust-version = "1.67.1"
version = "0.7.4"
version = "0.7.5-buildless"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

released under a custom version, for now


categories = ["command-line-utilities", "development-tools::build-utils"]
description = "Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible, storing a cache in a remote storage using various cloud storage."
Expand Down Expand Up @@ -146,10 +146,18 @@ all = [
"memcached",
"gcs",
"azure",
"buildless",
"gha",
"webdav",
]
azure = ["opendal", "reqsign"]
buildless = ["opendal", "redis", "webdav"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since buildless implements webdav and redis, this code simply reuses those adapters to reduce code surface

buildless-client = [
"buildless",
"dist-client",
"native-zlib",
"vendored-openssl",
]
default = ["all"]
gcs = ["opendal", "reqsign", "url", "reqwest/blocking", "trust-dns-resolver"]
gha = ["opendal"]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Table of Contents (ToC)
* [Azure](docs/Azure.md)
* [GitHub Actions](docs/GHA.md)
* [WebDAV (Ccache/Bazel/Gradle compatible)](docs/Webdav.md)
* [Buildless (Agent, Cloud, or both)](docs/Buildless.md)

---

Expand Down Expand Up @@ -287,3 +288,4 @@ Storage Options
* [Azure](docs/Azure.md)
* [GitHub Actions](docs/GHA.md)
* [WebDAV (Ccache/Bazel/Gradle compatible)](docs/Webdav.md)
* [Buildless (Agent, Cloud, or both)](docs/Buildless.md)
112 changes: 112 additions & 0 deletions docs/Buildless.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Buildless

[Buildless][0] is a suite of build caching tools and a remote build caching cloud. It can be used with nearly any build
toolchain which supports caching, including SCCache, Gradle, Maven, Bazel, and TurboRepo.

Near-caching with the [Buildless Agent][1] is free forever for every user. Then, to share caches, link your CLI to the
[Buildless Cloud][2], where it can be shared with your teammates, vendors, customers, and more.

## Using SCCache with Buildless

The Buildless adapter for SCCache supports several transports and endpoint types:

- **[Buildless Agent][1]:** Local Buildless agent and near-cache
- **[Buildless Cloud][2]:** Cloud services for caching and configuration
- **[HTTPS][3]**, **[Redis][4]**, and **[GitHub Actions][5]**

Usually, you will want to use this in tandem with the [Buildless Agent][1], which acts as a near-cache and optimized
backhaul router when cloud services are enabled.

## Installation & Setup

Obtain a [release of `sccache`][6] from the Buildless team, or clone the fork and compile it with the instructions
below.

### Obtaining a release

Releases are [published on GitHub][6], and additionally bundled with the [Buildless CLI][1] (see `buildless sccache`).
Verification of releases can be performed via [Sigstore][9] and similar tools; for more details, see the
[CLI release notes][10].

1. Download a release from one of the sources above
2. Place it somewhere on your machine, make sure it is executable
3. (**Optional**): Install the [Buildless CLI][1] and run the [Buildless Agent][8]

### Building yourself

1. Clone or add the fork: `git clone git@github.com:buildless/sccache.git`
2. Checkout your desired branch
3. Build with: `cargo build --release --features=buildless-client`
4. Check that Buildless is enabled: `./target/release/sccache --help`, which should show:

```
Usage: sccache ...

Enabled features:
S3: false
Redis: true
Memcached: false
GCS: false
GHA: false
Azure: false
Buildless: true
```

> Native zlib and TLS are built-in when using this configuration.

## Usage

If you have an API key set at `BUILDLESS_APIKEY` ([docs][7]), the module will **activate automatically.**
The [Buildless Agent][8] is detected, if running, and used (unless disabled -- see _Agent Negotation_ below). Otherwise,
**you can set `SCCACHE_BUILDLESS`** to any value to force-enable the adapter.

See other environment variables below for customizing `sccache`'s behavior as it relates to Buildless.

| Environment Variable | Description |
|----------------------|----------------------------------------------------------------------------------------------|
| `SCCACHE_BUILDLESS` | Force-enables the Buildless backend, even with no API key or other credentials. |
| `BUILDLESS_APIKEY` | Automatically detected and set as the user's API key. Enables the module if detected. |
| `BUILDLESS_ENDPOINT` | Sets a custom endpoint for use by `sccache`. This should only be used in advanced scenarios. |
| `BUILDLESS_NO_AGENT` | Instructs `sccache` not to ever use the [Buildless Agent][8]. |

### Agent Negotiation

If the [Buildless Agent][8] is running on the local machine, it will be detected and used instead of the public
[Buildless Cloud service][2]. The agent can be configured to use edge services or not, and **does not require a license
or payment of any kind**. An account with Buildless Cloud is not required for local use.

Agent detection works with a "rendezvous file," defined at known path on each operating system. The file is typically
encoded in JSON and includes agent connection and protocol details.

### Buildless Cloud

If no agent is available, or if your agent is configured for Buildless Cloud services, it will automatically upload
cached objects asynchronously and pull cached objects from the cloud, via an optimized long-living connection.

### Transport Selection

Several transport types are available for use via the agent and via the Buildless Cloud, including **HTTPS**, **Redis**
(RESP), **gRPC**, and more. This adapter can use HTTPS or Redis.

Since the agent only supports HTTP at this time, it is used automatically when the agent is enabled. When using Cloud
servics directly, Redis is used, with HTTPS as a fallback. Buildless Cloud traffic is [always encrypted][11].

## Docs & Support

Find more documentation, including API reference docs, via the [Buildless Docs][12]. Support is also available for
paying users, and for free users on a best-effort basis, via the [Buildless Support][13] site.

[0]: https://less.build
[1]: https://docs.less.build/cli
[2]: https://less.build/resources/network
[3]: https://docs.less.build/reference/supported-api-interfaces
[4]: https://docs.less.build/docs/redis
[5]: https://docs.less.build/docs/github-actions
[6]: https://github.com/buildless/sccache
[7]: https://docs.less.build/docs/auth
[8]: https://docs.less.build/agent
[9]: https://sigstore.dev
[10]: https://github.com/buildless/cli/releases
[11]: https://www.ssllabs.com/ssltest/analyze.html?d=edge.less.build
[12]: https://less.build/docs
[13]: https://less.build/support
Loading
Loading