Skip to content

Commit 85f2982

Browse files
authored
Merge pull request #248 from spinkube/mossaka/setup-rust
ci: Update caching mechanism and refactor the actions
2 parents 574001c + febdfb1 commit 85f2982

File tree

7 files changed

+114
-92
lines changed

7 files changed

+114
-92
lines changed

.github/workflows/build.yaml renamed to .github/workflows/action-build.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,30 @@ jobs:
2121
ARCH: ${{ matrix.config.arch }}
2222
steps:
2323
- uses: actions/checkout@v4
24-
- uses: Swatinem/rust-cache@v2
24+
- uses: actions-rust-lang/setup-rust-toolchain@v1
2525
with:
26-
workspaces: |
27-
"containerd-shim-* -> target"
26+
cache-key: rust-cache-${{ matrix.config.os }}-${{ matrix.config.arch}}
2827
- name: Setup build env
2928
run: |
3029
make setup
31-
- name: build spin shim
30+
- name: Build spin shim
3231
run: |
3332
VERBOSE=1 make build
34-
- name: unit tests spin shim
33+
- name: Run unit tests spin shim
3534
run: |
3635
VERBOSE=1 make unit-tests
37-
- name: lowercase the runner OS name
36+
- name: Lowercase the runner OS name
3837
shell: bash
3938
run: |
4039
OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
4140
echo "RUNNER_OS=$OS" >> $GITHUB_ENV
42-
- name: package release assets
41+
- name: Package release assets
4342
run: |
4443
mkdir _dist
4544
cp target/${{ matrix.config.arch }}-unknown-linux-musl/release/containerd-shim-spin-v2 _dist/
4645
cd _dist
4746
tar czf containerd-shim-spin-v2-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz containerd-shim-spin-v2
48-
- name: upload shim artifacts
47+
- name: Upload shim artifacts
4948
uses: actions/upload-artifact@v4
5049
with:
5150
name: containerd-shim-spin-v2-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}

.github/workflows/action-check.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Run Check
2+
3+
on:
4+
workflow_call:
5+
env:
6+
CARGO_TERM_COLOR: always
7+
8+
jobs:
9+
check:
10+
name: check
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions-rust-lang/setup-rust-toolchain@v1
15+
with:
16+
components: rustfmt, clippy
17+
- name: Install nightly rustfmt
18+
run:
19+
rustup toolchain install nightly --component rustfmt
20+
- name: Setup build env
21+
run: |
22+
make setup
23+
- name: Run fmt
24+
run: |
25+
make fmt

.github/workflows/docker-build-push.yaml renamed to .github/workflows/action-docker-build-push.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
description: 'Is this a test run?'
77
type: boolean
88
required: true
9+
910
jobs:
1011
build_and_push:
1112
permissions:
@@ -32,29 +33,29 @@ jobs:
3233
echo "RUNNER_OS=$OS" >> $GITHUB_ENV
3334
- name: Set up QEMU
3435
uses: docker/setup-qemu-action@v3
35-
- name: setup buildx
36+
- name: Setup buildx
3637
uses: docker/setup-buildx-action@v3
37-
- name: login to GitHub container registry
38+
- name: Login to GitHub container registry
3839
uses: docker/login-action@v3
3940
with:
4041
registry: ghcr.io
4142
username: ${{ github.actor }}
4243
password: ${{ secrets.GITHUB_TOKEN }}
4344

44-
- name: enable containerd image store
45+
- name: Enable containerd image store
4546
run: |
4647
echo '{ "features": { "containerd-snapshotter": true } }' | sudo tee /etc/docker/daemon.json
4748
sudo systemctl restart docker
4849
49-
- name: test
50+
- name: Build and load (test run)
5051
uses: docker/build-push-action@v5
5152
if: ${{ inputs.test }}
5253
with:
5354
context: ${{ matrix.image.context }}
5455
load: true
5556
tags: containerd-shim-spin/${{ matrix.image.imageName }}:test
5657
platforms: wasi/wasm
57-
- name: build and push
58+
- name: Build and push
5859
uses: docker/build-push-action@v5
5960
if: ${{ !inputs.test }}
6061
with:

.github/workflows/node-installer.yaml renamed to .github/workflows/action-node-installer.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ jobs:
3535
- name: Set up QEMU
3636
uses: docker/setup-qemu-action@v3
3737

38-
- name: setup buildx
38+
- name: Setup buildx
3939
uses: docker/setup-buildx-action@v3
4040

41-
- name: login to GitHub container registry
41+
- name: Login to GitHub container registry
4242
uses: docker/login-action@v3
4343
with:
4444
registry: ghcr.io
@@ -47,14 +47,14 @@ jobs:
4747

4848
# Build and push node-installer image
4949
# TODO: remove once https://github.com/spinkube/runtime-class-manager handles this
50-
- name: untar musl artifacts into ./node-installer/.tmp/linux/(amd64|arm64) dir
50+
- name: Extract musl artifacts into ./node-installer/.tmp/linux/(amd64|arm64) dir
5151
run: |
5252
mkdir -p ./node-installer/.tmp/linux/amd64
5353
mkdir -p ./node-installer/.tmp/linux/arm64
5454
for f in ./_artifacts/*/*-x86_64.tar.gz; do tar -xf $f --directory ./node-installer/.tmp/linux/amd64; done
5555
for f in ./_artifacts/*/*-aarch64.tar.gz; do tar -xf $f --directory ./node-installer/.tmp/linux/arm64; done
5656
57-
- name: build and push node-installer image
57+
- name: Build and push node-installer image
5858
uses: docker/build-push-action@v5
5959
with:
6060
push: true
@@ -63,7 +63,7 @@ jobs:
6363
context: node-installer
6464
platforms: linux/amd64,linux/arm64
6565

66-
- name: clear
66+
- name: Clear
6767
if: always()
6868
run: |
6969
rm -f ${HOME}/.docker/config.json

.github/workflows/action-test.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Run Check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
env:
10+
ARCH: x86_64
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/download-artifact@v4
14+
- uses: azure/setup-kubectl@v4
15+
- uses: fermyon/actions/spin/setup@v1
16+
with:
17+
version: "v2.7.0"
18+
19+
- name: Setup build env
20+
run: |
21+
make setup
22+
23+
- name: Extract containerd-shim-spin-linux-${{ env.ARCH }}
24+
run: |
25+
mkdir -p ./bin
26+
for f in containerd-shim-spin-*-linux-${{ env.ARCH }}/containerd-shim-spin-*-linux-${{ env.ARCH }}.tar.gz
27+
do tar -xzf "$f" -C ./bin
28+
done
29+
30+
- name: Install k3d
31+
run: make install-k3d
32+
33+
- name: Run integration tests
34+
run: BIN_DIR="./bin" IS_CI=true make integration-tests
35+
36+
- name: Collect debug logs
37+
if: failure()
38+
run: make tests/collect-debug-logs
39+
40+
- name: Upload debug logs
41+
if: failure()
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: debug-logs
45+
path: debug-logs/
46+
retention-days: 5
47+
48+
- name: Output runner storage on failure
49+
if: failure()
50+
run: df -h
51+
52+
- name: Clean up k3d
53+
if: always()
54+
run: make tests/clean

.github/workflows/ci.yaml

Lines changed: 7 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,16 @@ env:
1212
CARGO_TERM_COLOR: always
1313
jobs:
1414
rustfmt:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- uses: actions/checkout@v4
18-
- uses: Swatinem/rust-cache@v2
19-
with:
20-
workspaces: |
21-
"containerd-shim-* -> target"
22-
- run:
23-
rustup toolchain install nightly --component rustfmt
24-
- name: Setup build env
25-
run: |
26-
make setup
27-
- name: fmt
28-
run: |
29-
make fmt
15+
uses: ./.github/workflows/action-check.yml
16+
build:
17+
uses: ./.github/workflows/action-build.yaml
3018
build-wasm-images:
31-
uses: ./.github/workflows/docker-build-push.yaml
19+
uses: ./.github/workflows/action-docker-build-push.yaml
20+
needs: build
3221
with:
3322
test: true
34-
build:
35-
uses: ./.github/workflows/build.yaml
3623
publish-node-installer-image:
37-
uses: ./.github/workflows/node-installer.yaml
24+
uses: ./.github/workflows/action-node-installer.yaml
3825
needs: build
3926
# This action requires use of the GITHUB_TOKEN to publish the image
4027
# By default, PRs from forks don't have access, so we only run when the PR branch is on origin.
@@ -43,48 +30,4 @@ jobs:
4330
ref: ${{ github.ref }}
4431
test:
4532
needs: build
46-
runs-on: ubuntu-latest
47-
env:
48-
ARCH: x86_64
49-
steps:
50-
- uses: actions/checkout@v4
51-
- uses: actions/download-artifact@v4
52-
- uses: azure/setup-kubectl@v4
53-
- uses: fermyon/actions/spin/setup@v1
54-
with:
55-
version: "v2.7.0"
56-
57-
- name: Setup build env
58-
run: |
59-
make setup
60-
61-
- name: Extract containerd-shim-spin-linux-${{ env.ARCH }}
62-
run: |
63-
mkdir -p ./bin
64-
for f in containerd-shim-spin-*-linux-${{ env.ARCH }}/containerd-shim-spin-*-linux-${{ env.ARCH }}.tar.gz
65-
do tar -xzf "$f" -C ./bin
66-
done
67-
68-
- name: install k3d
69-
run: make install-k3d
70-
71-
- name: run integration tests
72-
run: BIN_DIR="./bin" IS_CI=true make integration-tests
73-
74-
- name: run collect debug logs
75-
if: failure()
76-
run: make tests/collect-debug-logs
77-
78-
- name: upload debug logs
79-
if: failure()
80-
uses: actions/upload-artifact@v4
81-
with:
82-
name: debug-logs
83-
path: debug-logs/
84-
retention-days: 5
85-
- name: Output runner storage on failure
86-
if: failure()
87-
run: df -h
88-
- name: clean up k3d
89-
if: always()
90-
run: make tests/clean
33+
uses: ./.github/workflows/action-test.yml

.github/workflows/release.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ on:
77
- "v[0-9]+.[0-9]+.*"
88
jobs:
99
build:
10-
uses: ./.github/workflows/build.yaml
10+
uses: ./.github/workflows/action-build.yaml
1111

1212
build-and-push-wasm-images:
13-
uses: ./.github/workflows/docker-build-push.yaml
13+
uses: ./.github/workflows/action-docker-build-push.yaml
1414
with:
1515
test: false
1616

1717
publish-node-installer-image:
18-
uses: ./.github/workflows/node-installer.yaml
18+
uses: ./.github/workflows/action-node-installer.yaml
1919
needs: build
2020
with:
2121
ref: ${{ github.ref }}
@@ -41,14 +41,14 @@ jobs:
4141
with:
4242
path: _artifacts
4343

44-
- name: copy release workload assets into _dist
44+
- name: Copy release workload assets into _dist
4545
if: startsWith(github.ref, 'refs/tags/v')
4646
run: |
4747
mkdir -p _dist
4848
cp ./deployments/workloads/runtime.yaml _dist/runtime.yaml
4949
cp ./deployments/workloads/workload.yaml _dist/workload.yaml
5050
51-
- name: create release
51+
- name: Create release
5252
if: startsWith(github.ref, 'refs/tags/v')
5353
env:
5454
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -63,25 +63,25 @@ jobs:
6363
- name: Set up QEMU
6464
uses: docker/setup-qemu-action@v3
6565

66-
- name: setup buildx
66+
- name: Setup buildx
6767
uses: docker/setup-buildx-action@v3
6868

69-
- name: login to GitHub container registry
69+
- name: Login to GitHub container registry
7070
uses: docker/login-action@v3
7171
with:
7272
registry: ghcr.io
7373
username: ${{ github.actor }}
7474
password: ${{ secrets.GITHUB_TOKEN }}
7575

7676
# Build and push k3d shim image
77-
- name: untar musl artifacts into ./deployments/k3d/.tmp/linux/(amd64|arm64) dir
77+
- name: Extract musl artifacts into ./deployments/k3d/.tmp/linux/(amd64|arm64) dir
7878
run: |
7979
mkdir -p ./deployments/k3d/.tmp/linux/amd64
8080
mkdir -p ./deployments/k3d/.tmp/linux/arm64
8181
for f in ./_artifacts/*/*-x86_64.tar.gz; do tar -xf $f --directory ./deployments/k3d/.tmp/linux/amd64; done
8282
for f in ./_artifacts/*/*-aarch64.tar.gz; do tar -xf $f --directory ./deployments/k3d/.tmp/linux/arm64; done
8383
84-
- name: build and push k3d shim image
84+
- name: Build and push k3d shim image
8585
uses: docker/build-push-action@v5
8686
with:
8787
push: true
@@ -92,7 +92,7 @@ jobs:
9292
build-args: |
9393
STAGE=release
9494
95-
- name: clear
95+
- name: Clear
9696
if: always()
9797
run: |
9898
rm -f ${HOME}/.docker/config.json

0 commit comments

Comments
 (0)