Skip to content

Commit

Permalink
Disable travis and update GitHub Actions (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinMaciaszek committed Jul 8, 2020
1 parent 38ae09f commit 07be757
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 64 deletions.
166 changes: 155 additions & 11 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,174 @@ on:
push:
branches:
- '*'
pull_request:
branches:
- master

jobs:
build:

test:
name: Build and test rfhub2
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

strategy:
matrix:
node-version: [13.x]
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2

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

- name: Cache Python packages
uses: actions/cache@v2
id: cache-pip
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt', '**/requirements-dev.txt', '**/requirements-postgres.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt', '**/requirements-dev.txt', '**/requirements-postgres.txt') }}
- name: Install Python dependencies
run: |
pip install -r requirements.txt -r requirements-dev.txt -r requirements-postgres.txt
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name : Tests
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -r requirements-postgres.txt
- name : Unit tests and coverage check
run: |
python -m coverage run --source rfhub2 -m unittest tests
python -m coverage xml
- name: Black check
run: |
black --check rfhub2 tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
fail_ci_if_error: true

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install yarn dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: frontend

- uses: nanasess/setup-chromedriver@master
- run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
- name: Build UI
run: ./build_ui.sh

- name: Build rfhub2 python package
run: python setup.py sdist bdist_wheel

- uses: actions/upload-artifact@master
with:
name: rfhub2_whl_${{ matrix.python-version }}
path: /home/runner/work/rfhub2/rfhub2/dist

# - name: Install rfhub2 in env
# run: pip install $(find dist -type f -iname "rfhub2-*.whl")[postgresql]

# - name: Run default Robot tests
# run: |
# robot -A tests/acceptance/conf/default.args -d results/ tests/acceptance

# - name: Upload default tests results
# if: failure()
# uses: actions/upload-artifact@v1
# with:
# name: Default tests
# path: /home/runner/work/rfhub2/rfhub2/results/

# - name: Run postgres Robot Framework tests
# run: |
# robot -A tests/acceptance/conf/postgres.args tests/acceptance

# - name: Upload postgres tests results
# if: failure()
# uses: actions/upload-artifact@v1
# with:
# name: Postgres tests
# path: /home/runner/work/rfhub2/rfhub2/log.html

package_check:
name: Install rfhub2 package in separate env
needs: test
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

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

- uses: actions/download-artifact@master
with:
name: rfhub2_whl_${{ matrix.python-version }}
path: /home/runner/work/rfhub2/rfhub2/dist

- name: Install rfhub2 in env
run: pip install $(find dist -type f -iname "rfhub2-*.whl")[postgresql]

push_and_deploy:
name: Push and deploy rfhub2
needs: package_check
if: github.extract_branch.outputs.branch == 'master'
runs-on: ubuntu-latest

steps:
- name: Set up Python 3.6
uses: actions/setup-python@v1
with:
python-version: 3.6

- uses: actions/download-artifact@master
with:
name: rfhub2_whl_3.6
path: /home/runner/work/rfhub2/rfhub2/dist

- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}

- name: Deploy to Heroku
uses: Suvink/[email protected]
with:
heroku_app_name: rfhub2-demo
heroku_email: [email protected]
dontuseforce: false
env:
HEROKU_TOKEN: '${{ secrets.HEROKU_AUTH_TOKEN }}'
BOT_TOKEN: '${{ secrets.BOT_TOKEN }}'
CHAT_ID: '${{ secrets.CHAT_ID }}'
67 changes: 67 additions & 0 deletions .github/workflows/rfhub2_push_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: rfhub2-push-and-deploy

on:
push:
branches:
- master
paths:
- 'rfhub2/version.py'

jobs:
push:
name: Push rfhub2 to PyPI
if: steps.extract_branch.outputs.branch == 'master'
needs: test
runs-on: ubuntu-latest
node-version: 13.x
python-version: 3.8

steps:
- uses: actions/checkout@v2

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

- name: Cache Python packages
uses: actions/cache@v1
id: cache-pip
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/requirements-dev.txt', '**/requirements-postgres.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/requirements-dev.txt', '**/requirements-postgres.txt') }}
- name: Use Node.js ${{ node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ node-version }}

- name: Install yarn dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: frontend

- name: Build UI
run: ./build_ui.sh

- name: Build rfhub2 python package
run: python setup.py sdist bdist_wheel

- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}

- name: Deploy to Heroku
uses: Suvink/[email protected]
with:
heroku_app_name: rfhub2-demo
heroku_email: [email protected]
dontuseforce: false
env:
HEROKU_TOKEN: '${{ secrets.HEROKU_AUTH_TOKEN }}'
BOT_TOKEN: '${{ secrets.BOT_TOKEN }}'
CHAT_ID: '${{ secrets.CHAT_ID }}'
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ To create frontend build and add its files to rfhub2 package static files direct
```
./build_ui.sh
```
You can specify *clean* parameter, if there is need to clean static files
```
./build_ui.sh clean
```

### Populate application with data
To populate application running on localhost:
Expand Down
7 changes: 5 additions & 2 deletions build_ui.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash
# !!!Please use clean paramater for this bash script if you need to clean static files.!!!
pushd frontend
yarn build
popd
rm -r rfhub2/static/*
rm rfhub2/templates/index.html
if [ "$1" == "clean" ]; then
rm -r rfhub2/static/*
rm rfhub2/templates/index.html
fi
cp -r frontend/build/* rfhub2/static
mv rfhub2/static/index.html rfhub2/templates/index.html
1 change: 0 additions & 1 deletion tests/acceptance/conf/default.args
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# default arguments; any other argument files should include
# this file.
-C ansi
--variable ACTIVATE_VENV:. atests-venv/bin/activate &&
1 change: 0 additions & 1 deletion tests/acceptance/conf/postgres.args
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# default arguments; any other argument files should include
# this file.
-C ansi
--variable ACTIVATE_VENV:. atests-venv/bin/activate &&
--variable DB_URI:RFHUB_DB_URI=postgresql://postgres:postgres@localhost:5432/postgres
1 change: 0 additions & 1 deletion tests/acceptance/conf/venv_wrapper.args
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# default arguments; any other argument files should include
# this file.
-C ansi
--variable ACTIVATE_VENV:
4 changes: 2 additions & 2 deletions tests/acceptance/resources/e2e_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Library SeleniumLibrary

*** Keywords ***
Open Browser With App On Mainpage
Open Browser url=localhost:8000 browser=gc
Open Browser http://localhost:8000 Headless Chrome
Maximize Browser Window

Navigate To Main Page
Go To localhost:8000
Go To http://localhost:8000

Collections Count On Main Page Should Be ${n}
Reload Page
Expand Down
6 changes: 3 additions & 3 deletions tests/acceptance/resources/keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Start Rfhub2
... As a side effect this creates a suite variable named \${rfhub process},
... which is used by the 'Stop rfhub2' keyword.
Remove File ${DB_PATH}
${rfhub2_process} Start Process ${ACTIVATE_VENV} ${DB_URI} rfhub2
${rfhub2_process} Start Process ${DB_URI} rfhub2
... shell=True stdout=api_logs.log stderr=stderr_logs.log
Set Suite Variable ${rfhub2_process}
Wait Until Keyword Succeeds 20 seconds 0.5 second
Expand All @@ -32,15 +32,15 @@ Run Cli Package With Options
... Attempt to run the rfhub2-cli package with the given options
... The stdout of the process will be in a test suite
... variable named \${output}
${output} Run ${ACTIVATE_VENV} rfhub2-cli ${options}
${output} Run rfhub2-cli ${options}
Set Suite Variable ${output}

Run Cli Package
[Documentation]
... Attempt to run the rfhub2-cli package with the default options
... The stdout of the process will be in a test suite
... variable named \${output}
${output} Run ${ACTIVATE_VENV} rfhub2-cli
${output} Run rfhub2-cli
Set Suite Variable ${output}

Output Should Contain
Expand Down

0 comments on commit 07be757

Please sign in to comment.