From 0481c36644bd4b064060f7bf5017d3aede3ba44d Mon Sep 17 00:00:00 2001 From: "Jiaxiao (mossaka) Zhou" Date: Thu, 12 Dec 2024 07:55:20 +0000 Subject: [PATCH] .github: reorganize the github action files 1. Renamed workflows to follow a consistent naming convention (`action-*`) 2. Extracted reusable workflows Signed-off-by: Jiaxiao (mossaka) Zhou --- .../{build.yaml => action-build.yaml} | 0 .github/workflows/action-check.yml | 24 +++++++ ...ush.yaml => action-docker-build-push.yaml} | 1 + ...taller.yaml => action-node-installer.yaml} | 0 .github/workflows/action-test.yml | 51 +++++++++++++ .github/workflows/ci.yaml | 71 ++----------------- .github/workflows/release.yaml | 6 +- 7 files changed, 86 insertions(+), 67 deletions(-) rename .github/workflows/{build.yaml => action-build.yaml} (100%) create mode 100644 .github/workflows/action-check.yml rename .github/workflows/{docker-build-push.yaml => action-docker-build-push.yaml} (99%) rename .github/workflows/{node-installer.yaml => action-node-installer.yaml} (100%) create mode 100644 .github/workflows/action-test.yml diff --git a/.github/workflows/build.yaml b/.github/workflows/action-build.yaml similarity index 100% rename from .github/workflows/build.yaml rename to .github/workflows/action-build.yaml diff --git a/.github/workflows/action-check.yml b/.github/workflows/action-check.yml new file mode 100644 index 00000000..c2eecc60 --- /dev/null +++ b/.github/workflows/action-check.yml @@ -0,0 +1,24 @@ +name: Run Check + +on: + workflow_call: +env: + CARGO_TERM_COLOR: always + +jobs: + check: + name: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt, clippy + - run: + rustup toolchain install nightly --component rustfmt + - name: Setup build env + run: | + make setup + - name: fmt + run: | + make fmt \ No newline at end of file diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/action-docker-build-push.yaml similarity index 99% rename from .github/workflows/docker-build-push.yaml rename to .github/workflows/action-docker-build-push.yaml index 05dfd552..fb785b13 100644 --- a/.github/workflows/docker-build-push.yaml +++ b/.github/workflows/action-docker-build-push.yaml @@ -6,6 +6,7 @@ on: description: 'Is this a test run?' type: boolean required: true + jobs: build_and_push: permissions: diff --git a/.github/workflows/node-installer.yaml b/.github/workflows/action-node-installer.yaml similarity index 100% rename from .github/workflows/node-installer.yaml rename to .github/workflows/action-node-installer.yaml diff --git a/.github/workflows/action-test.yml b/.github/workflows/action-test.yml new file mode 100644 index 00000000..60921470 --- /dev/null +++ b/.github/workflows/action-test.yml @@ -0,0 +1,51 @@ +name: Run Check + +on: + workflow_call: + runs-on: ubuntu-latest + env: + ARCH: x86_64 + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - uses: azure/setup-kubectl@v4 + - uses: fermyon/actions/spin/setup@v1 + with: + version: "v2.7.0" + + - name: Setup build env + run: | + make setup + + - name: Extract containerd-shim-spin-linux-${{ env.ARCH }} + run: | + mkdir -p ./bin + for f in containerd-shim-spin-*-linux-${{ env.ARCH }}/containerd-shim-spin-*-linux-${{ env.ARCH }}.tar.gz + do tar -xzf "$f" -C ./bin + done + + - name: install k3d + run: make install-k3d + + - name: run integration tests + run: BIN_DIR="./bin" IS_CI=true make integration-tests + + - name: run collect debug logs + if: failure() + run: make tests/collect-debug-logs + + - name: upload debug logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: debug-logs + path: debug-logs/ + retention-days: 5 + + - name: Output runner storage on failure + if: failure() + run: df -h + + - name: clean up k3d + if: always() + run: make tests/clean diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ac37eb2d..8c504855 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,29 +12,16 @@ env: CARGO_TERM_COLOR: always jobs: rustfmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - with: - workspaces: | - "containerd-shim-* -> target" - - run: - rustup toolchain install nightly --component rustfmt - - name: Setup build env - run: | - make setup - - name: fmt - run: | - make fmt + uses: ./.github/workflows/action-check.yml + build: + uses: ./.github/workflows/action-build.yaml build-wasm-images: - uses: ./.github/workflows/docker-build-push.yaml + uses: ./.github/workflows/action-docker-build-push.yaml + needs: build with: test: true - build: - uses: ./.github/workflows/build.yaml publish-node-installer-image: - uses: ./.github/workflows/node-installer.yaml + uses: ./.github/workflows/action-node-installer.yaml needs: build # This action requires use of the GITHUB_TOKEN to publish the image # 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: ref: ${{ github.ref }} test: needs: build - runs-on: ubuntu-latest - env: - ARCH: x86_64 - steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 - - uses: azure/setup-kubectl@v4 - - uses: fermyon/actions/spin/setup@v1 - with: - version: "v2.7.0" - - - name: Setup build env - run: | - make setup - - - name: Extract containerd-shim-spin-linux-${{ env.ARCH }} - run: | - mkdir -p ./bin - for f in containerd-shim-spin-*-linux-${{ env.ARCH }}/containerd-shim-spin-*-linux-${{ env.ARCH }}.tar.gz - do tar -xzf "$f" -C ./bin - done - - - name: install k3d - run: make install-k3d - - - name: run integration tests - run: BIN_DIR="./bin" IS_CI=true make integration-tests - - - name: run collect debug logs - if: failure() - run: make tests/collect-debug-logs - - - name: upload debug logs - if: failure() - uses: actions/upload-artifact@v4 - with: - name: debug-logs - path: debug-logs/ - retention-days: 5 - - name: Output runner storage on failure - if: failure() - run: df -h - - name: clean up k3d - if: always() - run: make tests/clean + uses: ./.github/workflows/action-test.yml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b3accd8d..5af83620 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -7,15 +7,15 @@ on: - "v[0-9]+.[0-9]+.*" jobs: build: - uses: ./.github/workflows/build.yaml + uses: ./.github/workflows/action-build.yaml build-and-push-wasm-images: - uses: ./.github/workflows/docker-build-push.yaml + uses: ./.github/workflows/action-docker-build-push.yaml with: test: false publish-node-installer-image: - uses: ./.github/workflows/node-installer.yaml + uses: ./.github/workflows/action-node-installer.yaml needs: build with: ref: ${{ github.ref }}