Skip to content

Commit

Permalink
Merge pull request #171 from HackSoc/github-actions
Browse files Browse the repository at this point in the history
Switch to GitHub Action & GitHub Packages, test on more Python versions
  • Loading branch information
alanbriolat committed Mar 27, 2021
2 parents 38ebd6f + 9ff5800 commit 26dccf2
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 56 deletions.
74 changes: 64 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,71 @@
name: CI

on: [push]
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]

jobs:
build:
tests:
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
include:
- python-version: 3.6
toxenv: py36
- python-version: 3.7
toxenv: py37
- python-version: 3.8
toxenv: py38
- python-version: 3.9
toxenv: py39-flake8
env:
PYTHON: ${{ matrix.python-version }}
steps:
- name: examine environment
run: env
- uses: actions/checkout@v1
- 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
python -m pip install tox
- name: Test with tox
run: python -m tox
env:
TOXENV: ${{ matrix.toxenv }}
- uses: codecov/codecov-action@v1
with:
env_vars: PYTHON

docker:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Run a one-line script
run: echo Hello, world!
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
- name: Build Docker image
uses: docker/build-push-action@v2
with:
load: true
push: false
tags: csbot:latest
- name: Run tests inside Docker
run: docker run --rm csbot:latest pytest
- name: Login to GitHub Packages
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: docker/login-action@v1
with:
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Docker image
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: docker/build-push-action@v2
with:
push: true
tags: |
docker.pkg.github.com/hacksoc/csbot/csbot:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pip-log.txt

# Unit test / coverage reports
.coverage
coverage*.xml
.tox
nosetests.xml
_trial_temp/
Expand Down
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

11 changes: 5 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ Testing
-------
csbot has some unit tests. (It'd be nice to have more.) To run them::

$ pytest
$ tox

We're also using Travis-CI for continuous integration and continuous deployment.
We're also using GitHub Actions for continuous integration and continuous deployment.

.. image:: https://travis-ci.org/HackSoc/csbot.svg?branch=master
:target: https://travis-ci.org/HackSoc/csbot
.. image:: https://github.com/HackSoc/csbot/actions/workflows/main.yml/badge.svg

.. image:: https://coveralls.io/repos/HackSoc/csbot/badge.png
:target: https://coveralls.io/r/HackSoc/csbot
.. image:: https://codecov.io/gh/HackSoc/csbot/branch/master/graph/badge.svg?token=oMJcY9E9lj
:target: https://codecov.io/gh/HackSoc/csbot


.. [1] csbot depends on lxml_, which is a compiled extension module based on
Expand Down
6 changes: 0 additions & 6 deletions docker-compose.test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
bot:
image: alanbriolat/csbot:latest
image: docker.pkg.github.com/hacksoc/csbot/csbot:latest
volumes:
- ${CSBOT_CONFIG_LOCAL:-./csbot.toml}:/app/csbot.toml
links:
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
testpaths = tests/
addopts = --cov=src/ -W ignore::schematics.deprecated.SchematicsDeprecationWarning
addopts = --cov=src/ --cov-report=xml -W ignore::schematics.deprecated.SchematicsDeprecationWarning
markers =
bot: mark a test as Bot-based rather than IRCClient-based
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pytest>=5.2.2,<6.0
pytest-asyncio==0.10.0
pytest-aiohttp==0.3.0
aioresponses==0.6.1
aioresponses==0.7.2
pytest-cov
asynctest==0.13.0
aiofastforward==0.0.24
Expand Down
5 changes: 4 additions & 1 deletion tests/test_plugin_calc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import pytest


Expand Down Expand Up @@ -53,5 +55,6 @@ def test_error(bot_helper):
assert calc._calc("factorial(-42)") == "Error, factorial() not defined for negative values"
assert calc._calc("factorial(4.2)") == "Error, factorial() only accepts integral values"
assert calc._calc("not await 1").startswith("Error,") # ast SyntaxError in Python 3.6 but not 3.7
assert calc._calc("(" * 200 + ")" * 200) == "Error, unable to parse"
if sys.version_info < (3, 9):
assert calc._calc("(" * 200 + ")" * 200) == "Error, unable to parse"
assert calc._calc("1@2") == "Error, invalid operator"
7 changes: 2 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
[tox]
envlist = py36,py37
envlist = py36,py37,py38,py39-flake8
skipsdist = True

[testenv]
passenv = TRAVIS TRAVIS_*
passenv = TRAVIS TRAVIS_* GITHUB_*
deps =
-r requirements.txt
coveralls: coveralls
flake8: flake8
commands =
python -m pytest {posargs}
flake8: flake8 --exit-zero --exclude=src/csbot/plugins_broken src/ tests/
# Try to run coveralls, but don't fail if coveralls fails
coveralls: - coveralls

0 comments on commit 26dccf2

Please sign in to comment.