Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to migrate from travis-ci to github-actions (for Python projects)

How to migrate from travis-ci to github-actions (for Python projects)

Tested on Python projects only.

Follow the steps below.

Create an .env file with the following context:

.env

GITHUB_TOKEN
COVERALLS_REPO_TOKEN

Change your .coveralls.yml file:

.coveralls.yml

service_name: github-actions

Set relative_files to True in your coverage config:

.coveragerc

[run]
relative_files = True

Add COVERALLS_REPO_TOKEN to the GitHub project secrets:

  • Create a token named COVERALLS_REPO_TOKEN on the coveralls.io side.
  • Remember the token (copy somewhere).
  • Add to the GitHub repository secrets.

Consider the following example:

.travis.yml

dist: xenial

language: python

matrix:
  fast_finish: true
  allow_failures:
    - python: 2.7
    - python: 3.5
  include:
  - env: TOX_ENV=py27
    python: 3.5
  - env: TOX_ENV=py35
    python: 3.5
  - env: TOX_ENV=py36
    python: 3.6
  - env: TOX_ENV=py37
    python: 3.7
  - env: TOX_ENV=py38
    python: 3.8
  - env: TOX_ENV=py39
    python: 3.9

before_install:
  - pip install pip-tools
  - pip-compile requirements/testing.in
  - pip-compile requirements/release.in

install:
  - pip install -r requirements/testing.txt -r requirements/release.txt

script: travis_retry tox -e $TOX_ENV

after_success:
  - pip install coveralls
  - coveralls

.github/workflows/test.yml

name: test

on: [push, pull_request]

jobs:
  test:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        include:
          - python-version: 3.6
            tox_env: py36
          - python-version: 3.7
            tox_env: py37
          - python-version: 3.8
            tox_env: py38
          - python-version: 3.9
            tox_env: py39

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install Dependencies
      run: |
        python -m pip install --upgrade pip
        pip install pip-tools
        pip-compile requirements/testing.in
        pip-compile requirements/release.in
        pip install -r requirements/testing.txt -r requirements/release.txt
    - name: Run Tests
      run: tox -e ${{ matrix.tox_env }}
    - name: Coveralls
      uses: AndreMiras/coveralls-python-action@develop
      with:
        parallel: true
        flag-name: Run Tests

  coveralls_finish:
    needs: test
    runs-on: ubuntu-latest
    steps:
    - name: Coveralls Finished
      env:
        COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
        GITHUB_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
      uses: AndreMiras/coveralls-python-action@develop
      with:
        parallel-finished: true
        debug: True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment