From 64d9f29ca96d7509e3d815d02052ef3551c82c19 Mon Sep 17 00:00:00 2001 From: vsoch Date: Sat, 17 Feb 2024 16:06:40 -0700 Subject: [PATCH] ci: add support to build and deploy fluence-controller Signed-off-by: vsoch --- .github/workflows/build-deploy.yaml | 43 +++++++++++++++++++++++++++-- .github/workflows/test.yaml | 43 +++++++++++++++++++++++------ 2 files changed, 74 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-deploy.yaml b/.github/workflows/build-deploy.yaml index c993aa9..575d2db 100644 --- a/.github/workflows/build-deploy.yaml +++ b/.github/workflows/build-deploy.yaml @@ -18,7 +18,7 @@ jobs: name: build fluence steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: ^1.19 @@ -45,7 +45,44 @@ jobs: - name: Deploy Container if: (github.event_name != 'pull_request') run: docker push ${{ env.container }} --all-tags - + + build-controller: + permissions: + packages: write + env: + container: ghcr.io/flux-framework/fluence-controller + runs-on: ubuntu-latest + name: build fluence-controller + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: ^1.19 + + - name: Build Containers + run: | + make prepare + make build REGISTRY=ghcr.io/flux-framework CONTROLLER_IMAGE=fluence-controller + + - name: Tag Release Image + if: (github.event_name == 'release') + run: | + tag=${GITHUB_REF#refs/tags/} + echo "Tagging and releasing ${{ env.container}}:${tag}" + docker tag ${{ env.container }}:latest ${{ env.container }}:${tag} + + - name: GHCR Login + if: (github.event_name != 'pull_request') + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Deploy Container + if: (github.event_name != 'pull_request') + run: docker push ${{ env.container }} --all-tags + build-sidecar: permissions: packages: write @@ -55,7 +92,7 @@ jobs: name: build sidecar steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: ^1.19 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3e24a33..de944a5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,30 +11,42 @@ on: jobs: build-fluence: + + # The scheduler and controller are built together with the hack script + # in the upstream scheduler-plugins env: container: ghcr.io/flux-framework/fluence + controller: ghcr.io/flux-framework/fluence-controller runs-on: ubuntu-latest name: build fluence steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: ^1.19 - name: Build Containers run: | make prepare - make build REGISTRY=ghcr.io/flux-framework SCHEDULER_IMAGE=fluence + make build REGISTRY=ghcr.io/flux-framework SCHEDULER_IMAGE=fluence CONTROLLER_IMAGE=fluence-controller - - name: Save Container - run: docker save ${{ env.container }} | gzip > fluence_latest.tar.gz + - name: Save Containers + run: | + docker save ${{ env.container }} | gzip > fluence_latest.tar.gz + docker save ${{ env.controller }} | gzip > fluence_controller_latest.tar.gz - name: Upload container artifact uses: actions/upload-artifact@v4 with: name: fluence path: fluence_latest.tar.gz - + + - name: Upload container artifact + uses: actions/upload-artifact@v4 + with: + name: fluence_controller + path: fluence_controller_latest.tar.gz + build-sidecar: env: container: ghcr.io/flux-framework/fluence-sidecar @@ -42,7 +54,7 @@ jobs: name: build sidecar steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: ^1.19 @@ -59,7 +71,7 @@ jobs: with: name: fluence_sidecar path: fluence_sidecar_latest.tar.gz - + test-fluence: needs: [build-fluence, build-sidecar] permissions: @@ -67,14 +79,15 @@ jobs: env: fluence_container: ghcr.io/flux-framework/fluence sidecar_container: ghcr.io/flux-framework/fluence-sidecar + controller_container: ghcr.io/flux-framework/fluence-controller runs-on: ubuntu-latest name: build fluence steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: - go-version: ^1.20 + go-version: ^1.19 - name: Download fluence artifact uses: actions/download-artifact@v4 @@ -88,11 +101,18 @@ jobs: name: fluence_sidecar path: /tmp + - name: Download fluence_controller artifact + uses: actions/download-artifact@v4 + with: + name: fluence_controller + path: /tmp + - name: Load Docker images run: | ls /tmp/*.tar.gz docker load --input /tmp/fluence_sidecar_latest.tar.gz docker load --input /tmp/fluence_latest.tar.gz + docker load --input /tmp/fluence_controller_latest.tar.gz docker image ls -a | grep fluence - name: Create Kind Cluster @@ -106,10 +126,12 @@ jobs: env: fluence: ${{ env.fluence_container }} sidecar: ${{ env.sidecar_container }} + controller: ${{ env.controller_container }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | kind load docker-image ${fluence} kind load docker-image ${sidecar} + kind load docker-image ${controller} - name: Test Fluence run: /bin/bash ./.github/test.sh @@ -122,6 +144,8 @@ jobs: docker tag ${{ env.fluence_container }}:latest ${{ env.fluence_container }}:${tag} echo "Tagging and releasing ${{ env.sidecar_container}}:${tag}" docker tag ${{ env.sidecar_container }}:latest ${{ env.sidecar_container }}:${tag} + echo "Tagging and releasing ${{ env.controller_container}}:${tag}" + docker tag ${{ env.controller_container }}:latest ${{ env.controller_container }}:${tag} # If we get here, tests pass, and we can deploy - name: GHCR Login @@ -137,3 +161,4 @@ jobs: run: | docker push ${{ env.fluence_container }} --all-tags docker push ${{ env.sidecar_container }} --all-tags + docker push ${{ env.controller_container }} --all-tags \ No newline at end of file