Skip to content
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
17 changes: 7 additions & 10 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
[env]
COMPILE_ENV = { value = "compile-env", relative = true, force = false }
PATH = { value = "compile-env/bin", relative = true, force = true }
LIBCLANG_PATH = { value = "compile-env/lib", relative = true, force = true }
PKG_CONFIG_PATH = { value = "compile-env/sysroot/x86_64-unknown-linux-gnu/release/lib/pkgconfig", relative = true, force = true }
DATAPLANE_SYSROOT = { value = "sysroot", relative = true, force = false }
C_INCLUDE_PATH = { value = "sysroot/include", relative = true, force = false }
LIBRARY_PATH = { value = "sysroot/lib", relative = true, force = false }
GW_CRD_PATH = { value = "devroot/src/gateway/config/crd/bases", relative = true, force = false }
PKG_CONFIG_PATH = { value = "sysroot/lib/pkgconfig", relative = true, force = false }
LIBCLANG_PATH = { value = "devroot/lib", relative = true, force = false }

[build]
target = "x86_64-unknown-linux-gnu"
rustc = "compile-env/bin/rustc"
rustflags = ["--cfg", "tokio_unstable"]

[target.x86_64-unknown-linux-gnu]
runner = ["scripts/test-runner.sh"]
rustflags = ["--cfg=tokio_unstable"]
8 changes: 8 additions & 0 deletions .cargo/cross/aarch64/gnu.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[env]
CC = { value = "aarch64-unknown-linux-gnu-clang", relative = false, force = true }

[build]
target = "aarch64-unknown-linux-gnu"

[target.aarch64-unknown-linux-gnu]
rustflags = ["--cfg=tokio_unstable", "-Clinker=aarch64-unknown-linux-gnu-clang", "-Clink-arg=-fuse-ld=lld"]
8 changes: 8 additions & 0 deletions .cargo/cross/aarch64/musl.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[env]
CC = { value = "aarch64-unknown-linux-musl-clang", relative = false, force = true }

[build]
target = "aarch64-unknown-linux-musl"

[target.aarch64-unknown-linux-musl]
rustflags = ["--cfg=tokio_unstable", "-Clinker=aarch64-unknown-linux-musl-clang", "-Clink-arg=-fuse-ld=lld"]
8 changes: 8 additions & 0 deletions .cargo/cross/x86_64/gnu.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[env]
CC = { value = "x86_64-unknown-linux-gnu-clang", relative = false, force = true }

[build]
target = "x86_64-unknown-linux-gnu"

[target.x86_64-unknown-linux-gnu]
rustflags = ["--cfg=tokio_unstable", "-Clinker=x86_64-unknown-linux-gnu-clang", "-Clink-arg=-fuse-ld=lld"]
8 changes: 8 additions & 0 deletions .cargo/cross/x86_64/musl.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[env]
CC = { value = "x86_64-unknown-linux-musl-clang", relative = false, force = true }

[build]
target = "x86_64-unknown-linux-musl"

[target.x86_64-unknown-linux-musl]
rustflags = ["--cfg=tokio_unstable", "-Clinker=x86_64-unknown-linux-musl-clang", "-Clink-arg=-fuse-ld=lld"]
1 change: 1 addition & 0 deletions .clangd
5 changes: 5 additions & 0 deletions .config/nix/nix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
max-jobs = 4
experimental-features = nix-command
substituters = https://dnoland-test-cache.cachix.org/ https://cache.nixos.org https://cache.nixos.org/
trusted-public-keys = dnoland-test-cache.cachix.org-1:AsVLS3c7NGIJbUHW5xOlK69zPEzY5jNF+ax0jd1LKUA= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be changed right?

always-allow-substitutes = true
48 changes: 2 additions & 46 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,46 +1,2 @@
export PROJECT_DIR="$(pwd)"

if [ -h "${PROJECT_DIR}/compile-env" ] || [ -d "${PROJECT_DIR}/compile-env" ]; then
export PATH="${PROJECT_DIR}/compile-env/bin:$PATH"
export LIBCLANG_PATH="${PROJECT_DIR}/compile-env/bin"
export COMPILE_ENV="${PROJECT_DIR}/compile-env"
else
>&2 echo "no compile environment found"
exit 0
fi

export NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1

CRT="-C target-feature=-crt-static"
DEBUG="-C debuginfo=full -C split-debuginfo=off -C dwarf-version=5"
LINKER="-C linker=${COMPILE_ENV}/bin/clang -C link-arg=--ld-path=${COMPILE_ENV}/bin/ld.lld"
RELRO="-C relro-level=full"
TARGET_CPU="-C target-cpu=x86-64-v3"

RUSTFLAGS="${CRT} ${DEBUG} ${LINKER} ${RELRO} ${TARGET_CPU}"

OPTIMIZE="-C opt-level=3 -C linker-plugin-lto -C lto=thin -C embed-bitcode=yes -C codegen-units=1"

case ${PROFILE:-DEBUG} in
fuzz|FUZZ)
COVERAGE="-C instrument-coverage"
DEBUG_ASSERTIONS="-C debug-assertions=on"
OVERFLOW_CHECK="-C overflow-checks=on"
RUSTFLAGS="${RUSTFLAGS} ${COVERAGE} ${DEBUG_ASSERTIONS} ${OVERFLOW_CHECK}"
;;
release|RELEASE)
RUSTFLAGS="${RUSTFLAGS} ${OPTIMIZE}"
;;
debug|DEBUG)
DEBUG_ASSERTIONS="-C debug-assertions=on"
OPTIMIZE="-C opt-level=0"
OVERFLOW_CHECK="-C overflow-checks=on"
RUSTFLAGS="${RUSTFLAGS} ${OPTIMIZE} ${DEBUG_ASSERTIONS} ${OVERFLOW_CHECK}"
;;
*)
>&2 echo "unknown profile"
exit 1
;;
esac

export RUSTFLAGS
export RUSTC_BOOTSTRAP=1
export PATH=$(pwd)/devroot/bin:$PATH
172 changes: 172 additions & 0 deletions .github/workflows/scratch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: "scratch.yml"

on:
pull_request: {}
push:
branches:
- "main"
tags:
- "v*"
merge_group:
types: ["checks_requested"]
workflow_dispatch:
inputs:
debug_enabled:
type: "boolean"
description: "Run with tmate enabled"
required: false
default: false
debug_justfile:
type: "boolean"
description: "enable to see debug statements from just recipes"
required: false
default: false
skip_vlab_tests:
type: "boolean"
description: "Skip VLAB tests (they run by default)"
required: false
default: false
run_hlab_tests:
type: "boolean"
description: "Run hybrid HLAB tests"
required: false
default: false
enable_release_tests:
type: "boolean"
description: "Enable release tests for VLAB/HLAB tests"
required: false
default: false

concurrency:
group: "${{ github.workflow }}:${{ github.event.pull_request.number || github.event.after || github.event.merge_group && github.run_id }}"
cancel-in-progress: true

permissions:
contents: "read"
packages: "write"
id-token: "write"

jobs:
check:
env:
CACHE_REGISTRY: "run.h.hhdev.io:30000"
UPSTREAM_REGISTRY: "ghcr.io"
USER: "runner"
permissions:
checks: "write"
pull-requests: "write"
contents: "read"
packages: "write"
id-token: "write"
strategy:
fail-fast: false
matrix:
profile:
- name: "debug"
cargo_name: "dev"
- name: "release"
cargo_name: "release"
debug_justfile:
- "${{ inputs.debug_justfile || false }}"
name: "${{matrix.profile.name}}"
runs-on: "lab"
timeout-minutes: 120
steps:
- name: "install nix"
uses: "cachix/install-nix-action@v31"
with:
nix_path: nixpkgs=channel:nixpkgs-unstable

- name: "login to ghcr.io"
uses: "docker/login-action@v3"
with:
registry: "${{ env.UPSTREAM_REGISTRY }}"
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"

- name: "login to image cache"
uses: "docker/login-action@v3"
with:
registry: "${{ env.CACHE_REGISTRY }}"
username: "${{ secrets.LAB_REGISTRY_USERNAME }}"
password: "${{ secrets.LAB_REGISTRY_TOKEN }}"

- name: "Checkout"
uses: "actions/checkout@v6"
with:
persist-credentials: "false"
fetch-depth: "0"

- name: "log into cachix"
uses: cachix/cachix-action@v14
with:
name: "${{ vars.CACHIX_CACHE_NAME }}"
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
useDaemon: true

- name: "sysroot"
run: |
nix build \
--log-format raw \
--argstr profile ${{matrix.profile.name}} \
--show-trace \
--max-jobs 3 \
--file default.nix \
sysroot \
--out-link sysroot

- name: "devroot"
run: |
nix build \
--log-format raw \
--argstr profile ${{matrix.profile.name}} \
--show-trace \
--max-jobs 3 \
--file default.nix \
devroot \
--out-link devroot

- name: "bins"
run: |
for pkg in dataplane cli init; do
nix build --file default.nix \
--log-format raw \
--argstr profile ${{matrix.profile.name}} \
--show-trace \
--max-jobs 3 \
packages.dataplane \
--out-link "packages.${pkg}"
done

- name: "cargo nextest"
run: |
export PATH="$(pwd)/devroot/bin:$PATH"
nix shell --file default.nix devroot --command \
cargo nextest archive --cargo-profile ${{matrix.profile.cargo_name}} --archive-file tests.tar.zst
# nix shell --file default.nix devroot --command \
# cargo nextest run --archive-file tests.tar.zst

- name: "run doctests"
run: |
nix shell --file default.nix devroot --command \
cargo test --profile=${{matrix.profile.cargo_name}} --doc

- id: "clippy"
name: "run clippy"
run: |
nix shell --file default.nix shell --command \
cargo clippy --profile ${{matrix.profile.cargo_name}} --all-targets --all-features -- -D warnings

- id: "docs"
name: "run rustdoc"
run: |
nix shell --file default.nix devroot --command \
sh -c 'RUSTDOCFLAGS="-D warnings" cargo doc --profile=${{matrix.profile_name}} --no-deps'

- name: "Setup tmate session for debug"
# if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: "mxschmitt/action-tmate@v3"
timeout-minutes: 120
with:
limit-access-to-actor: true
Loading
Loading