Skip to content

Commit b4f8269

Browse files
authored
Merge pull request #998 from rust-lang/rustfmt
Migrate code formatting to the orchestrator
2 parents ece84a8 + 44fb0bd commit b4f8269

File tree

15 files changed

+576
-285
lines changed

15 files changed

+576
-285
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -101,50 +101,22 @@ jobs:
101101
uses: dtolnay/rust-toolchain@stable
102102
with:
103103
components: rustfmt
104-
- name: Cache Cargo intermediate products
105-
uses: actions/cache@v3
106-
with:
107-
path: |-
108-
~/.cargo/registry
109-
~/.cargo/git
110-
ui/target
111-
key: "${{ runner.os }}-cargo-${{ hashFiles('ui/**/Cargo.lock') }}-2"
112104
- name: Format server
113105
run: cargo fmt --manifest-path ui/Cargo.toml --all --check
114106
- name: Format top-crates
115107
run: cargo fmt --manifest-path top-crates/Cargo.toml --check
116108
- name: Format orchestrator
117109
run: cargo fmt --manifest-path compiler/base/orchestrator/Cargo.toml --check
118110
- name: Build backend
119-
run: |-
120-
mkdir -p ui/target; docker run --rm -v $PWD/compiler/base/asm-cleanup:/compiler/base/asm-cleanup -v $PWD/compiler/base/orchestrator:/compiler/base/orchestrator -v $PWD/compiler/base/modify-cargo-toml:/compiler/base/modify-cargo-toml -v $PWD/ui:/ui -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry --workdir /ui rust:alpine sh -c '
121-
apk add musl-dev openssl-dev openssl-libs-static
122-
123-
# Adding -C relocation-model=static due to
124-
# https://github.com/rust-lang/rust/issues/95926
125-
126-
# Adding this to find the statically-built version
127-
export OPENSSL_NO_PKG_CONFIG=1 OPENSSL_STATIC=1 OPENSSL_DIR=/usr/
128-
129-
# Unit tests
130-
cargo rustc --tests --locked -- -C relocation-model=static;
131-
132-
test_bin=$(find target/debug/deps/ -name "ui*" -type f -perm -a=x);
133-
mv "${test_bin}" target/unit_tests;
134-
135-
# Primary binary
136-
cargo rustc --locked --release -- -C relocation-model=static;
137-
mv target/release/ui target/ui;
138-
'
139-
- name: Restore permissions
140-
run: sudo chown -R runner:docker ~/.cargo/ ui/target
111+
run: "./ci/build-backend.sh"
141112
- name: Save backend artifact
142113
uses: actions/upload-artifact@v3
143114
with:
144115
name: backend
145116
path: |
146-
ui/target/ui
147-
ui/target/unit_tests
117+
docker-output/ui
118+
docker-output/unit_tests_ui
119+
docker-output/unit_tests_orchestrator
148120
build_frontend:
149121
name: Build frontend
150122
runs-on: ubuntu-latest
@@ -249,8 +221,13 @@ jobs:
249221
with:
250222
name: frontend
251223
path: tests/server/build/
252-
- name: Run unit tests
253-
run: chmod +x ./server/unit_tests && ./server/unit_tests
224+
- name: Run orchestrator unit tests
225+
env:
226+
TESTS_MAX_CONCURRENCY: 3
227+
TESTS_TIMEOUT_MS: 30000
228+
run: chmod +x ./server/unit_tests_orchestrator && ./server/unit_tests_orchestrator
229+
- name: Run ui unit tests
230+
run: chmod +x ./server/unit_tests_ui && ./server/unit_tests_ui
254231
- name: Run tests
255232
env:
256233
PLAYGROUND_UI_ROOT: server/build/

ci/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM rust:alpine
2+
3+
RUN apk add musl-dev openssl-dev openssl-libs-static
4+
5+
# Adding -C relocation-model=static due to
6+
# https://github.com/rust-lang/rust/issues/95926
7+
8+
# Adding this to find the statically-built version
9+
ENV OPENSSL_NO_PKG_CONFIG=1 OPENSSL_STATIC=1 OPENSSL_DIR=/usr/
10+
11+
RUN mkdir /output
12+
13+
COPY compiler/base/asm-cleanup /compiler/base/asm-cleanup
14+
COPY compiler/base/orchestrator /compiler/base/orchestrator
15+
COPY compiler/base/modify-cargo-toml /compiler/base/modify-cargo-toml
16+
COPY ui /ui
17+
18+
WORKDIR /compiler/base/orchestrator
19+
20+
RUN \
21+
cargo rustc --profile test --lib --locked -- --cfg force_docker -C relocation-model=static; \
22+
test_bin=$(find target/debug/deps/ -name "orchestrator*" -type f -perm -a=x); \
23+
mv "${test_bin}" /output/unit_tests_orchestrator;
24+
25+
WORKDIR /ui
26+
27+
RUN \
28+
cargo rustc --tests --locked -- -C relocation-model=static; \
29+
test_bin=$(find target/debug/deps/ -name "ui*" -type f -perm -a=x); \
30+
mv "${test_bin}" /output/unit_tests_ui;
31+
32+
RUN \
33+
cargo rustc --locked --release -- -C relocation-model=static; \
34+
mv target/release/ui /output/ui;

ci/Dockerfile.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*
2+
!compiler/base/asm-cleanup/**
3+
compiler/base/asm-cleanup/target
4+
!compiler/base/orchestrator/**
5+
compiler/base/orchestrator/target
6+
!compiler/base/modify-cargo-toml/**
7+
compiler/base/modify-cargo-toml/target
8+
!ui/**
9+
ui/frontend
10+
ui/target

ci/build-backend.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
IMAGE_NAME=backend-build
6+
OUTPUT_DIR=docker-output
7+
8+
docker build -t "${IMAGE_NAME}" -f ci/Dockerfile .
9+
10+
mkdir -p "${OUTPUT_DIR}"
11+
12+
container_id=$(docker create "${IMAGE_NAME}")
13+
for f in unit_tests_orchestrator unit_tests_ui ui; do
14+
docker cp "${container_id}:/output/${f}" "${OUTPUT_DIR}"
15+
done
16+
docker rm -f "${container_id}"

ci/workflows.yml

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,6 @@ workflows:
177177
with:
178178
components: rustfmt
179179

180-
- name: "Cache Cargo intermediate products"
181-
uses: actions/cache@v3
182-
with:
183-
path: |-
184-
~/.cargo/registry
185-
~/.cargo/git
186-
ui/target
187-
key: ${{ runner.os }}-cargo-${{ hashFiles('ui/**/Cargo.lock') }}-2
188-
189180
- name: "Format server"
190181
run: cargo fmt --manifest-path ui/Cargo.toml --all --check
191182

@@ -196,50 +187,16 @@ workflows:
196187
run: cargo fmt --manifest-path compiler/base/orchestrator/Cargo.toml --check
197188

198189
- name: "Build backend"
199-
run: >-
200-
mkdir -p ui/target;
201-
docker
202-
run
203-
--rm
204-
-v $PWD/compiler/base/asm-cleanup:/compiler/base/asm-cleanup
205-
-v $PWD/compiler/base/orchestrator:/compiler/base/orchestrator
206-
-v $PWD/compiler/base/modify-cargo-toml:/compiler/base/modify-cargo-toml
207-
-v $PWD/ui:/ui
208-
-v ~/.cargo/git:/root/.cargo/git
209-
-v ~/.cargo/registry:/root/.cargo/registry
210-
--workdir /ui
211-
rust:alpine
212-
sh -c '
213-
apk add musl-dev openssl-dev openssl-libs-static
214-
215-
# Adding -C relocation-model=static due to
216-
# https://github.com/rust-lang/rust/issues/95926
217-
218-
# Adding this to find the statically-built version
219-
export OPENSSL_NO_PKG_CONFIG=1 OPENSSL_STATIC=1 OPENSSL_DIR=/usr/
220-
221-
# Unit tests
222-
cargo rustc --tests --locked -- -C relocation-model=static;
223-
224-
test_bin=$(find target/debug/deps/ -name "ui*" -type f -perm -a=x);
225-
mv "${test_bin}" target/unit_tests;
226-
227-
# Primary binary
228-
cargo rustc --locked --release -- -C relocation-model=static;
229-
mv target/release/ui target/ui;
230-
'
231-
232-
- name: "Restore permissions"
233-
run: >-
234-
sudo chown -R runner:docker ~/.cargo/ ui/target
190+
run: ./ci/build-backend.sh
235191

236192
- name: "Save backend artifact"
237193
uses: actions/upload-artifact@v3
238194
with:
239195
name: backend
240196
path: |
241-
ui/target/ui
242-
ui/target/unit_tests
197+
docker-output/ui
198+
docker-output/unit_tests_ui
199+
docker-output/unit_tests_orchestrator
243200
244201
build_frontend:
245202
name: "Build frontend"
@@ -354,9 +311,16 @@ workflows:
354311
name: frontend
355312
path: tests/server/build/
356313

357-
- name: "Run unit tests"
314+
- name: "Run orchestrator unit tests"
315+
env:
316+
TESTS_MAX_CONCURRENCY: 3
317+
TESTS_TIMEOUT_MS: 30000
318+
run: |-
319+
chmod +x ./server/unit_tests_orchestrator && ./server/unit_tests_orchestrator
320+
321+
- name: "Run ui unit tests"
358322
run: |-
359-
chmod +x ./server/unit_tests && ./server/unit_tests
323+
chmod +x ./server/unit_tests_ui && ./server/unit_tests_ui
360324
361325
- name: "Run tests"
362326
env:

compiler/base/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ version = "=2.1.0"
560560

561561
[dependencies.hyper]
562562
package = "hyper"
563-
version = "=1.0.0"
563+
version = "=1.0.1"
564564
features = ["client", "full", "http1", "http2", "server"]
565565

566566
[dependencies.hyper_0_14_27]
@@ -1464,7 +1464,7 @@ version = "=0.7.26"
14641464

14651465
[dependencies.zeroize]
14661466
package = "zeroize"
1467-
version = "=1.6.1"
1467+
version = "=1.7.0"
14681468
default-features = false
14691469

14701470
[dependencies.zune_inflate]
@@ -2013,7 +2013,7 @@ version = "=2.1.0"
20132013

20142014
[build_dependencies.hyper]
20152015
package = "hyper"
2016-
version = "=1.0.0"
2016+
version = "=1.0.1"
20172017
features = ["client", "full", "http1", "http2", "server"]
20182018

20192019
[build_dependencies.hyper_0_14_27]
@@ -2917,7 +2917,7 @@ version = "=0.7.26"
29172917

29182918
[build_dependencies.zeroize]
29192919
package = "zeroize"
2920-
version = "=1.6.1"
2920+
version = "=1.7.0"
29212921
default-features = false
29222922

29232923
[build_dependencies.zune_inflate]

compiler/base/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- \
4444
-y \
4545
--profile minimal \
4646
--default-toolchain "${channel}" \
47-
--target wasm32-unknown-unknown
47+
--target wasm32-unknown-unknown \
48+
--component rustfmt
4849

4950
COPY --chown=playground entrypoint.sh /playground/tools/
5051

compiler/base/crate-information.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@
576576
},
577577
{
578578
"name": "hyper",
579-
"version": "1.0.0",
579+
"version": "1.0.1",
580580
"id": "hyper"
581581
},
582582
{
@@ -1561,7 +1561,7 @@
15611561
},
15621562
{
15631563
"name": "zeroize",
1564-
"version": "1.6.1",
1564+
"version": "1.7.0",
15651565
"id": "zeroize"
15661566
},
15671567
{

compiler/base/orchestrator/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/base/orchestrator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ tracing = { version = "0.1.37", default-features = false, features = ["attribute
2222
[dev-dependencies]
2323
assert_matches = "1.5.0"
2424
assertables = "7.0.1"
25+
once_cell = "1.18.0"
2526
tempdir = "0.3.7"
2627
tracing-subscriber = "0.3.17"

0 commit comments

Comments
 (0)