AppVeyor – Continues Integration for .NET/JavaScript – configuration

AppVeyor – Continues Integration for .NET/JavaScript – configuration

AppVeyor
Source

Some time ago I have been looking for some Continuous Integration engine for my Open Source project hosted on GitHub. I found a list of popular services https://github.com/ligurio/Continuous-Integration-services/blob/master/continuous-integration-services-list.md. My general requirement was support to JavaScript and .NET projects. Moreover it should be possible to run tests within this engine. I want to ensure the quality of my projects and I want to be able to detect failing test as quickly as possible after each commit. Also it would be nice to have a method to run deployment directly from this service.

After analysis of few different services I have chosen AppVeyor, because it meets all my expectations. This is a simple on-line service which is free for public projects hosted on GitHub, Bitbucket or VisualStudio Online.

Configuration for different project types

.NET

For .NET application the most important feature is just to build whole solution and run tests for specifics projects. That’s what we want to configure.

I will explain the configuration on example public GitHub project.

At first, we should add a project to our account.

Add project in AppVeyor

Then we can test, if build for this project succeed. Probably not, because we didn’t configure NuGet for our project. Generally NuGet should be configured to don’t store all packages on repository. Then it can be automatically downloaded by this package manager. That’s why we should tell AppVeyor to download this package before building the project. We should only add a special script to execute before build in Build tab in Configuration options.

nuget restore

Configure NuGet in AppVeyor .NET project

For test configuration it is enough to trust “Automatic discovery” option. It works well for NUnit tests and according to list https://www.appveyor.com/docs/running-tests it supports most of the popular test libraries.

Finally we can rerun build for our project to see that commit becomes green and all tests passes.

Green build and tests

JavaScript

Configuration for JavaScript project is a bit more difficult than for .NET. Because this CI server is based on Visual Studio, it is easier to configure it outside of web page. We should create a file named appveyor.yml in the main directory of our project. This is another method for configure the build process. You can find more information about this file in https://www.appveyor.com/docs/build-configuration.

In our case we want to run npm install phase and also run test from package.json configuration file. Of course, you can have different configuration of npm tasks, but the only one thing that you need to do is to modify this definition file to match your npm/gulp task names.

# Install scripts. (runs after repo cloning)
install:
  # Get the latest stable version of Node.js
  - ps: Install-Product node
  # install modules
  - npm install

# Post-install test scripts.
test_script:
  # Output useful info for debugging.
  - node --version
  - npm --version
  # run tests
  - npm test

# Don't actually build.
build: off

Before we run npm we have to be sure that we install it. It can be done with PowerShell command Install-Product node.

Notification

It is very useful to set up a notification system to inform you immediately about the build status. We can do this in project settings. We can configure it to send email or Slack message if the build fails.

AppVeyor Slack integration

Deployment

The last important part of Continues Integration process is deployment. We can configure AppVeyor, to give us a quick method to start project deployment. We can configure a deployment using WebDeploy, FTP server or even Azure Cloud.

Deployment to GitHub pages

I use a GitHub Pages mechanism as I described earlier http://www.diwebsity.com/2016/03/08/najtanszy-hosting-dla-projektow-webowych/ therefore I want to integrate it with AppVeyor. It is very easy, because the only one necessary part is to configure custom deployment script using:

gulp deploy

Deploy using GitHubPages

This is the basic type of CI environment and AppVeyor definitely match my requirements.