Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run tox from github actions

I am new to tox and GitHub actions, and I am looking for a simple way to make them work together. I wrote this simple workflow:

name: Python package

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version: [3.7]

    steps:
    - uses: actions/checkout@v1
    - name: Install tox
      run: pip install tox
    - name: Run tox
      run: tox

which just installs tox and then runs it. But when I run this workflow, the tox installation works fine, but the run command returns an error:

tox: command not found

What is the correct way to run tox from a GitHub action?

like image 597
Erel Segal-Halevi Avatar asked Dec 30 '19 14:12

Erel Segal-Halevi


1 Answers

You can also use tox-gh-actions.

In your workflow file:

 steps:
  - uses: actions/checkout@v1
  - name: Set up Python ${{ matrix.python-version }}
    uses: actions/setup-python@v2
    with:
      python-version: ${{ matrix.python-version }}
  - name: Install dependencies
    run: |
      python -m pip install --upgrade pip
      pip install tox tox-gh-actions
  - name: Test with tox
    run: tox

In your tox.ini (other config formats work too):

[gh-actions]
python = 
  3.8: py38
like image 137
tobhai Avatar answered Sep 18 '22 20:09

tobhai