Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Commit

Permalink
Execute Selenium Tests after GithubPage Deployment (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolte committed Jan 6, 2019
1 parent 634cc90 commit 7c9c057
Show file tree
Hide file tree
Showing 13 changed files with 299 additions and 17 deletions.
54 changes: 49 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ aliases:
sudo apt install -y build-essential libssl-dev libpython-dev python python-pip
sudo pip install tox
# @see http://chromedriver.chromium.org/
# install chromedriver for selenium tests
- &run_task_install_chromedriver_dependencies
run:
name: install chromedriver
command: |
wget -q https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip -O /tmp/chromedriver_linux64.zip
mkdir ${HOME}/chromedriver
unzip /tmp/chromedriver_linux64.zip -d ${HOME}/chromedriver
chmod +x ${HOME}/chromedriver
sudo sh /tmp/workspaces/build/ci-scripts/install_selenium_dependencies.sh
jobs:

# generate a changelog from existing github commits/pull requests
Expand Down Expand Up @@ -164,9 +176,10 @@ jobs:
- run:
name: execute the pytests documentation
command: |
tox -e test
tox -e py36-test,py27-test
- store_test_results:
path: .tox/test/tmp/reports

finializebuild:
<<: *container_python
working_directory: /tmp/workspaces/build
Expand All @@ -177,14 +190,15 @@ jobs:
- attach_workspace:
at: /tmp/workspaces
- run:
name: execute the pytests documentation
name: Push changes to github if release build
command: |
if [ -f /tmp/workspaces/release_build.txt ]; then
echo "File not found!"
releaseBranch="$(cat /tmp/workspaces/release_build.txt)"
git push origin release/$releaseBranch
git push origin ${CIRCLE_BRANCH}
fi
check_grade_up_build:
<<: *container_python
working_directory: /tmp/workspaces/build
Expand All @@ -194,11 +208,11 @@ jobs:
- *run_task_install_tox_dependencies
- checkout
- run:
name: debug
name: install bumpversion
command: |
sudo pip install bumpversion
- run:
name: debug
name: check is release build
command: |
GIT_COMMIT_DESC=$(git log --format=%B -n 1 $CIRCLE_SHA1)
echo $GIT_COMMIT_DESC
Expand All @@ -219,6 +233,7 @@ jobs:
paths:
- build/*
- release_build.txt

integrate_release:
<<: *container_releasemanager
working_directory: /tmp/workspaces/build
Expand Down Expand Up @@ -246,6 +261,7 @@ jobs:
root: /tmp/workspaces
paths:
- build/*

create_gh_release:
<<: *container_releasemanager
working_directory: /tmp/workspaces/build
Expand Down Expand Up @@ -275,12 +291,37 @@ jobs:
command: |
git push origin master
git push origin --delete ${CIRCLE_BRANCH}
execute_integration_tests:
<<: *container_python
working_directory: /tmp/workspaces/build
environment:
CHROMEDRIVER_VERSION: 2.45
TOX_TEST_ENV: github-py36-integrationtests
steps:
- attach_workspace:
at: /tmp/workspaces
- *run_task_install_tox_dependencies
- *run_task_install_chromedriver_dependencies
- run:
name: execute selenium integrationtests
command: |
export PATH=$PATH:${HOME}/chromedriver
tox -e ${TOX_TEST_ENV}
mkdir -p /tmp/workspaces/testreports
cp -r .tox/${TOX_TEST_ENV}/tmp/reports/ /tmp/workspaces/testreports
- store_test_results:
path: /tmp/workspaces/testreports
- persist_to_workspace:
root: /tmp/workspaces/
paths:
- testreports

workflows:
version: 2
build_and_test:
jobs:
- check_grade_up_build

- builddocs:
requires:
- check_grade_up_build
Expand Down Expand Up @@ -312,3 +353,6 @@ workflows:
- create_gh_release:
requires:
- generate-changelog
- execute_integration_tests:
requires:
- publishghpage
25 changes: 25 additions & 0 deletions ci-scripts/install_selenium_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
echo "==> Install common stuff missing from the slim base image..." && \
apt-get update && \
apt-get install -y --no-install-recommends \
gnupg \
dirmngr \
wget \
ca-certificates && \
rm -rf /var/lib/apt/lists/*

echo "==> Add Google repo for Chrome..."
wget -q -O- https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google.list

echo "==> Install prerequisite stuff..." && \
apt-get update && \
apt-get install -y --no-install-recommends \
python3-dev \
python3-pip \
xvfb \
libfontconfig \
libfreetype6 \
xfonts-scalable \
fonts-liberation \
google-chrome-stable
8 changes: 8 additions & 0 deletions docs/development/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Development
----------------------------------------------------

.. toctree::
:maxdepth: 2

projectstructure
process
122 changes: 122 additions & 0 deletions docs/development/process.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
.. _development-process:

Development Process
========================================================

.. _development-process-branch-model:

Branch Modell
------------------------------------------

As Branchmodel we use a mix of `Gitflow <https://datasift.github.io/gitflow/IntroducingGitFlow.html>`_ and `pull-requests <https://help.github.com/articles/about-pull-requests/>`_.
Gitflow is used for the Release Process, the ``master`` branch present the latest Published Release.
PullRequests are used for integrate external changes and ``feature`` branches into the :ref:`development-process-branch-model-develop`.


Feature Branch
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

New features will be develop in feature branches like ``feature/integrate-cuberite``.

.. warning::

Please dont use use ``feature/*`` branches in your production Environment.


.. _development-process-branch-model-develop:

Develop Branch
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The ``develop`` branch contains the latest unrelesed version from the template, mostly stable ;)

.. _development-process-branch-model-release:

Release Branch
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Master Branch
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The ``master`` present the latest published release.


.. _development-process-build:

Build
--------------------------------------------------------



.. _development-process-test:

Testing
----------------------------------------------------

Static tests
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. _development-process-test-unit:

Unit tests
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. _development-process-test-integrationtest:

Integrations tests
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



.. _development-process-release:

Releasing
----------------------------------------------------

You can start the Release process with some commit like:

.. code:: bash
git commit --allow-empty -m "[GradeUP] grade up the branch"
git push origin develop
| With pushing this commit the Release Pipeline will started automatically.
| **The Process**
* Update the version to new Release, see :ref:`development-process-release-versioning`
* create the :ref:`development-process-branch-model-release`
* prepare the :ref:`development-process-branch-model-develop` branch for next version.
* Create :ref:`development-process-publish-gh-release`
* Publish :ref:`development-process-publish-gh-page`
* execute :ref:`development-process-test-integrationtest`
* delete the :ref:`development-process-branch-model-release`


.. _development-process-release-versioning:

Versioning
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

| This project follows `semantic versioning`_.
| In the context of semantic versioning, consider the role contract to be defined by the role variables.
- Changes that require user intervention will increase the **major** version. This includes changing the default value of a role variable.
- Changes that do not require user intervention, but add backwards-compatible features, will increase the **minor** version.
- Bug fixes will increase the **patch** version.

.. _development-process-publish:

Publishing
----------------------------------------------------

.. _development-process-publish-gh-release:

Github Release
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. _development-process-publish-gh-page:

Github Page
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. include:: ../links.rst
52 changes: 52 additions & 0 deletions docs/development/projectstructure.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Project Structure
========================================================

Base Directory Structure
------------------------------------------------------

`.bumpversion.cfg`
Config file for `bumpversion`_ handled the `semantic versioning`_ process. More information at the :ref:`development-process` description.

`.circleci/config.yml`
| Used `CircleCI`_ for handle the :ref:`development-process-build`, :ref:`development-process-test`, :ref:`development-process-release` and :ref:`development-process-publish` steps.
| **Status:** |CircleCI build status|
`ci-scripts`
Folder for ci utility scripts like, install selenium.

`docs`
| This project is documentated with `sphinx-doc`_. The generated deployment will be published to `ReadTheDocs` and `nolte.github.io`.
| **Status:** |Documentation Status|
`.github`
This folder is used form the `GitHub Issue Templates <https://blog.github.com/2016-02-17-issue-and-pull-request-templates/>`_.

`it-tests`
This Folder contains `Selenium`_ based `pytest`_ integrations tests. Runned after a `nolte.github.io/cookiecutter-circleci <https://nolte.github.io/cookiecutter-circleci/>`_ deployment.

`tests`
Test for checking the CookieCutter Template generated projects, based on `pytest`_ and `pytest-cookies <https://github.com/hackebrot/pytest-cookies>`_.

`tox.ini`
Using `tox`_ for handle the different build and test configs.

.. list-table:: Important Tox Environments
:header-rows: 1

* - Tox Environment
- Description
* - {py27,py36}-test
- Start the local builds, used `pytest-cookies`_ for testing the `cookiecutter`_ template, see :ref:`development-process-test-unit`.
* - docs
- Generate the html `sphinx-doc`_. All required dependencies are listed in `requirementsDocs.txt`
* - py36-{github,readthedocs-latest,readthedocs-stable}-integrationtests
- Start the Selenium Integration Tests for existing deployments, some type of Smoke Tests, see :ref:`development-process-test-integrationtest`.


`.travis.yml`
| Build config for the `TravisCI`_ Job, used for testing different python versions.
| **Status:** |Travis CI build status|
.. _sphinx-doc: `link-sphinx`_

.. include:: ../links.rst
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Index

self
usage
development/index
9 changes: 9 additions & 0 deletions docs/links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@
:target: https://github.com/nolte/cookiecutter-circleci

.. _CircleCI: https://circleci.com
.. _Selenium: https://pytest-selenium.readthedocs.io/en/latest/index.html
.. _TravisCI: https://travis-ci.org
.. _bumpversion: https://github.com/peritus/bumpversion
.. _cookiecutter: https://cookiecutter.readthedocs.io
.. _link-sphinx: http://www.sphinx-doc.org
.. _pytest-cookies: https://github.com/hackebrot/pytest-cookies
.. _pytest: https://docs.pytest.org/en/latest/
.. _semantic versioning: http://semver.org/
.. _tox: https://tox.readthedocs.io/en/latest/
6 changes: 0 additions & 6 deletions docsRequirements.txt

This file was deleted.

12 changes: 12 additions & 0 deletions it-tests/test_smoke_deployment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest
import sys, os

@pytest.fixture
def chrome_options(chrome_options):
chrome_options.add_argument('headless')
return chrome_options

def test_example(selenium):
selenium.get(os.environ["SELENIUM_BASE_URL"])
# selenium.save_screenshot('/tmp/screenshot/sample_screenshot_1.png');
assert "Cookiecutter Template for circleci BuildJobs — Cookiecutter CircleCI Pipeline documentation" in selenium.title
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest-cookies==0.3.0
cookiecutter==1.6.0
6 changes: 6 additions & 0 deletions requirementsDocs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sphinx==1.8.3
sphinxcontrib-plantuml==0.14
sphinxcontrib-ansibleautodoc==0.0.5
sphinx_rtd_theme==0.4.2
PyYAML==3.13
m2r==0.2.1
2 changes: 2 additions & 0 deletions requirementsIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest==4.0.2
pytest-selenium==1.15.0

0 comments on commit 7c9c057

Please sign in to comment.