Skip to content

Commit cecf64b

Browse files
authored
Introducing cargo-make to simplify build flow and unify local dev with CI (#302)
* Introducing cargo-make to simplify build flow and unify local dev with CI * Clippy * Remove -is postfix from cache keys * Use large executors * Rebuild
1 parent 8806ffc commit cecf64b

File tree

10 files changed

+333
-161
lines changed

10 files changed

+333
-161
lines changed

.github/workflows/ci.yaml

Lines changed: 33 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
toolchain: stable
4646
target: ${{ matrix.platform.target }}
4747
override: true
48+
- uses: davidB/rust-cargo-make@v1
4849
- name: Install Rust Target
4950
run: rustup target add ${{ matrix.platform.target }}
5051
- name: Install Protoc
@@ -66,26 +67,23 @@ jobs:
6667
~/.cargo/registry/cache/
6768
~/.cargo/git/db/
6869
target/
69-
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
70+
key: ${{ runner.os }}-cargo-release-${{ matrix.platform }}-${{ hashFiles('**/Cargo.lock') }}
7071
- name: Build Executables
71-
run: cargo build --release --target ${{ matrix.platform.target }} ${{ matrix.platform.build-config }}
72+
env:
73+
PLATFORM_OVERRIDE: ${{ matrix.platform }}
74+
run: cargo make build-release
7275
- name: Prepare Targets
73-
run: |
74-
cd target
75-
tar -cvf ${{ matrix.platform.target }}.tar \
76-
${{ matrix.platform.target }}/release/golem-shard-manager \
77-
${{ matrix.platform.target }}/release/worker-executor \
78-
${{ matrix.platform.target }}/release/golem-template-service \
79-
${{ matrix.platform.target }}/release/golem-worker-service \
80-
${{ matrix.platform.target }}/release/golem-template-compilation-service
76+
env:
77+
PLATFORM_OVERRIDE: ${{ matrix.platform }}
78+
run: cargo make package-release
8179
- uses: actions/upload-artifact@v4
8280
name: Upload Targets
8381
with:
8482
name: docker-targets-build-${{ env.PLATFORM_PAIR }}
8583
path: target/${{ matrix.platform.target }}.tar
8684
docker-publish:
8785
runs-on: ubuntu-latest
88-
needs: [docker-targets-build]
86+
needs: [ docker-targets-build ]
8987
if: github.event_name == 'push' && github.ref_type == 'tag'
9088
steps:
9189
- name: Checkout
@@ -213,7 +211,7 @@ jobs:
213211
tags: ${{ steps.meta-golem-router.outputs.tags }}
214212
labels: ${{ steps.meta-golem-router.outputs.labels }}
215213
unit-tests:
216-
runs-on: ubuntu-latest
214+
runs-on: ubuntu-latest-large
217215
steps:
218216
- name: Checkout
219217
uses: actions/checkout@v3
@@ -229,24 +227,25 @@ jobs:
229227
~/.cargo/registry/cache/
230228
~/.cargo/git/db/
231229
target/
232-
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}-is
230+
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
233231
- name: Setup Rust
234232
uses: actions-rs/toolchain@v1
235233
with:
236234
toolchain: stable
237235
override: true
236+
- uses: davidB/rust-cargo-make@v1
238237
- name: Install Protoc
239238
uses: arduino/setup-protoc@v1
240239
with:
241240
repo-token: ${{ secrets.GITHUB_TOKEN }}
242-
- name: Check formatting
243-
run: cargo fmt -- --check
244-
- name: Clippy
245-
run: cargo clippy -- -Dwarnings
241+
- name: Check formatting and clippy rules
242+
run: cargo make check
246243
- name: Unit tests
247-
run: cargo test --lib --bins --all-features
244+
run: cargo make unit-tests
245+
- name: Check that OpenAPI specs are up-to-date
246+
run: cargo make check-openapi
248247
worker-tests:
249-
runs-on: ubuntu-latest
248+
runs-on: ubuntu-latest-large
250249
steps:
251250
- name: Checkout
252251
uses: actions/checkout@v3
@@ -262,12 +261,13 @@ jobs:
262261
~/.cargo/registry/cache/
263262
~/.cargo/git/db/
264263
target/
265-
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}-is
264+
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
266265
- name: Setup Rust
267266
uses: actions-rs/toolchain@v1
268267
with:
269268
toolchain: stable
270269
override: true
270+
- uses: davidB/rust-cargo-make@v1
271271
- name: Install Protoc
272272
uses: arduino/setup-protoc@v1
273273
with:
@@ -277,54 +277,10 @@ jobs:
277277
with:
278278
redis-version: latest
279279
auto-start: false
280-
- name: "Worker Executor integration tests"
281-
run: WASMTIME_BACKTRACE_DETAILS=1 cargo test --package golem-worker-executor-base --test '*' -- --nocapture
282-
build:
283-
runs-on: ubuntu-latest
284-
steps:
285-
- name: Checkout
286-
uses: actions/checkout@v3
287-
with:
288-
submodules: recursive
289-
- uses: actions/cache@v3
290-
with:
291-
path: |
292-
~/.cargo/bin/
293-
~/.cargo/.crates2.json
294-
~/.cargo/.crates.toml
295-
~/.cargo/registry/index/
296-
~/.cargo/registry/cache/
297-
~/.cargo/git/db/
298-
target/
299-
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}-is
300-
- name: Setup Rust
301-
uses: actions-rs/toolchain@v1
302-
with:
303-
toolchain: stable
304-
override: true
305-
- name: Install Protoc
306-
uses: arduino/setup-protoc@v1
307-
with:
308-
repo-token: ${{ secrets.GITHUB_TOKEN }}
309-
- name: Build all
310-
# --release to minimize artifact size
311-
run: cargo build --release
312-
- name: Upload binaries
313-
uses: actions/upload-artifact@v4
314-
with:
315-
name: golem-binaries
316-
retention-days: 1
317-
path: |
318-
target/release/golem-template-service
319-
target/release/golem-worker-service
320-
target/release/golem-template-compilation-service
321-
target/release/golem-worker-service-yaml
322-
target/release/golem-template-service-yaml
323-
target/release/golem-shard-manager
324-
target/release/worker-executor
280+
- name: Worker Executor integration tests
281+
run: cargo make worker-executor-tests
325282
integration-tests:
326-
needs: [build]
327-
runs-on: ubuntu-latest
283+
runs-on: ubuntu-latest-large
328284
steps:
329285
- name: Checkout
330286
uses: actions/checkout@v3
@@ -340,12 +296,13 @@ jobs:
340296
~/.cargo/registry/cache/
341297
~/.cargo/git/db/
342298
golem-cli/target/
343-
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}-is
299+
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
344300
- name: Setup Rust
345301
uses: actions-rs/toolchain@v1
346302
with:
347303
toolchain: stable
348304
override: true
305+
- uses: davidB/rust-cargo-make@v1
349306
- name: Install Protoc
350307
uses: arduino/setup-protoc@v1
351308
with:
@@ -355,49 +312,17 @@ jobs:
355312
with:
356313
redis-version: latest
357314
auto-start: false
358-
- name: Download binaries
359-
uses: actions/download-artifact@v4
360-
with:
361-
name: golem-binaries
362-
path: ./target/debug/
363-
- name: Restore executable flag
364-
run: chmod a+x ./target/debug/*
365-
- name: Generate golem-template-service OpenAPI yaml
366-
run: ./target/debug/golem-template-service-yaml > ./target/golem-template-service.yaml
367-
- name: Generate golem-worker-service OpenAPI yaml
368-
run: ./target/debug/golem-worker-service-yaml > ./target/golem-worker-service.yaml
369-
- name: Merge openapi specs
370-
run: |
371-
cargo install [email protected]
372-
golem-openapi-client-generator merge --spec-yaml target/golem-template-service.yaml target/golem-worker-service.yaml --output-yaml target/golem-service.yaml
373-
- name: Check Golem OpenAPI yaml latest
374-
shell: bash
375-
run: |
376-
if diff openapi/golem-service.yaml target/golem-service.yaml >/dev/null 2>&1
377-
then
378-
echo "Latest Golem OpenAPI spec version detected."
379-
else
380-
echo "openapi/golem-service.yaml is not the same as produced by golem-service-yaml." 1>&2
381-
echo "Run ./scripts/generate-openapi-yaml.sh to generate new spec." 1>&2
382-
exit 1
383-
fi
384315
- name: Integration tests
385-
working-directory: golem-cli
386316
env:
387317
CI: true
388-
run: |
389-
cargo build
390-
RUST_LOG=info cargo test --test integration
318+
run: cargo make integration-tests
391319
- name: Sharding tests
392-
working-directory: golem-cli
393320
env:
394321
CI: true
395-
run: |
396-
cargo build
397-
RUST_LOG=info cargo test --test sharding
322+
run: cargo make sharding-tests
398323
timeout-minutes: 10
399324
publish:
400-
needs: [unit-tests, worker-tests, integration-tests]
325+
needs: [ unit-tests, worker-tests, integration-tests ]
401326
if: "startsWith(github.ref, 'refs/tags/v')"
402327
runs-on: ubuntu-latest
403328
steps:
@@ -415,30 +340,22 @@ jobs:
415340
~/.cargo/registry/cache/
416341
~/.cargo/git/db/
417342
target/
418-
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}-is
343+
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
419344

420345
- name: Setup Rust
421346
uses: actions-rs/toolchain@v1
422347
with:
423348
toolchain: stable
424349
override: true
350+
- uses: davidB/rust-cargo-make@v1
425351
- name: Install Protoc
426352
uses: arduino/setup-protoc@v1
427353
with:
428354
repo-token: ${{ secrets.GITHUB_TOKEN }}
429355
- id: get_version
430356
uses: battila7/get-version-action@v2
431-
- name: Publish Golem client
357+
- name: Publish all packages
432358
env:
433359
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
434-
run: |
435-
export VERSION="${{ steps.get_version.outputs.version-without-v }}"
436-
sed -i "s/0.0.0/$VERSION/g" golem-client/Cargo.toml
437-
cargo publish -p golem-client --all-features --allow-dirty
438-
- name: Publish Golem CLI
439-
env:
440-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
441-
run: |
442-
export VERSION="${{ steps.get_version.outputs.version-without-v }}"
443-
sed -i "s/0.0.0/$VERSION/g" golem-cli/Cargo.toml
444-
cargo publish -p golem-cli --all-features --allow-dirty
360+
VERSION: "${{ steps.get_version.outputs.version-without-v }}"
361+
run: cargo make publish

0 commit comments

Comments
 (0)