Skip to content

Commit

Permalink
Replace travis with github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino committed Feb 23, 2021
1 parent d124087 commit b071701
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 44 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/apt-get-update.sh
@@ -0,0 +1,19 @@
#!/bin/bash

set -eo pipefail

aptget_update()
{
if [ ! -z $1 ]; then
echo ""
echo "Retrying apt-get update..."
echo ""
fi
output=`sudo apt-get update 2>&1`
echo "$output"
if [[ $output == *[WE]:\ * ]]; then
return 1
fi
}

aptget_update || aptget_update retry || aptget_update retry
114 changes: 114 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,114 @@
name: Test

on: [push, pull_request]

jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: ["2.7", "3.6", "3.7"]
django-version: ["1.11", "2.2"]
grappelli: ["0", "1"]
s3: ["0", "1"]
exclude:
- python-version: "2.7"
django-version: "2.2"
- grappelli: "1"
s3: "1"
- python-version: "3.7"
django-version: "1.11"
- python-version: "3.8"
django-version: "1.11"
- python-version: "3.6"
s3: "1"
include:
- python-version: "2.7"
python-bin: python2
- python-version: "3.6"
python-bin: python3
- python-version: "3.7"
python-bin: python3
- s3: "1"
name-suffix: " with S3 storage"
- grappelli: "1"
name-suffix: " with grappelli"
- s3: "0"
grappelli: "0"
name-suffix: ""

runs-on: ubuntu-latest
name: Django ${{ matrix.django-version }}${{ matrix.name-suffix }} (Python ${{ matrix.python-version }})

env:
DJANGO: ${{ matrix.django-version }}
GRAPPELLI: ${{ matrix.grappelli }}
S3: ${{ matrix.s3 }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Setup chromedriver
uses: nanasess/setup-chromedriver@v1.0.5

- name: Install system dependencies
run: |
sudo .github/workflows/apt-get-update.sh
sudo apt-get install -y exempi gifsicle
- name: Install tox
run: |
${{ matrix.python-bin }} -m pip install tox tox-gh-actions
- name: Run tests
run: |
tox -- -v --selenosis-driver=chrome-headless || \
tox -- -v --selenosis-driver=chrome-headless || \
tox -- -v --selenosis-driver=chrome-headless
- name: Upload junit xml
if: always()
uses: actions/upload-artifact@v2
with:
name: junit-reports
path: reports/*.xml

- name: Combine coverage
run: tox -e coverage-report

- name: Upload coverage
run: tox -e codecov
env:
CODECOV_NAME: ${{ github.workflow }}

report:
if: always()
needs: build
runs-on: ubuntu-latest
name: "Report Test Results"
steps:
- uses: actions/download-artifact@v2
with:
name: junit-reports

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1.8
if: always()
with:
files: ./*.xml
report_individual_runs: true

success:
needs: build
runs-on: ubuntu-latest
name: Test Successful
steps:
- name: Success
run: echo Test Successful
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ ghostdriver.log
test/media
dist/
.coverage
/reports/
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

44 changes: 41 additions & 3 deletions tox.ini
@@ -1,13 +1,32 @@
[tox]
envlist =
py{27,36}-dj111{,-grp}
py{36,37,38}-dj{22,30,31}{,-grp}
py{27,36}-dj111-{grp,nogrp}
py{36,37,38}-dj{22,30,31}-{grp,nogrp}
skipsdist = True

[gh-actions]
python =
2.7: py27
3.6: py36
3.7: py37
3.8: py38

[gh-actions:env]
DJANGO =
1.11: dj111
2.2: dj22
3.0: dj30
3.1: dj31
GRAPPELLI =
0: nogrp
1: grp

[testenv]
commands =
pytest {posargs}
pytest --junitxml={toxinidir}/reports/test-{envname}.xml {posargs}
usedevelop = True
setenv =
COVERAGE_FILE={toxworkdir}/coverage/.coverage.{envname}
passenv =
CI
TRAVIS
Expand Down Expand Up @@ -36,3 +55,22 @@ deps =
dj31-grp: django-grappelli==2.14.3
lxml
-e git+https://github.com/theatlantic/django-ckeditor.git@v4.5.7+atl.6.1#egg=django-ckeditor

[testenv:coverage-report]
skip_install = true
deps = coverage
setenv=COVERAGE_FILE=.coverage
changedir = {toxworkdir}/coverage
commands =
coverage combine
coverage report
coverage xml

[testenv:codecov]
skip_install = true
deps = codecov
depends = coverage-report
passenv = CODECOV_TOKEN
changedir = {toxinidir}
commands =
codecov --file {toxworkdir}/coverage/*.xml {posargs}

0 comments on commit b071701

Please sign in to comment.