Repository navigation
168 lines (144 loc) · 6.2 KB
/
Copy pathdep_code_checks.yml
File metadata and controls
168 lines (144 loc) · 6.2 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# Formatting and lints do not depend on the hypervisor, so they run once per
# OS instead of in every build job. The macOS build jobs lint macOS, because
# a separate job would add load to the shared Mac runners.
name: Code Checks
on:
workflow_call:
inputs:
docs_only:
description: Skip the checks when "true"
required: false
type: string
default: "false"
prime_cache:
description: >-
Run clippy from a cold target and save the caches. Skips it when the
caches are up to date.
required: false
type: boolean
default: false
permissions:
contents: read
jobs:
linux-checks:
if: ${{ inputs.docs_only == 'false' }}
timeout-minutes: ${{ fromJSON(vars.CODE_CHECKS_JOB_TIMEOUT || '30') }}
runs-on: ${{ fromJSON(format('["self-hosted", "Linux", "X64", "1ES.Pool=hld-kvm-amd", "JobId=linux-checks-{0}-{1}-{2}"]',
github.run_id,
github.run_number,
github.run_attempt)) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: hyperlight-dev/ci-setup-workflow@59673866360458f8dd035f4a9fa766aeebad2038 # v2.3.1
with:
just-version: "1.51"
- name: Install Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: 'src/js-host-api/package-lock.json'
# Priming builds cold, so the entry holds only what this commit needs.
- name: Rust cache
id: rust-cache
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
prefix-key: v1-rust
shared-key: code-checks-linux
lookup-only: ${{ inputs.prime_cache }}
save-if: ${{ inputs.prime_cache }}
# cargo-hyperlight builds a guest sysroot in each target directory it
# uses. rust-cache deletes everything that is not a dependency, both when
# it saves and when it restores a partial match, so the sysroots have
# their own cache, restored after it.
- name: Restore sysroot cache
id: sysroot-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
target/sysroot
target/hyperlight-js-runtime/sysroot
key: sysroot-code-checks-linux-${{ hashFiles('rust-toolchain.toml') }}
- name: Check whether the caches are up to date
id: prime
if: inputs.prime_cache
shell: bash
run: echo "skip=${{ steps.rust-cache.outputs.cache-hit == 'true' && steps.sysroot-cache.outputs.cache-hit == 'true' }}" >> "$GITHUB_OUTPUT"
- name: fmt
if: ${{ !inputs.prime_cache }}
run: just fmt-check
- name: clippy (debug)
if: steps.prime.outputs.skip != 'true'
run: just clippy debug
- name: clippy (release)
if: steps.prime.outputs.skip != 'true'
run: just clippy release
- name: Lint JS
if: ${{ !inputs.prime_cache }}
run: just lint-js
# A job step, not a post-job step, so the save runs before rust-cache's
# post-job cleanup deletes the sysroots.
- name: Save sysroot cache
if: ${{ inputs.prime_cache && steps.sysroot-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
target/sysroot
target/hyperlight-js-runtime/sysroot
key: ${{ steps.sysroot-cache.outputs.cache-primary-key }}
windows-checks:
if: ${{ inputs.docs_only == 'false' }}
timeout-minutes: ${{ fromJSON(vars.CODE_CHECKS_JOB_TIMEOUT || '30') }}
runs-on: ${{ fromJSON(format('["self-hosted", "Windows", "X64", "1ES.Pool=hld-win2025-amd", "JobId=windows-checks-{0}-{1}-{2}"]',
github.run_id,
github.run_number,
github.run_attempt)) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: hyperlight-dev/ci-setup-workflow@59673866360458f8dd035f4a9fa766aeebad2038 # v2.3.1
with:
just-version: "1.51"
- name: Rust cache
id: rust-cache
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
prefix-key: v1-rust
shared-key: code-checks-windows
lookup-only: ${{ inputs.prime_cache }}
save-if: ${{ inputs.prime_cache }}
- name: Restore sysroot cache
id: sysroot-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
target/sysroot
target/hyperlight-js-runtime/sysroot
key: sysroot-code-checks-windows-${{ hashFiles('rust-toolchain.toml') }}
- name: Check whether the caches are up to date
id: prime
if: inputs.prime_cache
shell: bash
run: echo "skip=${{ steps.rust-cache.outputs.cache-hit == 'true' && steps.sysroot-cache.outputs.cache-hit == 'true' }}" >> "$GITHUB_OUTPUT"
# Temporary workaround until hyperlight-host preserves the surrogate
# inside OUT_DIR. rust-cache removes it but retains build-script state.
# can be removed once a hyperlight-host with https://github.com/hyperlight-dev/hyperlight/pull/2038 is referenced.
- name: Invalidate cached Windows surrogate build
if: runner.os == 'Windows'
run: |
cargo clean -p hyperlight-host --profile dev
cargo clean -p hyperlight-host --profile release
- name: clippy (debug)
if: steps.prime.outputs.skip != 'true'
run: just clippy debug
- name: clippy (release)
if: steps.prime.outputs.skip != 'true'
run: just clippy release
- name: Save sysroot cache
if: ${{ inputs.prime_cache && steps.sysroot-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
target/sysroot
target/hyperlight-js-runtime/sysroot
key: ${{ steps.sysroot-cache.outputs.cache-primary-key }}