Skip to content

Commit

Permalink
Introduce Github Actions to replace TravisCI (getmoto#3610)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Jan 26, 2021
1 parent 5a41866 commit 8591eda
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 244 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ exclude_lines =
[run]
include = moto/*
omit = moto/packages/*
source = moto
192 changes: 188 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,191 @@
name: Example Action
on: [push]
name: TestNDeploy

on:
push:
branches:
- master
pull_request:

jobs:
job1:
# Install and cache dependencies
cache:
name: Caching
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 2.7, 3.6, 3.7, 3.8 ]

steps:
- run: echo "Test"
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache-dir
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
id: pip-cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache-dir.outputs.dir }}
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements-dev.txt') }}
- name: Install Linux dependencies
if: ${{ matrix.python-version == 3.8 && steps.pip-cache.outputs.cache-hit != 'true' }}
run: |
sudo apt-get install libxslt-dev libxml2-dev -y
- name: Install project dependencies
if: ${{ steps.pip-cache.outputs.cache-hit != 'true' }}
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
lint:
name: Linting
runs-on: ubuntu-latest
needs: cache
strategy:
matrix:
python-version: [3.7]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# Retrieve the previously cached dependencies
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements-dev.txt') }}
# Still need to properly install the dependencies - it will only skip the download part
- name: Install project dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Lint with flake8
run:
make lint

test:
name: Unit test
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
python-version: [2.7, 3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements-dev.txt') }}
- name: Install Linux dependencies
if: ${{ matrix.python-version == 3.8 }}
run: |
sudo apt-get install libxslt-dev libxml2-dev -y
- name: Install project dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install pytest-cov
- name: Test with pytest
if: ${{ matrix.python-version != 3.7 }}
run: |
make test-only
# Only need to configure coverage once
# Pytest-cov explicitly fails in Py2 for XRay tests
- name: Test with pytest/coverage
if: ${{ matrix.python-version == 3.7 }}
run: |
make test-coverage
- name: "Upload coverage to Codecov"
if: ${{ matrix.python-version == 3.7 }}
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true

testserver:
name: Unit tests in Server Mode
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version: [2.7, 3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Start MotoServer
run: |
python setup.py sdist
docker run --rm -t --name motoserver -e TEST_SERVER_MODE=true -e AWS_SECRET_ACCESS_KEY=server_secret -e AWS_ACCESS_KEY_ID=server_key -v `pwd`:/moto -p 5000:5000 -v /var/run/docker.sock:/var/run/docker.sock python:3.7-buster /moto/travis_moto_server.sh &
python wait_for.py
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements-dev.txt') }}
- name: Install Linux dependencies
if: ${{ matrix.python-version == 3.8 }}
run: |
sudo apt-get install libxslt-dev libxml2-dev -y
- name: Install project dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Test ServerMode
env:
TEST_SERVER_MODE: ${{ true }}
run: |
make test-only
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [test, testserver]
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- name: Update project version
run: |
git fetch --unshallow
python update_version_from_git.py
- name: Build project
run: |
pip install wheel
python setup.py sdist bdist_wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}

68 changes: 0 additions & 68 deletions .travis.yml

This file was deleted.

7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ format:
test-only:
rm -f .coverage
rm -rf cover
@pytest -sv --cov=moto --cov-report html ./tests/ $(TEST_EXCLUDE)
pytest -sv ./tests/ $(TEST_EXCLUDE)

test-coverage:
rm -f .coverage
rm -rf cover
pytest -sv --cov=moto --cov-report xml ./tests/ $(TEST_EXCLUDE)

test: lint test-only

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Join the chat at https://gitter.im/awsmoto/Lobby](https://badges.gitter.im/awsmoto/Lobby.svg)](https://gitter.im/awsmoto/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Build Status](https://travis-ci.org/spulec/moto.svg?branch=master)](https://travis-ci.org/spulec/moto)
[![Build Status](https://github.com/spulec/moto/workflows/TestNDeploy/badge.svg)](https://github.com/spulec/moto/actions)
[![Coverage Status](https://coveralls.io/repos/spulec/moto/badge.svg?branch=master)](https://coveralls.io/r/spulec/moto)
[![Docs](https://readthedocs.org/projects/pip/badge/?version=stable)](http://docs.getmoto.org)
![PyPI](https://img.shields.io/pypi/v/moto.svg)
Expand Down Expand Up @@ -441,8 +441,8 @@ As a result, you need to add that entry to your host file for your tests to func

## Releases

Releases are done from travisci. Fairly closely following this:
https://docs.travis-ci.com/user/deployment/pypi/
Releases are done from Gitlab Actions. Fairly closely following this:
https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

- Commits to `master` branch do a dev deploy to pypi.
- Commits to a tag do a real deploy to pypi.
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ universal=1
[tool:pytest]
markers =
network: marks tests which require network connection

[coverage:run]
relative_files = True
Loading

0 comments on commit 8591eda

Please sign in to comment.