Skip to content

Commit

Permalink
Switch from Travis CI to GitHub Actions
Browse files Browse the repository at this point in the history
Travis CI has a new pricing model since Nov'2020 with "credits" per build-minutes. The credits were depleted quite fast. There is no clear way to buy more credits, there is no clear way to request more for an open-source project, there are no clear criteria on what counts as open-source. And even if requested, the build-minutes are used fast (mostly by nightly builds) — 10'000 credits were depleted in two weeks. That might work for tiny project, but for K8s tests matrix, those credits are not enough.

Besides, Travis CI has introduced the limited capacity for open-source builds, so there were a few cases when the builds were waiting for 1 hour in the backlog to be executed. This kills all the optimisations made to get the PR feedback faster, in ~5 mins.

GitHub Actions offer unlimited build-minutes for public repositories, i.e. for open-source. The pricing model is clear, if it would be ever needed. If and when GitHub will cancel free builds for open-source/public repositories, that approach can be revised again in favour of Travis CI or maybe other CI tools.
  • Loading branch information
nolar committed Nov 18, 2020
1 parent 5563bdb commit cbe0035
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 138 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/publish.yaml
@@ -0,0 +1,27 @@
name: Publish to PyPI
on:
workflow_dispatch:
release:
types:
- published
# push:
# tags:
# - "[0-9]+.[0-9]+*"

jobs:
publish:
name: Build and publish
if: startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: pip install --upgrade setuptools wheel twine
- run: python setup.py sdist bdist_wheel
- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_token }}
skip_existing: true
155 changes: 155 additions & 0 deletions .github/workflows/tests.yaml
@@ -0,0 +1,155 @@
name: Tests
on:
workflow_dispatch:
push:
branches:
- master
- release/**
paths-ignore:
- "*.md"
- "docs/**"
pull_request:
branches:
- master
schedule:
- cron: "13 3 * * *"

jobs:
linters:
name: Linting and static analysis
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- run: pip install -r requirements.txt
- run: isort . --check --diff
continue-on-error: true
- run: isort examples --settings=examples --check --diff
continue-on-error: true

unit-tests:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9" ]
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- run: pip install -r requirements.txt
- run: mypy kopf --strict --pretty
- run: pytest --cov=kopf --cov-branch --junit-xml=junit.xml
- run: coveralls || true
if: ${{ success() }}
- run: codecov --flags unit
if: ${{ success() }}
# - uses: actions/upload-artifact@v2
# with:
# name: JUnit for ${{ matrix.python-version }}
# path: junit.xml
# if: ${{ always() }}

functional:
strategy:
fail-fast: false
matrix:
k3s: [latest, v1.18.8+k3s1, v1.16.14+k3s1]
client: [true, false]
crdapi: ["", v1beta1]
exclude:
- client: true
- crdapi: v1beta1
include:
- k3s: v1.16.14+k3s1
crdapi: v1beta1
client: false
- k3s: latest
crdapi: ""
client: true
name: >-
K3s ${{matrix.k3s}}
${{matrix.crdapi && format('CRD={0}', matrix.crdapi) || ''}}
${{matrix.client && '+client' || ''}}
runs-on: ubuntu-20.04
env:
K3S: ${{ matrix.k3s }}
CLIENT: ${{ matrix.client || '' }}
CRDAPI: ${{ matrix.crdapi || '' }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- run: pip install -r requirements.txt
- run: tools/install-clients.sh
- run: tools/install-kubectl.sh
- run: tools/install-k3d-k3s.sh
- run: pytest --only-e2e

full-scale-crd-v1:
# if: ${{ github.event_name == 'schedule' }} # TODO
strategy:
fail-fast: false
matrix:
k8s: [latest, v1.19.0, v1.18.8, v1.17.11, v1.16.14]
client: [true, false]
crdapi: [""]
python-version: ["3.9"]
exclude:
- client: true
include:
- k8s: latest
client: true
name: >-
K8s ${{matrix.k8s}}
${{matrix.crdapi && format('CRD={0}', matrix.crdapi) || ''}}
${{matrix.client && '+client' || ''}}
runs-on: ubuntu-20.04
env:
K8S: ${{ matrix.k8s }}
CLIENT: ${{ matrix.client || '' }}
CRDAPI: ${{ matrix.crdapi || '' }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- run: pip install -r requirements.txt
- run: tools/install-clients.sh
- run: tools/install-kubectl.sh
- run: tools/install-minikube.sh
- run: pytest --only-e2e

full-scale-crd-v1beta1:
# if: ${{ github.event_name == 'schedule' }} # TODO
strategy:
fail-fast: false
matrix:
k8s: [v1.16.14, v1.15.12, v1.14.10, v1.13.12]
client: [false]
crdapi: [v1beta1]
python-version: ["3.9"]
name: >-
K8s ${{matrix.k8s}}
${{matrix.crdapi && format('CRD={0}', matrix.crdapi) || ''}}
${{matrix.client && '+client' || ''}}
runs-on: ubuntu-20.04
env:
K8S: ${{ matrix.k8s }}
CLIENT: ${{ matrix.client || '' }}
CRDAPI: ${{ matrix.crdapi || '' }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- run: pip install -r requirements.txt
- run: tools/install-clients.sh
- run: tools/install-kubectl.sh
- run: tools/install-minikube.sh
- run: pytest --only-e2e
111 changes: 0 additions & 111 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
# Kubernetes Operator Pythonic Framework (Kopf)

[![Build Status](https://travis-ci.org/nolar/kopf.svg?branch=master)](https://travis-ci.org/nolar/kopf)
[![Tests](https://github.com/nolar/kopf/workflows/Tests/badge.svg)](https://github.com/nolar/kopf/actions)
[![codecov](https://codecov.io/gh/nolar/kopf/branch/master/graph/badge.svg)](https://codecov.io/gh/nolar/kopf)
[![Coverage Status](https://coveralls.io/repos/github/nolar/kopf/badge.svg?branch=master)](https://coveralls.io/github/nolar/kopf?branch=master)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/nolar/kopf.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nolar/kopf/alerts/)
Expand Down
20 changes: 0 additions & 20 deletions docs/contributing.rst
Expand Up @@ -105,23 +105,3 @@ Code reviews
You can use one of the existing or closed issues that match your topic best.
* The PRs can be reviewed and commented by anyone,
but can be approved only by the project maintainers.


Private CI/CD
=============

The existing setup runs the Travis CI builds on every push
to the existing pull requests of the upstream repository.

In case you do not want to create a pull request yet,
but want to run the builds for your branch,
enable Travis CI for your own fork:

* Create a `Travis CI <https://travis-ci.org/>`_ account.
* Find your fork in the list of repos.
* Click the toggle.
* Push a feature branch to ``origin`` (see above).
* Observe how Travis runs the tests in Travis CI in your account.

When ready, create a PR to the upstream repository.
This will run the tests in the upstream's Travis account.
2 changes: 1 addition & 1 deletion examples/09-testing/test_example_09.py
Expand Up @@ -11,7 +11,7 @@

@pytest.fixture(scope='session')
def crd_yaml():
crd_api = os.environ.get('CRDAPI', 'v1')
crd_api = os.environ.get('CRDAPI') or 'v1'
crd_file = 'crd.yaml' if crd_api == 'v1' else f'crd-{crd_api}.yaml'
return os.path.relpath(os.path.join(os.path.dirname(__file__), '..', crd_file))

Expand Down
2 changes: 1 addition & 1 deletion examples/11-filtering-handlers/test_example_11.py
Expand Up @@ -11,7 +11,7 @@

@pytest.fixture(scope='session')
def crd_yaml():
crd_api = os.environ.get('CRDAPI', 'v1')
crd_api = os.environ.get('CRDAPI') or 'v1'
crd_file = 'crd.yaml' if crd_api == 'v1' else f'crd-{crd_api}.yaml'
return os.path.relpath(os.path.join(os.path.dirname(__file__), '..', crd_file))

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/conftest.py
Expand Up @@ -18,14 +18,14 @@ def exampledir(request):

@pytest.fixture(scope='session')
def peering_yaml():
crd_api = os.environ.get('CRDAPI', 'v1')
crd_api = os.environ.get('CRDAPI') or 'v1'
crd_file = 'peering.yaml' if crd_api == 'v1' else f'peering-{crd_api}.yaml'
return f'{crd_file}'


@pytest.fixture(scope='session')
def crd_yaml():
crd_api = os.environ.get('CRDAPI', 'v1')
crd_api = os.environ.get('CRDAPI') or 'v1'
crd_file = 'crd.yaml' if crd_api == 'v1' else f'crd-{crd_api}.yaml'
return f'examples/{crd_file}'

Expand Down
2 changes: 1 addition & 1 deletion tools/install-kind.sh
Expand Up @@ -19,7 +19,7 @@ if [[ "$K8S" == latest ]] ; then
K8S="$( curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt )"
fi

curl -Lo ./kind https://kind.sigs.k8s.io/dl/"$KIND"/kind-linux-"$TRAVIS_CPU_ARCH"
curl -Lo ./kind https://kind.sigs.k8s.io/dl/"$KIND"/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion tools/install-kubectl.sh
Expand Up @@ -13,6 +13,6 @@ if [[ "$K8S" == latest ]] ; then
K8S="$( curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt )"
fi

curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/"$K8S"/bin/linux/"$TRAVIS_CPU_ARCH"/kubectl
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/"$K8S"/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

0 comments on commit cbe0035

Please sign in to comment.