Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiimk committed Feb 9, 2024
1 parent 3f3b3aa commit da45de1
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: build
on:
push:
paths-ignore:
- "image/**"
- "**.md"
workflow_dispatch: {} # manual trigger
env:
RUST_LOG: "debug"
Expand Down
132 changes: 132 additions & 0 deletions .github/workflows/release_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: release_test
on:
push: {}
env:
REGISTRY_IMAGE: ghcr.io/kamu-data/engine-datafusion
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
target: x86_64-unknown-linux-musl
platform: linux/amd64
qemu: false
- runs-on: ubuntu-latest
target: aarch64-unknown-linux-musl
platform: linux/arm64
qemu: true
name: Build
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4

# Collects metadata about build for image labels
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
# TODOOOOOOOOOOO
tags: |
# use custom value instead of git tag
type=semver,pattern={{version}},value=v0.7.2
- name: Set up QEMU
if: matrix.qemu
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- uses: actions-rs/toolchain@v1
with:
target: ${{ matrix.target }}
override: true

- name: Install cross
run: cargo install cross --locked

- name: Build binary
run: |
# make build TARGET_ARCH=${{ matrix.target }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# See: https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
file: image/Dockerfile
platforms: ${{ matrix.platform }}
# TODOOOOOOOOOOOOOOOOO
build-args: |
target_arch=${{ matrix.target }}
version=0.7.2
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Prepare upload digest
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create --dry-run $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TARGET_ARCH = x86_64-unknown-linux-musl
IMAGE_PLATFORM = linux/amd64
PLATFORM = linux/amd64
CRATE_VERSION = $(shell cargo metadata --format-version 1 | jq -r '.packages[] | select( .name == "kamu-engine-datafusion") | .version')
IMAGE_TAG = $(CRATE_VERSION)
IMAGE = ghcr.io/kamu-data/engine-datafusion:$(IMAGE_TAG)
Expand Down Expand Up @@ -35,12 +35,13 @@ build:

.PHONY: image
image:
docker build \
--platform $(IMAGE_PLATFORM) \
docker buildx build \
--platform $(PLATFORM) \
--build-arg target_arch=$(TARGET_ARCH) \
--build-arg version=$(CRATE_VERSION) \
-t $(IMAGE) \
-f image/Dockerfile \
--load \
.


Expand Down
2 changes: 1 addition & 1 deletion image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN apk add --no-cache tini


# Engine
COPY target/${target_arch}/release/kamu-engine-datafusion /opt/engine/bin/kamu-engine-datafusion
# COPY target/${target_arch}/release/kamu-engine-datafusion /opt/engine/bin/kamu-engine-datafusion


ENV RUST_BACKTRACE=1
Expand Down

0 comments on commit da45de1

Please sign in to comment.