From d9cb6ff3658af9ae272900ca998baa2613271f10 Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Mon, 5 Aug 2019 11:56:49 +0300 Subject: [PATCH 1/6] add travis integration --- .travis.yml | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tox.ini | 5 +++ 2 files changed, 93 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..a71e6fe21 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,88 @@ +sudo: required +dist: xenial +language: python + +python: 3.6 +install: true + +git: + depth: false + quiet: true + +services: docker + +stages: + - name: tests + if: type IN (push, pull_request) + - name: uitests + if: type IN (pull_request) + +jobs: + include: + - stage: tests + name: "Code Style Check" + python: 3.6 + before_script: + - pip install tox-travis + script: tox -e flake8 + - stage: tests + name: "Unit Tests" + python: 3.6 + before_script: + - pip install tox-travis + script: tox + - stage: tests + name: "Documentation Tests" + python: 3.6 + before_script: + - pip install tox-travis + - wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz + - tar -xvzf geckodriver-v0.24.0-linux64.tar.gz + - rm geckodriver-v0.24.0-linux64.tar.gz + - chmod +x geckodriver + - sudo cp geckodriver /usr/local/bin/ + - geckodriver --version + - sudo apt-get update + - sudo apt-get install firefox -y + script: + - tox -e docs + - stage: tests + name: "Python Code Security Tests" + python: 3.6 + before_script: + - pip install tox-travis + script: tox -e bandit + - stage: uitests + name: "Firefox UI Tests" + python: 3.6 + before_script: + - pip install tox-travis + - wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz + - tar -xvzf geckodriver-v0.24.0-linux64.tar.gz + - rm geckodriver-v0.24.0-linux64.tar.gz + - chmod +x geckodriver + - sudo cp geckodriver /usr/local/bin/ + - geckodriver --version + - sudo apt-get update + - sudo apt-get install firefox -y + script: + - tox -e firefox + - stage: uitests + name: "Chrome UI Tests" + python: 3.6 + before_script: + - pip install tox-travis + - sudo apt-get -y update + - sudo apt-get -y install google-chrome-stable + - wget https://chromedriver.storage.googleapis.com/75.0.3770.140/chromedriver_linux64.zip + - unzip chromedriver_linux64.zip + - rm chromedriver_linux64.zip + - chmod +x chromedriver + - sudo cp chromedriver /usr/local/bin/ + - sudo chromedriver --version + script: + - tox -e chrome + + +notifications: + email: false diff --git a/tox.ini b/tox.ini index 62bd90e73..4a07947af 100644 --- a/tox.ini +++ b/tox.ini @@ -59,3 +59,8 @@ setenv = deps = .[ui_test] commands = py.test -vvv ui_tests/test_frontend_chrome.py ui_tests/test_session_chrome.py + +[travis] +unignore_outcomes = True +python = + 3.6: py36 \ No newline at end of file From ed0035635d836f4b7951214d0464c694ec9eb946 Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Mon, 5 Aug 2019 11:57:05 +0300 Subject: [PATCH 2/6] github templates --- .github/ISSUE_TEMPLATE/bug_report.md | 27 +++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 17 ++++++++++ .../ISSUE_TEMPLATE/general-issue-template.md | 17 ++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 34 +++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/general-issue-template.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..edc179148 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,27 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +#### Describe the bug + + +#### To Reproduce +Steps to reproduce the behaviour: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +#### Expected behavior + + +#### Screenshots + + +#### Additional context + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..d189ad628 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' + +--- + +#### Proposed solution + + +#### DoD (Definition of Done) + + +#### Testing + diff --git a/.github/ISSUE_TEMPLATE/general-issue-template.md b/.github/ISSUE_TEMPLATE/general-issue-template.md new file mode 100644 index 000000000..a6c76de51 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/general-issue-template.md @@ -0,0 +1,17 @@ +--- +name: General issue template +about: Describe this issue template's purpose here. +title: '' +labels: '' +assignees: '' + +--- + +#### Description + + +#### DoD (Definition of Done) + + +#### Testing + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..98c64b348 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,34 @@ +### Description + + + +### Related issues + + +### Type of change + + + + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] This change requires a documentation update (this needs a follow up PR) + +### Changes Made + + + +### Testing + + + + + +- [ ] Unit Tests +- [ ] Integration Tests +- [ ] Tests do not apply +- [ ] Needs testing (start an issue or do a follow up PR about it) + +### Mentions + From 7c6c4b1cae91349f15616916663b82947bf02d21 Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Mon, 5 Aug 2019 11:59:33 +0300 Subject: [PATCH 3/6] update contributing guidelines --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aba5460f8..99a2f0d6d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,9 @@ If you're reading this, it means you saw something that is not right, you want t ### Testing -We have unit tests and currently no integration tests, and always in need of more. In our Git workflow unit tests are run on every Push and Merge Request. +We have a handful of unit tests and UI tests. In our Git workflow unit tests are run on every Push and Pull Request, while UI tests run on every Pull Request. + +For more information this guide on [swift-browser-ui testing](https://swift-browser-ui.readthedocs.io/en/latest/testing.html) might be worth a read. ### Submitting Issues @@ -12,7 +14,7 @@ We have templates for submitting new issues, that you can fill out. For example ### Submitting changes -When you made some changes you are happy with please send a [GitLab merge Request to swift-browser-ui](https://gitlab.csc.fi/CSCCSDP/swift-browser-ui/merge_requests/new) with a clear list of what you've done (read more about [merge requests](https://docs.gitlab.com/ee/gitlab-basics/add-merge-request.html)). When you create that Merge Request, we will forever be in your debt if you check previous docs for typos. +When you made some changes you are happy with please send a [GitLab merge Request to swift-browser-ui](https://github.com/CSCfi/swift-browser-ui/pull_requests/new/devel) with a clear list of what you've done (read more about [pull requests]https://help.github.com/en/articles/about-pull-requests)). When you create that Merge Request, we will forever be in your debt if you check previous docs for typos. Please follow our Git branches model and coding conventions (both below), and make sure all of your commits are atomic (preferably one feature per commit) and it is recommended a Merge Request addresses one functionality or fixes one bug. From 94a5ff700c43c5e4557dc7a6edc0557cc8d98c4b Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Mon, 5 Aug 2019 13:03:48 +0300 Subject: [PATCH 4/6] update chromedriver --- .travis.yml | 4 +++- ui_tests/test_frontend_chrome.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a71e6fe21..ea38e5652 100644 --- a/.travis.yml +++ b/.travis.yml @@ -72,9 +72,11 @@ jobs: python: 3.6 before_script: - pip install tox-travis + - curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add + - echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list.d/google-chrome.list - sudo apt-get -y update - sudo apt-get -y install google-chrome-stable - - wget https://chromedriver.storage.googleapis.com/75.0.3770.140/chromedriver_linux64.zip + - wget https://chromedriver.storage.googleapis.com/76.0.3809.68/chromedriver_linux64.zip - unzip chromedriver_linux64.zip - rm chromedriver_linux64.zip - chmod +x chromedriver diff --git a/ui_tests/test_frontend_chrome.py b/ui_tests/test_frontend_chrome.py index c5d93ee9c..4e9fffe96 100644 --- a/ui_tests/test_frontend_chrome.py +++ b/ui_tests/test_frontend_chrome.py @@ -16,7 +16,7 @@ from .common import wait_for_clickable -class TestFirefoxFrontend(ChromiumTestClass): +class TestChromeFrontend(ChromiumTestClass): """Test the frontend wiht chrome.""" @pytest.mark.timeout(60) From ea797278ea3c7f73c2b5dd13f8a10f610e199ffa Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Mon, 5 Aug 2019 13:13:29 +0300 Subject: [PATCH 5/6] add badges --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index dc8f9cdb6..b7d598f24 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ ## swift-browser-ui +[![Build Status](https://travis-ci.org/CSCfi/swift-browser-ui.svg?branch=master)](https://travis-ci.org/CSCfi/swift-browser-ui) +[![Coverage Status](https://coveralls.io/repos/github/CSCfi/swift-browser-ui/badge.svg?branch=maste)](https://coveralls.io/github/CSCfi/swift-browser-ui?branch=maste) +[![Documentation Status](https://swift-browser-ui.readthedocs.io/en/latest/?badge=latest)](https://swift-browser-ui.readthedocs.io/en/latest/?badge=latest) + ### Description A web frontend for browsing and downloading objects saved in [SWIFT](https://docs.openstack.org/swift/latest/) From 436dffcbc20455627a0ce1a45d96ccb33d88ff14 Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Mon, 5 Aug 2019 13:20:21 +0300 Subject: [PATCH 6/6] add coveralls integration --- .travis.yml | 2 +- tests/coveralls.py | 17 +++++++++++++++++ tox.ini | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/coveralls.py diff --git a/.travis.yml b/.travis.yml index ea38e5652..f219bb1cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ jobs: python: 3.6 before_script: - pip install tox-travis - script: tox + script: tox -e pytest - stage: tests name: "Documentation Tests" python: 3.6 diff --git a/tests/coveralls.py b/tests/coveralls.py new file mode 100644 index 000000000..6fedf2167 --- /dev/null +++ b/tests/coveralls.py @@ -0,0 +1,17 @@ +#!/bin/env/python + +import os +from subprocess import call +import sys + +# Run converalls command only on Travis +# Solution provided by +# https://stackoverflow.com/questions/32757765/conditional-commands-in-tox-tox-travis-ci-and-coveralls + +if __name__ == '__main__': + if 'TRAVIS' in os.environ: + rc = call('coveralls') + sys.stdout.write("Coveralls report from TRAVIS CI.\n") + # raise SystemExit(rc) + else: + sys.stdout.write("Not on TRAVIS CI.\n") diff --git a/tox.ini b/tox.ini index 4a07947af..adc241dd8 100644 --- a/tox.ini +++ b/tox.ini @@ -31,10 +31,12 @@ commands = python -m ui_tests.ui_take_screenshots [testenv:pytest] basepython = python3.6 +passenv = TRAVIS TRAVIS_* deps = .[test] -rrequirements.txt commands = py.test -x --cov=swift_browser_ui tests/ --cov-fail-under=75 + python {toxinidir}/tests/coveralls.py [testenv] basepython = python3.6