Repository navigation
100 lines (90 loc) · 3.99 KB
/
Copy pathsdk.yaml
File metadata and controls
100 lines (90 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# SPDX-FileCopyrightText: © 2025 Daniel Sharifi <daniel.sharifi@nearone.org>
# SPDX-FileCopyrightText: © 2025 Phala Network <dstack@phala.network>
#
# SPDX-License-Identifier: Apache-2.0
name: SDK tests
permissions:
contents: read
on:
push:
branches: [next, 'release/**']
pull_request:
branches: [next, 'release/**']
env:
CARGO_TERM_COLOR: always
jobs:
sdk-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
# The change detection below diffs against the base commit.
fetch-depth: 0
# Which files changed, decided here rather than with a workflow-level
# `paths:` filter.
#
# `sdk-tests` is a required status check. A workflow skipped by `paths:`
# reports nothing at all, so the check never arrives and the pull request
# waits on it forever -- the filter has to live inside a job that always
# runs and always reports. Everything expensive below is gated on this
# output; when nothing relevant moved the job costs a checkout and a diff.
#
# `dstack/` is in the pattern because `sdk/run-tests.sh` starts the
# simulator, which is built from that workspace -- these suites exercise
# the agent's wire surface, not just the client libraries. The whole
# directory rather than the simulator's dependency closure: the closure is
# a dozen crates deep and would go stale the first time a dependency
# moved, and a filter that silently stops covering something is worse than
# one that occasionally runs when it need not.
- name: Detect relevant changes
id: changes
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
if [ -z "$BASE_SHA" ]; then
echo "relevant=true" >> "$GITHUB_OUTPUT"
echo "push build: running everything"
exit 0
fi
changed=$(git diff --name-only "$BASE_SHA...HEAD")
echo "$changed"
if echo "$changed" | grep -qE '^(sdk/|dstack/|rust-toolchain\.toml|\.github/workflows/sdk\.yaml)'; then
echo "relevant=true" >> "$GITHUB_OUTPUT"
else
echo "relevant=false" >> "$GITHUB_OUTPUT"
echo "nothing this job covers changed"
fi
- name: Install Rust
uses: dtolnay/rust-toolchain@1.92.0
with:
components: clippy, rustfmt
# This additional target is needed for wasm32 compatibility check.
targets: wasm32-unknown-unknown, thumbv6m-none-eabi
# Both workspaces: `sdk/rust` for the SDK crates, and `dstack` for the
# release simulator that `sdk/run-tests.sh` builds before any suite runs.
# Without the second entry that build starts cold every time and is most
# of the job's wall time.
- name: Cache cargo
if: steps.changes.outputs.relevant == 'true'
uses: Swatinem/rust-cache@v2
with:
workspaces: |
sdk/rust
dstack
# Save only from pushes to protected branches; pull requests restore
# from those. This cache is about 1 GB, and one per pull request ref
# would quickly push the repository past its cache quota and evict
# the entries that are actually shared.
save-if: ${{ github.event_name == 'push' }}
- name: SDK tests
if: steps.changes.outputs.relevant == 'true'
run: cd sdk && ./run-tests.sh
- name: Verify WASM compilation
if: steps.changes.outputs.relevant == 'true'
# Ensures SDK types can be used in smart contracts
run: cargo check --manifest-path sdk/rust/Cargo.toml --target=wasm32-unknown-unknown -p dstack-sdk-types
- name: Verify no_std compatibility
if: steps.changes.outputs.relevant == 'true'
run: |
cargo test --manifest-path sdk/rust/Cargo.toml -p dstack-sdk-types --test no_std_test --no-default-features
cargo check --manifest-path sdk/rust/Cargo.toml -p no_std_check --target thumbv6m-none-eabi