-
Notifications
You must be signed in to change notification settings - Fork 57
143 lines (133 loc) · 4.23 KB
/
Copy pathrust-ci.yml
File metadata and controls
143 lines (133 loc) · 4.23 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: CI
on:
pull_request:
push:
branches: [main]
env:
CARGO_TERM_COLOR: always
AGENT_RELAY_TELEMETRY_DISABLED: 1
jobs:
changes:
name: Detect change scope
runs-on: ubuntu-latest
outputs:
sdk_swift_only: ${{ steps.scope.outputs.sdk_swift_only }}
steps:
- id: scope
uses: actions/github-script@v7
with:
script: |
let files = [];
if (context.eventName === 'pull_request') {
const changed = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page: 100,
});
files = changed.map((file) => file.filename);
} else {
const comparison = await github.rest.repos.compareCommits({
owner: context.repo.owner,
repo: context.repo.repo,
base: context.payload.before,
head: context.sha,
});
files = (comparison.data.files || []).map((file) => file.filename);
}
const sdkSwiftOnly = files.length > 0 && files.every((file) => file.startsWith('packages/sdk-swift/'));
core.info(`Changed files (${files.length}): ${files.join(', ')}`);
core.setOutput('sdk_swift_only', sdkSwiftOnly ? 'true' : 'false');
rust-test:
name: Rust Tests (${{ matrix.os }})
needs: changes
if: needs.changes.outputs.sdk_swift_only != 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-bin: false
- name: Run Rust tests
run: cargo test
- name: Run Rust tests (release)
run: cargo test --release
rust-cross-compile:
name: Cross-compile check (${{ matrix.target }})
needs: changes
if: needs.changes.outputs.sdk_swift_only != 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
linker: aarch64-linux-gnu-gcc
packages: gcc-aarch64-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
cache-bin: false
- name: Install cross-compilation tools
if: matrix.packages
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.packages }}
- name: Cross-compile agent-relay-broker
run: cargo check --target ${{ matrix.target }} --bin agent-relay-broker
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: ${{ matrix.linker }}
rust-clippy:
name: Clippy (${{ matrix.os }})
needs: changes
if: needs.changes.outputs.sdk_swift_only != 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
with:
cache-bin: false
- run: cargo clippy -- -D warnings
rust-fmt:
name: Format
needs: changes
if: needs.changes.outputs.sdk_swift_only != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt -- --check
sdk-check:
name: SDK TypeScript Check
needs: changes
if: needs.changes.outputs.sdk_swift_only != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: scripts/post-publish-verify/retry-command.sh "SDK npm install" npm install
- run: npm run -w @agent-relay/sdk check