Skip to content

Commit

Permalink
Add support for Linux arm64 binaries (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharsadhwani authored May 21, 2024
1 parent cde6605 commit 7e919de
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 5 deletions.
133 changes: 133 additions & 0 deletions .github/workflows/build-cross.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Build binaries for platforms under QEMU

on:
push:
tags:
- "v*"
branches:
- main
workflow_dispatch:
pull_request:

permissions:
contents: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-cross:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { name: "Linux-aarch64", target: aarch64-linux, os: ubuntu-20.04 }
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Check for release
id: is-release
shell: bash
run: |
unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
- uses: uraimo/run-on-arch-action@v2
name: Build binary under QEMU
id: build
with:
arch: aarch64
distro: ubuntu22.04
# Not required, but speeds up builds by storing container images in
# a GitHub package registry.
githubToken: ${{ github.token }}
run: |
apt update
apt install python3-pip -y
pip install .
# aliens: requires no source
ALIENS_NAME="aliens-${{ matrix.target }}.bin"
ALIENS_PATH=${PWD}/${ALIENS_NAME}
# packaged $ALIENS_NAME 'pip install pygame' 'python -m pygame.examples.aliens'
# textual: requires no source
TEXTUAL_NAME="textual-${{ matrix.target }}.bin"
TEXTUAL_PATH=${PWD}/${TEXTUAL_NAME}
packaged $TEXTUAL_NAME 'pip install pygame' 'python -m textual'
# IPython: requires no source
IPYTHON_NAME="ipython-${{ matrix.target }}.bin"
IPYTHON_PATH=${PWD}/${IPYTHON_NAME}
packaged $IPYTHON_NAME 'pip install ipython' 'ipython'
# ./examples/mandelbrot
MANDELBROT_NAME="mandelbrot-${{ matrix.target }}.bin"
MANDELBROT_PATH=${PWD}/${MANDELBROT_NAME}
packaged $MANDELBROT_NAME 'pip install -r requirements.txt' 'python mandelbrot.py' ./example/mandelbrot
# ./examples/minesweeper
MINESWEEPER_NAME="minesweeper-${{ matrix.target }}.bin"
MINESWEEPER_PATH=${PWD}/${MINESWEEPER_NAME}
packaged ./example/minesweeper
mv ./minesweeper.bin $MINESWEEPER_NAME
# Setup output paths for upload
echo ::set-output name=ALIENS_NAME::"${ALIENS_NAME}"
echo ::set-output name=ALIENS_PATH::"${ALIENS_PATH}"
echo ::set-output name=TEXTUAL_NAME::"${TEXTUAL_NAME}"
echo ::set-output name=TEXTUAL_PATH::"${TEXTUAL_PATH}"
echo ::set-output name=IPYTHON_NAME::"${IPYTHON_NAME}"
echo ::set-output name=IPYTHON_PATH::"${IPYTHON_PATH}"
echo ::set-output name=MANDELBROT_NAME::"${MANDELBROT_NAME}"
echo ::set-output name=MANDELBROT_PATH::"${MANDELBROT_PATH}"
echo ::set-output name=MINESWEEPER_NAME::"${MINESWEEPER_NAME}"
echo ::set-output name=MINESWEEPER_PATH::"${MINESWEEPER_PATH}"
- name: Upload aliens
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build.outputs.ALIENS_NAME }}
path: ${{ steps.build.outputs.ALIENS_PATH }}

- name: Upload textual
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build.outputs.TEXTUAL_NAME }}
path: ${{ steps.build.outputs.TEXTUAL_PATH }}

- name: Upload IPython
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build.outputs.IPYTHON_NAME }}
path: ${{ steps.build.outputs.IPYTHON_PATH }}

- name: Upload mandelbrot
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build.outputs.MANDELBROT_NAME }}
path: ${{ steps.build.outputs.MANDELBROT_PATH }}

- name: Upload minesweeper
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build.outputs.MINESWEEPER_NAME }}
path: ${{ steps.build.outputs.MINESWEEPER_PATH }}

- name: Publish packages
uses: softprops/action-gh-release@v1
if: steps.is-release.outputs.IS_RELEASE
with:
draft: true
files: |
${{ steps.build.outputs.ALIENS_PATH }}
${{ steps.build.outputs.TEXTUAL_PATH }}
${{ steps.build.outputs.IPYTHON_PATH }}
${{ steps.build.outputs.MANDELBROT_PATH }}
${{ steps.build.outputs.MINESWEEPER_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ jobs:
matrix:
include:
- { name: "Linux-x86_64", target: x86_64-linux, os: ubuntu-20.04 }
# No arm linux OS available on github actions.
# Find another way.
# - { name: "Linux-aarch64", target: aarch64-linux, os: ubuntu-latest }
- { name: "macOS-x86_64", target: x86_64-darwin, os: macOS-13 }
- { name: "macOS-aarch64", target: aarch64-darwin, os: macOS-14 }
# - {
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- { python-version: "3.8", tox-env: "py38" }
- { python-version: "3.9", tox-env: "py39" }
- { python-version: "3.10", tox-env: "py310" }
- { python-version: "3.11", tox-env: "py311" }
- { python-version: "3.12", tox-env: "py312" }
name: Python ${{ matrix.python-version }} tests
steps:
- uses: actions/checkout@v2
Expand All @@ -23,4 +28,4 @@ jobs:
- name: Install dependencies
run: pip install -r requirements-dev.txt
- name: Run tests and type checking
run: tox
run: tox -e ${{matrix.tox-env }}

0 comments on commit 7e919de

Please sign in to comment.