Skip to content

Commit

Permalink
Merge pull request #1166 from tobias-urdin/4.4-gha
Browse files Browse the repository at this point in the history
Migrate CI to Github Actions
  • Loading branch information
tobias-urdin authored Jul 27, 2021
2 parents 450e956 + 5bdac90 commit 9a57712
Show file tree
Hide file tree
Showing 20 changed files with 249 additions and 142 deletions.
56 changes: 56 additions & 0 deletions .github/actions/gnocchi-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM ubuntu:20.04
ENV GNOCCHI_WORKSPACE /github/workspace
ENV DEBIAN_FRONTEND noninteractive

#NOTE(tobias-urdin): need gnupg for apt-key
RUN apt-get update -y && apt-get install -qy gnupg software-properties-common
RUN add-apt-repository -y ppa:deadsnakes/ppa
RUN apt-get update -y && apt-get install -qy \
locales \
git \
wget \
curl \
nodejs \
npm \
python3 \
python3-dev \
python3-pip \
python3.6 \
python3.6-dev \
# Needed for uwsgi core routing support
build-essential \
libffi-dev \
libpq-dev \
postgresql \
memcached \
mysql-client \
mysql-server \
# For Ceph
librados-dev \
liberasurecode-dev \
python3-rados \
ceph \
# For prometheus
libsnappy-dev \
libprotobuf-dev \
# For redis
redis-server \
&& rm -rf /var/lib/apt/lists/*

#NOTE(sileht): really no utf-8 in 2017 !?
ENV LANG en_US.UTF-8
RUN update-locale
RUN locale-gen $LANG

#NOTE(sileht): Upgrade python dev tools
RUN python3 -m pip install -U pip tox virtualenv
RUN python3.6 -m pip install -U pip tox virtualenv

RUN npm install [email protected] --global

RUN groupadd --gid 1001 tester
RUN useradd --uid 1001 --gid 1001 --home-dir $GNOCCHI_WORKSPACE --shell /bin/bash tester
USER tester

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
12 changes: 12 additions & 0 deletions .github/actions/gnocchi-container/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: 'Gnocchi Container'
description: 'Run command inside Gnocchi Container'
author: 'Tobias Urdin'
inputs:
command:
description: 'Command to run'
required: true
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.command }}
2 changes: 2 additions & 0 deletions .github/actions/gnocchi-container/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
$@
65 changes: 65 additions & 0 deletions .github/workflows/gnocchi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Gnocchi

on: pull_request

# NOTE(tobias-urdin): If you change any jobs make sure to modify
# the Mergify.io config in .mergify.yml to include the jobs!

jobs:
doc:
runs-on: ubuntu-latest
strategy:
matrix:
env:
- docs
- docs-gnocchi-web
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: ./.github/actions/gnocchi-container
with:
command: tox -e ${{ matrix.env }}

check:
runs-on: ubuntu-latest
strategy:
matrix:
env:
- pep8
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/gnocchi-container
with:
command: tox -e ${{ matrix.env }}

test:
runs-on: ubuntu-latest
strategy:
matrix:
python:
- py36
- py38
env:
- mysql-ceph-upgrade-from-4.3
- postgresql-file-upgrade-from-4.3
- mysql-file
- mysql-swift
- mysql-s3
- mysql-ceph
- postgresql-file
- postgresql-swift
- postgresql-s3
- postgresql-ceph
exclude:
- env: mysql-ceph-upgrade-from-4.3
python: py36
- env: mysql-ceph
python: py36
- env: postgresql-ceph
python: py36
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/gnocchi-container
with:
command: tox -e ${{ matrix.python }}-${{ matrix.env }}
72 changes: 36 additions & 36 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,30 @@ pull_request_rules:
conditions:
- label!=work-in-progress
- '#approved-reviews-by>=1'
- status-success=continuous-integration/travis-ci/pr
- status-success=doc (docs)
- status-success=doc (docs-gnocchi-web)

- status-success=check (pep8)

- status-success=test (py36-postgresql-file-upgrade-from-4.3)
- status-success=test (py36-mysql-file)
- status-success=test (py36-mysql-swift)
- status-success=test (py36-mysql-s3)
- status-success=test (py36-postgresql-file)
- status-success=test (py36-postgresql-swift)
- status-success=test (py36-postgresql-s3)

- status-success=test (py38-mysql-ceph-upgrade-from-4.3)
- status-success=test (py38-postgresql-file-upgrade-from-4.3)
- status-success=test (py38-mysql-file)
- status-success=test (py38-mysql-swift)
- status-success=test (py38-mysql-s3)
- status-success=test (py38-mysql-ceph)
- status-success=test (py38-postgresql-file)
- status-success=test (py38-postgresql-swift)
- status-success=test (py38-postgresql-s3)
- status-success=test (py38-postgresql-ceph)

- name: automatic merge backports from Mergify
actions:
merge:
Expand All @@ -19,48 +42,25 @@ pull_request_rules:
- base~=^stable/.*
- label!=work-in-progress
- author=mergify[bot]
- status-success=continuous-integration/travis-ci/pr
- status-success=Travis CI - Pull Request

- name: dismiss reviews on additional commit
actions:
dismiss_reviews: {}
conditions: []

# Backports to stable branches
- actions:
backport:
branches:
- stable/3.0
conditions:
- label=backport-to-3.0
name: backport stable/3.0
- actions:
backport:
branches:
- stable/3.1
conditions:
- label=backport-to-3.1
name: backport stable/3.1
- actions:
backport:
branches:
- stable/4.0
conditions:
- label=backport-to-4.0
name: backport stable/4.0
- actions:
backport:
branches:
- stable/4.1
conditions:
- label=backport-to-4.1
name: backport stable/4.1
- actions:
backport:
branches:
- stable/4.2
- stable/4.3
conditions:
- label=backport-to-4.2
name: backport stable/4.2
- label=backport-to-4.3
name: backport stable/4.3
- actions:
backport:
branches:
- stable/4.3
- stable/4.4
conditions:
- label=backport-to-4.3
name: backport stable/4.3
- label=backport-to-4.4
name: backport stable/4.4
73 changes: 6 additions & 67 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,16 @@
os: linux
dist: bionic
language: generic
sudo: required

services:
- docker

cache:
directories:
- ~/.cache/pip
env:
- TARGET: pep8
- TARGET: docs
- TARGET: docs-gnocchi-web

- TARGET: py36-mysql-ceph-upgrade-from-4.3
- TARGET: py36-postgresql-file-upgrade-from-4.3

- TARGET: py36-mysql
- TARGET: py36-postgresql

before_script:
# NOTE(sileht): We need to fetch all tags/branches for documentation.
# For the multiversioning, we change all remotes refs to point to
# the pull request checkout. So the "master" branch will be the PR sha and not
# real "master" branch. This ensures the doc build use the PR code for initial
# doc setup.
- if \[ "$TRAVIS_PULL_REQUEST" != "false" -o -n "$TRAVIS_TAG" \]; then
set -x;
case $TARGET in
docs*)
git config --get-all remote.origin.fetch;
git config --unset-all remote.origin.fetch;
git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/*;
git config --get-all remote.origin.fetch;
git fetch --unshallow --tags;
;;
esac ;
case $TARGET in
docs-gnocchi-web)
git branch -a | sed -n "/\/HEAD /d; /\/master$/d; s,remotes/origin/,,p;" | xargs -i git branch {} origin/{} ;
git branch -D master;
git checkout -b master;
git remote set-url origin file:///home/tester/src;
git ls-remote --heads --tags | grep heads;
;;
esac ;
set +x;
fi
install:
- if \[ "$TRAVIS_PULL_REQUEST" != "false" -o -n "$TRAVIS_TAG" \]; then
docker pull gnocchixyz/ci-tools:latest;
fi
script:
- if \[ "$TRAVIS_PULL_REQUEST" != "false" -o -n "$TRAVIS_TAG" \]; then
docker run -v ~/.cache/pip:/home/tester/.cache/pip -v $(pwd):/home/tester/src gnocchixyz/ci-tools:latest tox -e ${TARGET} ;
fi

notifications:
email: false
irc:
on_success: change
on_failure: always
skip_join: true
channels:
- "irc.freenode.org#gnocchi"

before_deploy:
- pip install --user --upgrade pip
- pip install --user --upgrade six
- sudo apt update -y
- sudo apt install -y python3 python3-pip python3-virtualenv
- python3 -m virtualenv env
- source env/bin/activate

deploy:
provider: pypi
user: jd
username: jd
password:
secure: c+Ccx3SHCWepiy0PUxDJ7XO9r3aNYnHjkzxF5c/kjV8QaCJayAJEgXJnBKhvjroqwgn7JPUgpD6QdSWdB4FqjbZYQ3I3oHOO1YL0vYYa8wHG5HuMsMp4J8qvzgs3QNQDECPI1mXsPevn3VMfGszUN+6BQrHB3FbZsTtOmE+Kmgok5NCT+obsfEhVea/UOD0XFUkVW9VJhPjQ2ytvYvFIc46/73GQf2Er/5DCa/4GGDEBSD++bDJgp3kQj438xslCAFeZWDwGsa+cTc43PI0Y0+E144ySVY7QyVbZ1B66a1BGWVrXJuM+gW/eIBCMN1FJXmD7CDdPa22azKI8dfMF7qaH3Oiv3cVovPWpubOvhTUHUFwG8+W7Fx+zUKktCWiLer/fZvEd3W8tcgby2kNOdcUfKfDB2ImZJ+P694/OJ4jJ8T5TQerruNoP2OstzcBMon77Ry0XawXR15SZd4JhbqhSi+h7XV6EYmct1UN4zoysA7fx/cWHcBxdnm2G6R0gzmOiiGUd74ptU8lZ3IlEP6EZckK/OZOdy1I8EQeUe7aiTooXZDAn07iPkDZliYRr2e36ij/xjtWCe1AjCksn/xdKfHOKJv5UVob495DU2GuNObe01ewXzexcnldjfp9Sb8SVEFuhHx6IvH5OC+vAq+BVYu2jwvMcVfXi3VSOkB4=
skip_existing: true
Expand Down
4 changes: 0 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Gnocchi - Metric as a Service
===============================

.. image:: https://travis-ci.org/gnocchixyz/gnocchi.png?branch=master
:target: https://travis-ci.org/gnocchixyz/gnocchi
:alt: Build Status

.. image:: https://badge.fury.io/py/gnocchi.svg
:target: https://badge.fury.io/py/gnocchi

Expand Down
22 changes: 15 additions & 7 deletions doc/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ When opening a pull-request, make sure that:
`git rebase --interactive` and/or `git commit --amend`.
* We recommend using `git pull-request`_ to send your pull-requests.

All sent pull-requests are checked using `Travis-CI`_, which is in charge of
All sent pull-requests are checked using GitHub Actions, which is in charge of
running the tests suites. There are different scenarios being run: `PEP 8`_
compliance tests, upgrade tests, unit and functional tests.

All pull-requests must be reviewed by `members of the Gnocchi project`_.

When a pull-request is approved by at least two of the members and when
Travis-CI confirms that all the tests run fine, the patch will be merged.
When a pull-request is approved by a team member and the GitHub Actions
confirms that all the tests run fine, the patch will be merged.

The Gnocchi project leverages `Mergify`_ in order to schedule the merge of the
different pull-requests. Mergify is in charge of making sure that the
Expand All @@ -52,7 +52,6 @@ make sure that no pull-request can break another one.

.. _`git pull-request`: https://github.com/jd/git-pull-request
.. _`PEP 8`: https://www.python.org/dev/peps/pep-0008/
.. _`Travis-CI`: http://travis-ci.org
.. _`members of the Gnocchi project`: https://github.com/orgs/gnocchixyz/people
.. _`Mergify`: https://mergify.io
.. _`Gnocchi's Mergify dashboard`: https://gh.mergify.io/gnocchixyz
Expand All @@ -66,16 +65,25 @@ a virtual environment for each test environment, so make sure you are using an
up to date version of `virtualenv <https://pypi.python.org/pypi/virtualenv>`_.

Different test environments and configurations can be found by running the
``tox -l`` command. For example, to run tests with Python 3.7, PostgreSQL as
``tox -l`` command. For example, to run tests with Python 3.8, PostgreSQL as
indexer, and file as storage backend:

::

tox -e py37-postgresql-file
tox -e py38-postgresql-file


To run tests with MySQL as indexer, and Ceph as storage backend:

::

tox -e py37-mysql-ceph
tox -e py38-mysql-ceph


In order to run the tests like they do in the CI, you could create
a user with UID 1001 and GID 1001 and run a command like this

::
docker run -v $(pwd):/github/workspace gnocchixyz/ci-tools:latest tox

Make sure the machine executing the tests has as least 4 GB of RAM.
2 changes: 1 addition & 1 deletion doc/source/releasenotes/3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
===================================

.. release-notes::
:branch: origin/stable/3.0
:branch: origin/eol/3.0
2 changes: 1 addition & 1 deletion doc/source/releasenotes/3.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
===================================

.. release-notes::
:branch: origin/stable/3.1
:branch: origin/eol/3.1
2 changes: 1 addition & 1 deletion doc/source/releasenotes/4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
===================================

.. release-notes::
:branch: origin/stable/4.0
:branch: origin/eol/4.0
Loading

0 comments on commit 9a57712

Please sign in to comment.