Skip to content

Commit

Permalink
Switch to GitHub Actions
Browse files Browse the repository at this point in the history
Travis CI is no longer free, so transition to using GitHub Actions to do
CI and release builds.

Note that while coverage data is being collected, it's not currently
being submitted to coveralls.io, as there doesn't appear to be good
GitHub Actions integration for Python with coveralls
  • Loading branch information
JoshuaWatt committed Feb 16, 2021
1 parent 7b24810 commit a81b154
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 78 deletions.
4 changes: 2 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[run]
include =
${TRAVIS_BUILD_DIR}/pyrex.py
${GITHUB_WORKSPACE}/pyrex.py
parallel = True
data_file = ${TRAVIS_BUILD_DIR}/.coverage
data_file = ${GITHUB_WORKSPACE}/.coverage

119 changes: 119 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: build
on:
push:
branches:
- master
- next
pull_request:
branches:
- master
- next
workflow_dispatch:

jobs:
check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: 3.6

- name: Install python packages
run: |
python3 -m pip install --upgrade pip
pip3 install \
black \
flake8
- name: Run black
run: |
black --check $(git ls-files '*.py')
- name: Run flake8
run: |
flake8 $(git ls-files '*.py')
build:
strategy:
fail-fast: false
matrix:
include:
- {image: ubuntu-14.04-base, provider: docker, sh: bash}
- {image: ubuntu-14.04-oe, provider: docker, sh: bash}
- {image: ubuntu-16.04-base, provider: docker, sh: bash}
- {image: ubuntu-16.04-oe, provider: docker, sh: bash}
- {image: ubuntu-18.04-base, provider: docker, sh: bash}
- {image: ubuntu-18.04-oe, provider: docker, sh: zsh }
- {image: ubuntu-18.04-oetest, provider: docker, sh: bash}
- {image: ubuntu-20.04-base, provider: docker, sh: bash}
- {image: ubuntu-20.04-oe, provider: docker, sh: bash}
- {image: ubuntu-20.04-oe, provider: podman, sh: bash}
- {image: ubuntu-20.04-oetest, provider: docker, sh: bash}

runs-on: ubuntu-20.04

env:
USE_HELPER: "1"
DOCKER_BUILDKIT: "1"

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: 3.6

- name: Prepare build
run: ./ci/prepare.sh

- name: Install packages
run: |
sudo mkdir -p /etc/containers/
echo -e "[registries.search]\nregistries = ['docker.io']\n" | sudo tee /etc/containers/registries.conf
echo '{ "features": { "buildkit": true } }' | sudo tee /etc/docker/daemon.json
sudo apt -y install \
diffstat \
fuse-overlayfs \
zsh
- name: ${{ matrix.provider }} info
run: ${{ matrix.provider }} info

- name: Install python packages
run: |
python3 -m pip install --upgrade pip
pip3 install coverage
- name: Build image
run: |
./ci/build_image.py ${{ matrix.image }} --provider=${{ matrix.provider }}
- name: Test image
run: |
export PYTHONPATH=${GITHUB_WORKSPACE}/ci/site/:$PYTHONPATH
export COVERAGE_PROCESS_START=${GITHUB_WORKSPACE}/.coveragerc
rm -f .coverage-report.*
${{ matrix.sh }} -c "./ci/test.py -vb PyrexImage_${{ matrix.provider }}_$(echo ${{ matrix.image }} | sed 's/\W/_/g')"
- name: Combine coverage
run: |
coverage3 combine
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: ${{ ( github.ref == 'refs/heads/next' || github.ref == 'refs/heads/master' ) && github.event_name == 'push' && matrix.provider == 'docker' }}

- name: Push image
run: |
TAG="${GITHUB_REF##*/}"
if [ "$TAG" = "master" ]; then
TAG="latest"
fi
docker tag garminpyrex/${{ matrix.image }}:ci-test garminpyrex/${{ matrix.image }}:$TAG
docker push garminpyrex/${{ matrix.image }}:$TAG
if: ${{ ( github.ref == 'refs/heads/next' || github.ref == 'refs/heads/master' ) && github.event_name == 'push' && matrix.provider == 'docker' }}
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: release
on:
release:
types:
- published

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- image: ubuntu-14.04-base
- image: ubuntu-14.04-oe
- image: ubuntu-16.04-base
- image: ubuntu-16.04-oe
- image: ubuntu-18.04-base
- image: ubuntu-18.04-oe
- image: ubuntu-18.04-oetest
- image: ubuntu-20.04-base
- image: ubuntu-20.04-oe
- image: ubuntu-20.04-oetest

runs-on: ubuntu-20.04

env:
USE_HELPER: "1"
DOCKER_BUILDKIT: "1"

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: 3.6

- name: Prepare build
run: ./ci/prepare.sh

- name: Install packages
run: |
sudo apt install -y diffstat
- name: Install python packages
run: |
python3 -m pip install --upgrade pip
pip3 install requests
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Deploy image
run: |
export RELEASE_TAG="${GITHUB_REF##*/}"
./ci/deploy_docker.py "${{ matrix.image }}:$RELEASE_TAG"
67 changes: 0 additions & 67 deletions .travis.yml

This file was deleted.

9 changes: 5 additions & 4 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,19 @@ To make a release of Pyrex:
intended for general consumption should always be in the form
`MAJOR.MINOR.MICRO` without any suffix. Push this change to the master
branch.
2. Wait for [Travis](https://travis-ci.org/garmin/pyrex/branches) to finish the
CI build and verify it passes, or manually test it with
2. Wait for the [CI build](https://github.com/garmin/pyrex/actions?query=workflow%3Abuild)
to finish and verify it passes, or manually test it with
```shell
./ci/test.py -vbf
```
3. Create a new [GitHub Release](https://github.com/garmin/pyrex/releases). The
release must be tagged with the version in `pyrex.py`, prefixed with `v`.
For example, the `1.0.0` release would be tagged `v1.0.0`
4. Tagging the repository will trigger a new Travis CI build. This build will
4. Tagging the repository will trigger a new CI build. This build will
automatically push the container images to
[dockerhub](https://cloud.docker.com/u/garminpyrex/repository/list) using
the same tag that was created for the release. Verify that the CI build
the same tag that was created for the release. Verify that the
[Release build](https://github.com/garmin/pyrex/actions?query=workflow%3Arelease)
passes and the container images are pushed. In the unlikely event this
fails, delete the release, fix the issue, and try again. To manually deploy
a release, run:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Pyrex
Containerize your bitbake

[![Build Status](https://travis-ci.com/garmin/pyrex.svg?branch=master)](https://travis-ci.com/garmin/pyrex)
[![Build Status](https://github.com/garmin/pyrex/workflows/build/badge.svg?event=push&branch=master)](https://github.com/garmin/pyrex/actions?query=workflow%3Abuild+event%3Apush+branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/garmin/pyrex/badge.svg?branch=master)](https://coveralls.io/github/garmin/pyrex?branch=master)

## Quickstart Guide (default layout)
Expand Down
2 changes: 0 additions & 2 deletions ci/deploy_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ def main():
image = args.image
if ":" in image:
image, tag = image.split(":", 1)
elif "TRAVIS_TAG" in os.environ:
tag = os.environ["TRAVIS_TAG"] or "latest"
else:
tag = "latest"

Expand Down
3 changes: 3 additions & 0 deletions ci/site/sitecustomize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import coverage

coverage.current_coverage = coverage.process_startup()
4 changes: 2 additions & 2 deletions ci/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,8 @@ def test_version(self):

def test_version_tag(self):
tag = None
if os.environ.get("TRAVIS_TAG"):
tag = os.environ["TRAVIS_TAG"]
if os.environ.get("RELEASE_TAG"):
tag = os.environ["RELEASE_TAG"]
else:
try:
tags = (
Expand Down

0 comments on commit a81b154

Please sign in to comment.