Skip to content

Commit

Permalink
Set up GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Adam committed Jul 25, 2021
1 parent dd1184c commit 4781fff
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 105 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Test & publish package

on: [push, pull_request]

jobs:

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- 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 coverage coveralls
pip install -r requirements.txt
- name: Run tests
run: |
python -m coverage run --branch --source=prometheus_flask_exporter -m unittest discover -s tests -v
- name: Upload coverage report
if: always() && matrix.python-version == '3.9'
run: |
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

integration:
runs-on: ubuntu-latest
needs: test
strategy:
fail-fast: false
matrix:
include:
- testname: gunicorn
- testname: gunicorn-internal
- testname: gunicorn-app-factory
- testname: uwsgi
- testname: uwsgi-lazy-apps
- testname: wsgi
- testname: connexion-pydantic
- testname: restful-with-blueprints
- testname: restful-return-none
- testname: restplus-default-metrics
- testname: flask-httpauth
- testname: reload
steps:
- uses: actions/checkout@v2
- name: Run integration test for ${{ matrix.testname }}
run: |
sh examples/${{ matrix.testname }}/run_tests.sh
publish:
runs-on: ubuntu-latest
needs: integration
steps:
- name: Install dependencies
run: |
pip install build
- name: Build package
run: |
python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

verify:
runs-on: ubuntu-latest
needs: publish
steps:
- name: Verify installation
run: |
pip install prometheus-flask-exporter
96 changes: 0 additions & 96 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/gunicorn-app-factory/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docker run -d --name gunicorn-app-factory-sample -p 4000:4000 gunicorn-app-facto
echo 'Waiting for Gunicorn to start...'

for _ in $(seq 1 10); do
PROCESS_COUNT=$(docker exec -it gunicorn-app-factory-sample sh -c 'pgrep -a gunicorn | wc -l')
PROCESS_COUNT=$(docker exec gunicorn-app-factory-sample sh -c 'pgrep -a gunicorn | wc -l')
if [ $PROCESS_COUNT -ge 5 ]; then
break
fi
Expand Down
2 changes: 1 addition & 1 deletion examples/gunicorn-internal/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docker run -d --name gunicorn-internal-sample -p 4000:4000 -p 9200:9200 gunicorn
echo 'Waiting for Gunicorn to start...'

for _ in $(seq 1 10); do
PROCESS_COUNT=$(docker exec -it gunicorn-internal-sample sh -c 'pgrep -a gunicorn | wc -l')
PROCESS_COUNT=$(docker exec gunicorn-internal-sample sh -c 'pgrep -a gunicorn | wc -l')
if [ $PROCESS_COUNT -ge 5 ]; then
break
fi
Expand Down
2 changes: 1 addition & 1 deletion examples/gunicorn/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docker run -d --name gunicorn-sample -p 4000:4000 -p 9200:9200 gunicorn-sample >
echo 'Waiting for Gunicorn to start...'

for _ in $(seq 1 10); do
PROCESS_COUNT=$(docker exec -it gunicorn-sample sh -c 'pgrep -a gunicorn | wc -l')
PROCESS_COUNT=$(docker exec gunicorn-sample sh -c 'pgrep -a gunicorn | wc -l')
if [ $PROCESS_COUNT -ge 5 ]; then
break
fi
Expand Down
2 changes: 1 addition & 1 deletion examples/pytest-app-factory/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _fail() {
}

docker build -f Dockerfile -t pytest-sample ../../. > /dev/null || _fail
docker run --rm -it --name pytest-sample pytest-sample py.test test
docker run --rm --name pytest-sample pytest-sample py.test test

if [ "$?" != "0" ]; then
echo 'Failed to execute the tests'
Expand Down
4 changes: 2 additions & 2 deletions examples/reload/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ if [ "$?" != "0" ]; then
fi

echo 'Changing the server...'
docker exec -it reload-sample sed -i "s#@app.route('/test')#@app.route('/changed')#" /var/flask/example.py
docker exec -it reload-sample sed -i "s#@app.route('/ping')#@app.route('/ping2')#" /var/flask/example.py
docker exec reload-sample sed -i "s#@app.route('/test')#@app.route('/changed')#" /var/flask/example.py
docker exec reload-sample sed -i "s#@app.route('/ping')#@app.route('/ping2')#" /var/flask/example.py

echo 'Waiting for the server to apply the changes...'

Expand Down
2 changes: 1 addition & 1 deletion examples/uwsgi-lazy-apps/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ docker run -d --name uwsgi-lazy-apps-sample -p 4000:4000 uwsgi-lazy-apps-sample
echo 'Waiting for uwsgi [lazy apps] to start...'

for _ in $(seq 1 10); do
PROCESS_COUNT=$(docker exec -it uwsgi-lazy-apps-sample sh -c 'pgrep -a uwsgi | wc -l')
PROCESS_COUNT=$(docker exec uwsgi-lazy-apps-sample sh -c 'pgrep -a uwsgi | wc -l')
if [ $PROCESS_COUNT -ge 5 ]; then
break
fi
Expand Down
2 changes: 1 addition & 1 deletion examples/uwsgi/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docker run -d --name uwsgi-sample -p 4000:4000 -p 9200:9200 uwsgi-sample > /dev/
echo 'Waiting for uwsgi to start...'

for _ in $(seq 1 10); do
PROCESS_COUNT=$(docker exec -it uwsgi-sample sh -c 'pgrep -a uwsgi | wc -l')
PROCESS_COUNT=$(docker exec uwsgi-sample sh -c 'pgrep -a uwsgi | wc -l')
if [ $PROCESS_COUNT -ge 5 ]; then
break
fi
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
Expand Down

0 comments on commit 4781fff

Please sign in to comment.