Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiimk committed Feb 8, 2024
1 parent 33947fa commit 464bbe0
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ jobs:
include:
- runs-on: ubuntu-latest
target: x86_64-unknown-linux-musl
# - runs-on: macos-14
# target: aarch64-apple-darwin
image-arch: linux/amd64
- runs-on: macos-14
target: aarch64-apple-darwin
image-arch: linux/arm/v8
name: Build
runs-on: ${{ matrix.runs-on }}
steps:
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: test_macos
on:
workflow_dispatch: {}
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
target: x86_64-unknown-linux-musl
image-platform: linux/amd64

- runs-on: ubuntu-latest
target: aarch64-unknown-linux-musl
image-platform: linux/arm/v8

# Cross-compiles from Intel Mac to arm64
# We can compile natively for arm64 using macos-14 runner,
# but M1 processors of macos-14 runner don't support docker.
# See: https://github.com/marketplace/actions/setup-docker-on-macos#arm64-processors-m1-m2-m3-series-used-on-macos-14-images-are-unsupported
# See: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
- runs-on: macos-12
target: aarch64-apple-darwin
image-platform: linux/arm/v8
name: Build
runs-on: ${{ matrix.runs-on }}
steps:
- name: Setup variables
run: |
TAG=v0.0.0
VERSION=${TAG#v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "IMAGE=ghcr.io/kamu-data/engine-datafusion:$VERSION" >> $GITHUB_ENV
- name: Install docker (macOS)
if: contains(matrix.runs-on, 'macos-')
# See: https://blog.netnerds.net/2022/11/docker-macos-github-actions/
run: |
brew install docker docker-buildx
mkdir -p ~/.docker/cli-plugins
ln -sfn /usr/local/opt/docker-buildx/bin/docker-buildx ~/.docker/cli-plugins/docker-buildx
colima start
- name: Install musl (linux)
if: contains(matrix.target, '-musl')
# See: https://blog.urth.org/2023/03/05/cross-compiling-rust-projects-in-github-actions/
run: |
sudo apt-get update --yes
sudo apt-get install --yes musl-tools
- uses: actions/checkout@v4

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

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

- name: Build binary
run: |
# cargo build --release --target ${{ matrix.target }}
- name: Build image
run: |
docker buildx build \
--platform ${{ matrix.image-platform }} \
--build-arg target_arch=${{ matrix.target }} \
--build-arg version=${{ env.VERSION }} \
-t ${{ env.IMAGE }} \
-f image/Dockerfile \
.
42 changes: 42 additions & 0 deletions .github/workflows/test2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: test_macos2
on:
push: {}
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
target: x86_64-unknown-linux-musl
image-platform: linux/amd64
- runs-on: ubuntu-latest
target: aarch64-unknown-linux-musl
image-platform: linux/arm/v8
name: Build
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4

- 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: Build image
run: |
make image PLATFORM=${{ matrix.image-platform }} 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 }}
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PLATFORM = linux/amd64
TARGET_ARCH = x86_64-unknown-linux-musl
ENGINE_VERSION = $(shell cargo metadata --format-version 1 | jq -r '.packages[] | select( .name == "kamu-engine-datafusion") | .version')
ENGINE_IMAGE_TAG = $(ENGINE_VERSION)
Expand Down Expand Up @@ -27,15 +28,15 @@ test:
# Build
###############################################################################

# Do not use except for local testing - release images are built via CI
.PHONY: build
build:
RUSTFLAGS="" cross build --release --target $(TARGET_ARCH)


.PHONY: image
image: build
image:
docker build \
--platform $(PLATFORM) \
--build-arg target_arch=$(TARGET_ARCH) \
--build-arg version=$(ENGINE_VERSION) \
-t $(ENGINE_IMAGE) \
Expand Down

0 comments on commit 464bbe0

Please sign in to comment.