• Stars
    star
    681
  • Rank 66,346 (Top 2 %)
  • Language
    Shell
  • License
    BSD 3-Clause "New...
  • Created about 5 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Github Action that executes jobs/commands on non-x86 cpu architectures (ARMv6, ARMv7, aarch64, s390x, ppc64le, riscv64) via QEMU

Run-On-Arch GitHub Action

A GitHub Action that executes commands on non-x86 CPU architecture (armv6, armv7, aarch64, s390x, ppc64le) via QEMU.

Usage

This action requires three input parameters:

  • arch: CPU architecture: armv6, armv7, aarch64, riscv64, s390x, or ppc64le. See Supported Platforms for the full matrix.
  • distro: Linux distribution name: ubuntu16.04, ubuntu18.04, ubuntu20.04, bullseye, buster, stretch, jessie, fedora_latest, alpine_latest or archarm_latest. See Supported Platforms for the full matrix.
  • run: Shell commands to execute in the container.

The action also accepts some optional input parameters:

  • githubToken: Your GitHub token, used for caching Docker images in your project's public package registry. Usually this would just be ${{ github.token }}. This speeds up subsequent builds and is highly recommended.
  • env: Environment variables to propagate to the container. YAML, but must begin with a | character. These variables will be available in both run and setup.
  • shell: The shell to run commands with in the container. Default: /bin/sh on Alpine, /bin/bash for other distros.
  • dockerRunArgs: Additional arguments to pass to docker run, such as volume mappings. See docker run documentation.
  • setup: Shell commands to execute on the host before running the container, such as creating directories for volume mappings.
  • install: Shell commands to execute in the container as part of docker build, such as installing dependencies. This speeds up subsequent builds if githubToken is also used, but note that the image layer will be publicly available in your projects GitHub Package Registry, so make sure the resulting image does not have any secrets cached in logs or state.
  • base_image: Specify a custom base image, such as busybox, arch and distro should be set to none in this case. This will allow you to chose direcly the image that will be used in the FROM clause of the internal docker container without needing to create a Dockerfile.arch.distro for a specific arch/distro pair. For more detials, see PR #103. Known limitation: Only one base_image configuration for each workflow if you use GitHub images caching.

Basic example

A basic example that sets an output variable for use in subsequent steps:

on: [push, pull_request]

jobs:
  armv7_job:
    # The host should always be Linux
    runs-on: ubuntu-18.04
    name: Build on ubuntu-18.04 armv7
    steps:
      - uses: actions/checkout@v3
      - uses: uraimo/run-on-arch-action@v2
        name: Run commands
        id: runcmd
        with:
          arch: armv7
          distro: ubuntu18.04

          # Not required, but speeds up builds by storing container images in
          # a GitHub package registry.
          githubToken: ${{ github.token }}

          # Set an output parameter `uname` for use in subsequent steps
          run: |
            uname -a
            echo ::set-output name=uname::$(uname -a)

      - name: Get the output
        # Echo the `uname` output parameter from the `runcmd` step
        run: |
          echo "The uname output was ${{ steps.runcmd.outputs.uname }}"

Advanced example

This shows how to use a matrix to produce platform-specific artifacts, and includes example values for the optional input parameters setup, shell, env, and dockerRunArgs.

on: [push, pull_request]

jobs:
  build_job:
    # The host should always be linux
    runs-on: ubuntu-18.04
    name: Build on ${{ matrix.distro }} ${{ matrix.arch }}

    # Run steps on a matrix of 4 arch/distro combinations
    strategy:
      matrix:
        include:
          - arch: aarch64
            distro: ubuntu18.04
          - arch: ppc64le
            distro: alpine_latest
          - arch: s390x
            distro: fedora_latest
          - arch: none
            distro: none
            base_image: riscv64/busybox
    steps:
      - uses: actions/checkout@v3
      - uses: uraimo/run-on-arch-action@v2
        name: Build artifact
        id: build
        with:
          arch: ${{ matrix.arch }}
          distro: ${{ matrix.distro }}

          # Not required, but speeds up builds
          githubToken: ${{ github.token }}

          # Create an artifacts directory
          setup: |
            mkdir -p "${PWD}/artifacts"

          # Mount the artifacts directory as /artifacts in the container
          dockerRunArgs: |
            --volume "${PWD}/artifacts:/artifacts"

          # Pass some environment variables to the container
          env: | # YAML, but pipe character is necessary
            artifact_name: git-${{ matrix.distro }}_${{ matrix.arch }}

          # The shell to run commands with in the container
          shell: /bin/sh

          # Install some dependencies in the container. This speeds up builds if
          # you are also using githubToken. Any dependencies installed here will
          # be part of the container image that gets cached, so subsequent
          # builds don't have to re-install them. The image layer is cached
          # publicly in your project's package repository, so it is vital that
          # no secrets are present in the container state or logs.
          install: |
            case "${{ matrix.distro }}" in
              ubuntu*|jessie|stretch|buster|bullseye)
                apt-get update -q -y
                apt-get install -q -y git
                ;;
              fedora*)
                dnf -y update
                dnf -y install git which
                ;;
              alpine*)
                apk update
                apk add git
                ;;
            esac

          # Produce a binary artifact and place it in the mounted volume
          run: |
            cp $(which git) "/artifacts/${artifact_name}"
            echo "Produced artifact at /artifacts/${artifact_name}"

      - name: Show the artifact
        # Items placed in /artifacts in the container will be in
        # ${PWD}/artifacts on the host.
        run: |
          ls -al "${PWD}/artifacts"

Supported Platforms

This table details the valid arch/distro combinations:

arch distro
armv6 jessie, stretch, buster, bullseye, alpine_latest
armv7 jessie, stretch, buster, bullseye, ubuntu16.04, ubuntu18.04, ubuntu20.04, ubuntu22.04, ubuntu_latest, ubuntu_rolling, ubuntu_devel, fedora_latest, alpine_latest, archarm_latest
aarch64 stretch, buster, bullseye, ubuntu16.04, ubuntu18.04, ubuntu20.04, ubuntu22.04, ubuntu_latest, ubuntu_rolling, ubuntu_devel, fedora_latest, alpine_latest, archarm_latest
riscv64 ubuntu20.04, ubuntu22.04, ubuntu_latest, ubuntu_rolling, ubuntu_devel, alpine_edge
s390x jessie, stretch, buster, bullseye, ubuntu16.04, ubuntu18.04, ubuntu20.04, ubuntu22.04, ubuntu_latest, ubuntu_rolling, ubuntu_devel, fedora_latest, alpine_latest
ppc64le jessie, stretch, buster, bullseye, ubuntu16.04, ubuntu18.04,ubuntu20.04, ubuntu22.04, ubuntu_latest, ubuntu_rolling, ubuntu_devel, fedora_latest, alpine_latest

Using an invalid arch/distro combination will fail.

Architecture emulation

This project makes use of an additional QEMU container to be able to emulate via software architectures like ARM, s390x, ppc64le, etc... that are not natively supported by GitHub. You should keep this into consideration when reasoning about the expected running time of your jobs, there will be a visible impact on performance when compared to a job executed on a vanilla runner.

Contributing

New distros and archs can be added simply by creating a Dockerfile named Dockerfile.{arch}.{distro} (that targets an image for the desired combination) in the Dockerfiles directory. Pull requests welcome!

Authors

Umberto Raimondi

Elijah Shaw-Rutschman

And many other contributors.

License

This project is licensed under the BSD 3-Clause License.

More Repositories

1

Awesome-Swift-Playgrounds

A List of Awesome Swift Playgrounds
Swift
3,998
star
2

SwiftyGPIO

A Swift library for hardware projects on Linux/ARM boards with support for GPIOs/SPI/I2C/PWM/UART/1Wire.
Swift
1,301
star
3

buildSwiftOnARM

All you need to build Swift on a RaspberryPi or other ARM boards, updated to Swift 5.1.5
Shell
489
star
4

awesome-software-patreons

A curated list of awesome programmers and software projects you can support!
456
star
5

Bitter

A Swift Bits Manipulation/Bitwise Operations Toolkit
Swift
205
star
6

Swift-Playgrounds

Collection of Swift playgrounds used in my posts: From functional aspects of Swift to C interoperability.
Swift
139
star
7

SwiftyLISP

A minimal LISP implemented in Swift
Swift
126
star
8

pygments-vimstyles

Vim Styles as pygments CSS
CSS
37
star
9

WS281x.swift

A Swift library for WS281x (WS2811,WS2812*,WS2813*) RGB led strips, rings, sticks, matrices and more.
Swift
33
star
10

Nunchuck.swift

A Swift Library for the I2C Wii Nunchuck controller.
Swift
31
star
11

5110LCD_PCD8544.swift

A Swift library for the Nokia3310/5110 PCD8544 Monochrome LCD display
Swift
27
star
12

SwizzlingInSwift

Swift Method Swizzling Sample
Swift
18
star
13

SwiftyLISP-REPL

Basic REPL for SwiftyLISP
Swift
13
star
14

HD44780CharacterLCD.swift

A Swift library for 16x2/20x4 Character LCDs with the HD44780(or clones) controller
Swift
12
star
15

SG90Servo.swift

Swift library for the SG90 Servo Motor, adaptable for other servos (9g ES08A, SM-S4303R, S3003, etc...).
Swift
10
star
16

UBloxGPS.swift

A Swift library for boards with the u-Blox 6/7/8 family of A-GPS receivers
Swift
9
star
17

MPU-6050.swift

A Swift library for the MPU-6050 (and MPU-6000 family) Accelerometer and Gyroscope
Swift
7
star
18

buildSwiftOnARMInfra

Setup an infrastructure to build Swift on Linux/ARM
Shell
7
star
19

uistackview-sample

Sample code for www.uraimo.com/2015/09/08/ios9-uistackview-guide-swift/
Swift
7
star
20

RCWL-0516-Radar.swift

A Swift library for the RCWL-0516 Microwave Radar
Swift
5
star
21

DS18B20.swift

A Swift library for the DS18B20 digital temperature sensor
Swift
5
star
22

dotfiles

My dotfiles
Vim Script
4
star
23

MCP3008.swift

A Swift library for the MCP3008 (and MCP3002,MCP3004) 10 bits SPI ADC
Swift
4
star
24

barememtracer

C/C++ bare bones memory tracer
C
3
star
25

javabuild

An experimental Java build tool that mimics the Swift Package Manager
Java
3
star
26

DS1307.swift

A Swift library for the DS1307 (DS1302, DS3231) I2C Real-Time Clock
Swift
3
star
27

congo

Simple Go console package - See docs: http://godoc.org/github.com/uraimo/congo
Go
2
star