Преглед изворни кода

Merge pull request #76 from CapXilinx/master

Add Travis CI build, test, and auto-publish of doxygen documentation page
Martin Melik-Merkumians пре 9 година
родитељ
комит
3ad204776f

+ 48 - 0
.travis.yml

@@ -0,0 +1,48 @@
+# This will run on Travis' 'new' container-based infrastructure
+sudo: false
+os: linux
+dist: precise
+
+language: c
+
+# Blacklist
+branches:
+  except:
+    - gh-pages
+
+# Environment variables
+env:
+  global:
+    - GH_REPO_NAME: OpENer
+    - DOXYFILE: opener.doxyfile
+    - GH_REPO_REF: github.com/CapXilinx/OpENer.git
+    - secure: "RAyvtCis1g7WET5y0NsOsXt7eVLG0iNYoNNyJ+2XXy9BdcOFDsucWJAABAWyb2bf/lqeJ/tvmPRjAzPoQhId4zMxkLMKKEU6xXQqIoTSMsLOlb2R5WUVahnR/dHfoq3u3wXdmZZq/vRnDp9UXDDjyYDvSqIprpN0uvu666QLEGU="
+
+# Install dependencies
+addons:
+  apt:
+    packages:
+      - doxygen
+      - doxygen-doc
+      - doxygen-latex
+      - doxygen-gui
+      - graphviz
+
+#Prepare CppUTest from source, as package is not available
+before_script:
+  - cd $TRAVIS_BUILD_DIR/source
+  - chmod +x $TRAVIS_BUILD_DIR/travis_scripts/installCppUTestDependency.sh
+  - $TRAVIS_BUILD_DIR/travis_scripts/installCppUTestDependency.sh
+
+# Build your code e.g. by calling make
+script:
+  - cd $TRAVIS_BUILD_DIR/bin/posix
+  - cmake -DOpENer_PLATFORM:STRING="POSIX" -DCMAKE_BUILD_TYPE:STRING="" -DOpENer_64_BIT_DATA_TYPES_ENABLED:BOOL=ON -DOpENer_TESTS:BOOL=ON -DCPPUTEST_HOME:PATH=$TRAVIS_BUILD_DIR/source/dependencies/cpputest -DCPPUTEST_LIBRARY:FILEPATH=$TRAVIS_BUILD_DIR/source/dependencies/cpputest/src/CppUTest/libCppUTest.a -DCPPUTESTEXT_LIBRARY:FILEPATH=$TRAVIS_BUILD_DIR/source/dependencies/cpputest/src/CppUTestExt/libCppUTestExt.a ../../source
+  - make
+  - make test
+
+# Generate and deploy documentation
+after_success:
+  - cd $TRAVIS_BUILD_DIR/source
+  - chmod +x $TRAVIS_BUILD_DIR/travis_scripts/generateDocumentationAndDeploy.sh
+  - $TRAVIS_BUILD_DIR/travis_scripts/generateDocumentationAndDeploy.sh

+ 1 - 1
source/CMakeLists.txt

@@ -1,7 +1,7 @@
 #######################################
 # Required CMake version              #
 #######################################
-cmake_minimum_required( VERSION 2.8.9 )
+cmake_minimum_required( VERSION 2.8.7 )
 
 #######################################
 # Project name                        #

+ 1 - 1
source/opener.doxyfile

@@ -38,7 +38,7 @@ PROJECT_NAME           = "OpENer - Open Source EtherNet/IP(TM)  I/O Target Stack
 # could be handy for archiving the generated documentation or if some version
 # control system is used.
 
-PROJECT_NUMBER         = 1.1
+PROJECT_NUMBER         = 1.2
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer a

+ 1 - 1
source/src/ports/POSIX/CMakeLists.txt

@@ -18,4 +18,4 @@ add_library( ${PLATFORMLIBNAME} ${PLATFORM_SPEC_SRC})
 
 add_executable(OpENer main.c)
 
-target_link_libraries( OpENer CIP SAMPLE_APP ENET_ENCAP PLATFORM_GENERIC ${PLATFORMLIBNAME} ${PLATFORM_SPEC_LIBS} ${OpENer_ADD_CIP_OBJECTS})
+target_link_libraries( OpENer CIP SAMPLE_APP ENET_ENCAP PLATFORM_GENERIC ${PLATFORMLIBNAME} ${PLATFORM_SPEC_LIBS} ${OpENer_ADD_CIP_OBJECTS} rt)

+ 2 - 2
source/tests/CMakeLists.txt

@@ -11,7 +11,7 @@ add_test_includes()
 ###################################################
 # Copy custom test output file to binary location #
 ###################################################
-configure_file( CTestCustom.cmake ${PROJECT_BINARY_DIR}/CTestCustom.cmake )
+#configure_file( CTestCustom.cmake ${PROJECT_BINARY_DIR}/CTestCustom.cmake )
 
 add_subdirectory( utils )
 add_subdirectory( enet_encap )
@@ -27,4 +27,4 @@ target_link_libraries( OpENer_Tests EthernetEncapsulationTest ENET_ENCAP )
 ########################################
 # Adds test to CTest environment       #
 ########################################
-add_test(OpENer_Tests ${EXECUTABLE_OUTPUT_PATH}/OpENer_Tests)
+add_test(OpENer_Tests ${EXECUTABLE_OUTPUT_PATH}/OpENer_Tests -v -c)

+ 0 - 1
source/tests/CTestCustom.cmake

@@ -1 +0,0 @@
-set( CTEST_CUSTOM_POST_TEST ${CTEST_CUSTOM_POST_TEST} "cat Testing/Temporary/LastTest.log" )

+ 108 - 0
travis_scripts/generateDocumentationAndDeploy.sh

@@ -0,0 +1,108 @@
+#!/bin/sh
+################################################################################
+# Title         : generateDocumentationAndDeploy.sh
+# Date created  : 2016/12/09
+# Notes         :
+__AUTHOR__="Martin Melik-Merkumians"
+# Preconditions:
+# - Packages doxygen doxygen-doc doxygen-latex doxygen-gui graphviz
+#   must be installed.
+# - Doxygen configuration file must have the destination directory empty and
+#   source code directory with a $(TRAVIS_BUILD_DIR) prefix.
+# - An gh-pages branch should already exist. See below for mor info on hoe to
+#   create a gh-pages branch.
+#
+# Required global variables:
+# - TRAVIS_BUILD_NUMBER : The number of the current build.
+# - TRAVIS_COMMIT       : The commit that the current build is testing.
+# - DOXYFILE            : The Doxygen configuration file.
+# - GH_REPO_NAME        : The name of the repository.
+# - GH_REPO_REF         : The GitHub reference to the repository.
+# - GH_REPO_TOKEN       : Secure token to the github repository.
+#
+# For information on how to encrypt variables for Travis CI please go to
+# https://docs.travis-ci.com/user/environment-variables/#Encrypted-Variables
+# or https://gist.github.com/vidavidorra/7ed6166a46c537d3cbd2
+# For information on how to create a clean gh-pages branch from the master
+# branch, please go to https://gist.github.com/vidavidorra/846a2fc7dd51f4fe56a0
+#
+# This script will generate Doxygen documentation and push the documentation to
+# the gh-pages branch of a repository specified by GH_REPO_REF.
+# Before this script is used there should already be a gh-pages branch in the
+# repository.
+# 
+################################################################################
+
+################################################################################
+##### Setup this script and get the current gh-pages branch.               #####
+echo 'Setting up the script...'
+# Exit with nonzero exit code if anything fails
+set -e
+
+# Create a clean working directory for this script.
+mkdir code_docs
+cd code_docs
+
+# Get the current gh-pages branch
+git clone -b gh-pages https://git@$GH_REPO_REF
+
+cd $GH_REPO_NAME
+##### Configure git.
+# Set the push default to simple i.e. push only the current branch.
+git config --global push.default simple
+# Pretend to be an user called Travis CI.
+git config user.name "Travis CI"
+git config user.email "travis@eipstackgroup.org"
+
+# Remove everything currently in the gh-pages branch.
+# GitHub is smart enough to know which files have changed and which files have
+# stayed the same and will only update the changed files. So the gh-pages branch
+# can be safely cleaned, and it is sure that everything pushed later is the new
+# documentation.
+rm -rf *
+
+# Need to create a .nojekyll file to allow filenames starting with an underscore
+# to be seen on the gh-pages site. Therefore creating an empty .nojekyll file.
+# Presumably this is only needed when the SHORT_NAMES option in Doxygen is set
+# to NO, which it is by default. So creating the file just in case.
+echo "" > .nojekyll
+
+cd ../..
+
+################################################################################
+##### Generate the Doxygen code documentation and log the output.          #####
+echo 'Generating Doxygen code documentation...'
+# Redirect both stderr and stdout to the log file AND the console.
+doxygen $DOXYFILE 2>&1 | tee doxygen.log
+
+cp -r doc/api_doc/html/* code_docs/$GH_REPO_NAME
+cd code_docs/$GH_REPO_NAME
+
+################################################################################
+##### Upload the documentation to the gh-pages branch of the repository.   #####
+# Only upload if Doxygen successfully created the documentation.
+# Check this by verifying that the html directory and the file html/index.html
+# both exist. This is a good indication that Doxygen did it's work.
+if [ -f "index.html" ]; then
+
+    echo 'Uploading documentation to the gh-pages branch...'
+    # Add everything in this directory (the Doxygen code documentation) to the
+    # gh-pages branch.
+    # GitHub is smart enough to know which files have changed and which files have
+    # stayed the same and will only update the changed files.
+    git add --all .
+
+    # Commit the added files with a title and description containing the Travis CI
+    # build number and the GitHub commit reference that issued this build.
+    git commit -m "Deploy code docs to GitHub Pages Travis build: ${TRAVIS_BUILD_NUMBER}" -m "Commit: ${TRAVIS_COMMIT}"
+
+    # Force push to the remote gh-pages branch.
+    # The ouput is redirected to /dev/null to hide any sensitive credential data
+    # that might otherwise be exposed.
+    git push --force "https://${GH_REPO_TOKEN}@${GH_REPO_REF}" HEAD:gh-pages > /dev/null 2>&1
+else
+    echo '' >&2
+    echo 'Warning: No documentation (html) files have been found!' >&2
+    echo 'Warning: Not going to push the documentation to GitHub!' >&2
+    exit 1
+fi

+ 16 - 0
travis_scripts/installCppUTestDependency.sh

@@ -0,0 +1,16 @@
+#!/bin/sh
+
+echo 'Setting up the CppUTest script...'
+# Exit with nonzero exit code if anything fails
+set -e
+
+mkdir dependencies
+cd dependencies
+
+git clone https://github.com/cpputest/cpputest.git
+
+cd cpputest
+git checkout v3.8
+cmake CMakeLists.txt
+make
+cd ../..