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

Initial continuous integration with Travis CI #77

Merged
merged 2 commits into from Jan 2, 2018

Conversation

metachris
Copy link
Contributor

@metachris metachris commented Dec 27, 2017

Proposal of an initial continuous integration setup using Travis CI (see also #72).

If merged and enabled at Travis CI, code pushes to GitHub will automatically build the code and run a number of tests to verify the neo-cli functionality.

  • The steps executed by Travis CI are defined in .travis.yml
  • The proposed setup uses a Docker image based on the microsoft/dotnet:2.0-sdk base image to build the code
  • Currently 2 test stages are implemented:
    • neo-cli tests using expect: these tests interacts with neo-cli like any normal user, send commands and wait for correct output. This could catch errors like Create address returns "error", does not create new address (v.2.5.2) #70. Note: if output of neo-cli commands that are tested with expect change, the test-neo-cli.expect script will also need to be updated accordingly.
    • JSON-RPC tests: neo-cli is started in the background with dotnet neo-cli.dll --rpc, and the JSON-RPC api is tested with curl commands. Currently one json-rpc test is implemented: querying totalSupply of the RPX token. This can catch errors such as Error 400 Access Denied on neo-cli 2.5.2 #71.

Example output of Travis CI: https://travis-ci.org/metachris/neo-cli/builds/322348356

This PR is an initial CI setup which can easily be extended with more tests in the future.

Looking forward to hearing your thoughts, and whether you are interested in all of those tests or just a part of it, or something completely different. I'd also like to know how you want to name the directory which contains the continuous integration scripts (in this proposal it's simply /ci).

expect /opt/ci/test-neo-cli.expect

# Start neo-cli in background for additional JSON-RPC tests
screen -dmS node1 bash -c "dotnet neo-cli.dll --rpc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make sure this screen is closed after tests have run

Copy link
Contributor Author

@metachris metachris Dec 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Docker container is killed after the tests, so it wouldn't matter. Edit: For reusability and flexibility it could still be good to kill it though.

Edit2: I'll think about this a bit more. This would make things more complex because the grep commands for the JSON-API response will exit the script with an error exit code at that point. So we would need to wrap the JSON-RPC tests in another script, check the exit codes, kill the screen session, and then exit with the exit code of the JSON-RPC tests. Not sure about the benefit and if this is worth the added complexity.

ci/README.md Outdated
@@ -0,0 +1,14 @@
This are files for the continuous integration with Travis CI.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'This' should be 'These'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@AshRolls
Copy link
Member

I like these changes, they will add more robustness to this repo. Given the amount of functionality exposed through neo-cli for the main neo repo, we should try and restrict the testing to general neo-cli rather than trying to stretch tests to cover all neo functionality.

/ci is fine for folder name

@erikzhang
Copy link
Member

I have set it up. So how do I test it?

@metachris
Copy link
Contributor Author

metachris commented Jan 2, 2018

To run it locally, you'll need to have Docker CE installed. Then just run ./ci/build-and-test.sh. Edit: This works on Linux and OSX, but on Windows you'll probably need a bash-compatible shell like the Git shell to execute the bash script. The bash script is just a wrapper for these commands, which you should also be able to execute in PowerShell:

docker build -f ci/Dockerfile -t neo-cli-ci .
docker run neo-cli-ci /opt/ci/run-tests-in-docker.sh

If you want to set it up with this GitHub repository, enable this repository at Travis CI (see this guide), and merge this PR. On all code pushes (including the merge commit), the build at Travis is triggered. This is how an example output at Travis looks like.

@erikzhang
Copy link
Member

So, anyone has tested it locally?

@metachris
Copy link
Contributor Author

metachris commented Jan 2, 2018

I have, and it works for me (OSX). Also works when executed by Travis-CI (see here) which uses Ubuntu Linux to run the builds. Not sure if @AshRolls has been running it too.

@erikzhang erikzhang merged commit fd95aa9 into neo-project:master Jan 2, 2018
@metachris
Copy link
Contributor Author

Works! You can see the output of the builds here: https://travis-ci.org/neo-project/neo-cli

If you want to add a travis-ci build status badge for the master branch like this: Build Status, you can use this code for the readme (markdown format):

[![Build Status](https://travis-ci.org/neo-project/neo-cli.svg?branch=master)](https://travis-ci.org/neo-project/neo-cli)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants