From 382de052d8272789b4b3620925e231ddf0a83294 Mon Sep 17 00:00:00 2001 From: Henrik Soerensen Date: Mon, 5 Aug 2024 11:27:34 -0400 Subject: [PATCH] WIP --- .github/workflows/build.yml | 19 ++++++++--------- .github/workflows/docker-publish.yml | 21 +++++++------------ bake.hcl | 31 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 bake.hcl diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5416741..1656b78 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,10 @@ name: build on: pull_request: - branches: [ main ] push: - branches: [ main ] + tags: + - '*' + workflow_dispatch: permissions: contents: read @@ -17,9 +18,9 @@ jobs: platform: [ linux/amd64, linux/arm64 ] steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 + uses: actions/setup-go@v5 with: go-version-file: 'go.mod' cache: true @@ -31,9 +32,7 @@ jobs: uses: docker/setup-buildx-action@v3 with: version: latest - - name: Build Docker Image - run: docker buildx build --platform ${{ matrix.platform }} -t voi-node:${{ matrix.platform }} --load . - - name: Run Tests in Docker Container - run: docker run --rm voi-node:${{ matrix.platform }} make test - - name: Build all - run: docker run --rm voi-node:${{ matrix.platform }} make all + - name: Run Bake + run: docker buildx bake --file bake.hcl --set *.platform=${{ matrix.platform }} --load + - name: Run Unit Tests + run: make test \ No newline at end of file diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 087029f..5f0ee37 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,22 +1,17 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# GitHub recommends pinning actions to a commit SHA. -# To get a newer version, you will need to update the SHA. -# You can also reference a tag or branch, but the action may change without warning. - name: Publish Docker image on: release: - types: [ published ] + types: [published] + workflow_dispatch: jobs: push_to_registries: name: Push Docker image to registry runs-on: ubuntu-latest + strategy: + matrix: + platform: [linux/amd64, linux/arm64] permissions: packages: write contents: read @@ -50,9 +45,9 @@ jobs: uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 with: context: . - platforms: linux/amd64,linux/arm64 + platforms: ${{ matrix.platform }} build-args: | BASE_ALGORAND_VERSION=3.25.0 - push: true + push: false tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/bake.hcl b/bake.hcl new file mode 100644 index 0000000..9f59014 --- /dev/null +++ b/bake.hcl @@ -0,0 +1,31 @@ +group "default" { + targets = ["build", "test", "all"] +} + +target "build" { + platforms = ["linux/amd64", "linux/arm64"] + tags = ["voi-node"] + context = "." + dockerfile = "Dockerfile" +} + +target "test" { + inherits = ["build"] + args = { + TARGET = "test" + } + commands = [ + "make test" + ] +} + +target "all" { + inherits = ["build"] + args = { + TARGET = "all" + } + + commands = [ + "make all" + ] +} \ No newline at end of file