diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6f976b7..b700c26 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..3ab6f5c --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,71 @@ +name: test_macos +on: + push: {} +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - runs-on: ubuntu-latest + target: x86_64-unknown-linux-musl + image-platform: linux/amd64 + + # 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 + - runs-on: macos-13 + target: aarch64-apple-darwin + image-platform: linux/arm/v8 + name: Build + runs-on: ${{ matrix.runs-on }} + steps: + - name: Setup variables + run: | + TAG=${{ github.ref }} + 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 + 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 build \ + --platform ${{ matrix.image-platform }} \ + --build-arg target_arch=${{ matrix.target }} \ + --build-arg version=${{ env.VERSION }} \ + -t ${{ env.IMAGE }} \ + -f image/Dockerfile \ + .