AWS Graviton2 processors deliver a major leap in performance and capabilities over first-generation AWS Graviton processors. They power Amazon Elastic Compute Cloud (Amazon EC2) M6g, C6g, and R6g instances, and their variants with local disk storage. Graviton2-based EC2 instances provide up to 40% better price/performance over comparable current generation x86-based instances for a wide variety of workloads, including:
- Application servers
- High-performance computing
- Electronic design automation
- Open source databases
- In-memory caches
Given the price and performance benefits of Graviton2, customers are adopting it quickly. This means many software teams and open source projects need to build and test their software on both x86 and Arm64 architectures. That is why the General Availability of Travis-CI.com for AWS Graviton2 based instances is exciting: It enables easy and efficient build, test, and deployment of code-artifacts for Arm64-based systems. Travis-CI.com builds using Graviton2 are available as both full virtual machines (VM) or LXD containers. The builds are up to two-times faster than previous Arm64 builds. Adding support for AWS Graviton2-based builds into a project requires adding a few extra lines of code.
In this post, we show how to get started building, testing, and deploying quickly through Travis-CI.com on Graviton2 using two examples. This post assumes that the reader is already familiar with Travis-CI.com’s basic concepts and knows how to link Travis-CI.com with their source repository. If not, please refer to the Travis CI tutorial to get started with Travis CI. (Note: Do not be confused with the deprecated Travis-CI.org, which does not have access to Graviton2.)
Example 1: Add Graviton2 to a generic project
A simple Travis CI build for a
C project on
x86_64 is shown in the following example
The Travis-CI.com project creates the target
make in the
script section. If the build is successful, it calls the resulting binary
after_success to determine whether the binary works.
To add building and testing on Graviton2, we must add three fields to the build file:
arch controls which CPU architectures to run the build on; to enable Graviton2, we add
Note that setting
arm64 targets the original Travis-CI.com Arm64 build servers. This results in significantly slower builds that can cause some projects to time out.
In addition to setting
arch for Graviton2 support, there are three extra variables that must be defined:
- For VM builds,
dist: focal, and
group: edgemust be set.
- For LXD builds,
distcan be set to
- For LXD builds,
group: edgemust be set.
For our example, we configure building on a VM and set the extra variables as shown below in the build file:
Otherwise, the rest of
.travis.yml remains unchanged and builds now run on both target architectures.
Example 2: Add Graviton2 to build wheels for a Python project
A common use case for Travis CI is to build, test, and distribute binary extensions for interpreted languages, such as Python. Python uses a package format called a “wheel” for distributing both Python-only packages and packages that contain native code compiled for a particular target machine. For instance, during a
pip install, you may see it downloading packages named like the following:
- <package name>-<version number>-<python abi>-<platform architecture>.whl
These files must be built for each target architecture the package supports. Pure Python modules use “any” as a platform architecture. When binaries are also built—for example, by compiling a C library—the wheel becomes platform-specific, containing binaries for x86 or Arm. Travis CI hosted on AWS Graviton2 allows for fast building and distribution of these Python packages that contain native code extensions and target Arm64.
To build a wheel, use a simple script to create the wheel packages. Review the following example, which we reference as the
build-wheels.sh script later in this post:
To build a wheel in Travis CI, we must use Docker to build the wheels in a lowest common denominator environment called ManyLinux. Using the ManyLinux containers results in binaries that are compatible across many different Linux distributions. To build and distribute x86-only wheels for our hypothetical project, our
This project builds the wheels inside the container by:
- Mounting the present working directory into the container’s filesystem.
- Performing the build through the
- On success, uploading the artifacts with
twineif the git commit that triggered the build was tagged.
To enable building Arm wheels on Graviton2, we add the
group tags as specified in Example 1. We also add an Arm64-specific entry in the
matrix.include portion for build job. The resulting
.travis.yml build specification is:
Working with Graviton2 builders on Travis-CI.com is straightforward for both simple and complex projects. Projects can enable Graviton2 builds on Travis-CI.com now to take advantage of the fast build times. To learn more about AWS Graviton, visit the website. To get started using Graviton2 for your projects, visit Travis-CI.com to register your account and link your repositories.