Tuesday, January 26, 2016

AppVeyor a free cloud CI - First experience

Background

Though open source doesn't mean free, most of the people working in open source area wants to get things free which ever is required for their projects. Github as free source control repositoty, Google hangout for meetings etc...AppVeyor is one of the tool which should be added to this list especially its .Net project. If we google we can get lot of information about AppVeyor. This post is going to be discussed about my experience with AppVeyor. I am really late into this open source world.

When we consider starting of any software project, there are many things other than writing code. Most of those things needs minimum research before starting. Else it will take more time to setup later. As seen earlier there should be some place to host the code. We cannot have keep the code in each and every developer's machine and pass it in zip files. Github now became one stop destination for hosting code free. So at least that piece doesn't require any more research. Another thing is Continuous Integration.

Continuous Integration

The need for CI

If we have experience more than 10 years, probably we might not have heard this word in college or during the initial years inside software industry. At that time we were considering a release as something special like Kumbamela which occurs in predefined intervals. Intervals were in years and in some places months. Nobody saw even in dream that they can give something bi-weekly to customer. But things changed with the adoption of a magic word called Agile. People started to give releases in 2 weeks to customers or at least forced to do so. That automatically bring the demand for continuous integration especially in automated ways.

In the earlier days when the release is approaching one person/team will be allocated for creating builds. All he needs to do is to compile the project and create MSI. Install it. Run basic tests and give to QA for detailed testing. Some teams opted for rotational policy for this build person / team. 

Software engineers are expected to solve others problems especially repeatable and involves human power. Who solves their problems? Of course themselves. In order to save a build person/team's pain the Continuous Integration is born.

What is continuous integration

As the name says integrate the works of developers continuously instead of waiting till the release date. Integration should mean getting the code changes of all developers, compiling the same and generating binaries/installers. Nice to have features are running unit tests, deploying to test machines and running integration tests. Advanced practitioners can even push to production if all the tests are passed. Everything is expected to be automatic. Better integration should start based on a souce code check-in.

This ensure that the defects are caught early instead of waiting till the release date.

CI Platforms

We saw that it needs to happen automatically on check-in. Where all these operations can run? They need dedicated one or more machines because developers cannot just sit idle during this time by running it in their machines.

In the initial days of CI people used separate systems for doing integration. Obviously when we automate integration we need software to do the process. Some people wrote their own programs to do all these operations and clever people created products out of it idea and made money. There were open source CI systems also emerged.

Even if buy or get OSS, it required a machine to run CI. Open source people at least who are working as individuals and small teams were struggling in this area. A machine is not free. Even if we keep old system for CI, we need to invest for internet, power etc...Enterprises also suffered a little as they need to maintain the CI machines.

Advances in the cloud technology solved this problem. Cloud allowed anybody to have a machine in cloud for short span of time. The SaaS model ie Software as a Service made the things more simple. They started giving CI as a Service. In other words, anybody can out soure the CI activities to cloud based systems without worrying about setting up a machine in cloud. All we had to do is to connect our source code with CI as a Service system. They have machines in cloud in which they download our source compile it, package it, run unit tests and even deploy it to production.

What is there for open source. There started some hosted CI providers who give free CI to open source projects along with their paid service. Wow...Anybody can do CI free in cloud. There are many major players. Lists can be found in many places in internet. One of those is AppVeyor.

AppVeyor experience

I started my research when I continuously saw a "Build Passing" flag in many open source projects in Github. Most of those lead me to travis-ci. When I started looking for a CI for my open source projects, I had no confusion to go to travis-ci. But when I read their .Net support, I got little confused. They have Linux servers only which points to mono. My first project which needs CI is not just an app. Its visual studio extension which directly depend on VS SDK. I started research again for CI which has native .Net support. The below links gave me confidence to try with AppVeyor.

Nuget restore

When I started AppVeyor, first stop was on nuget restoration. I know there is nuget restore command. But I was not sure where to enter the command. First google lead me to AppVeyor page where they explains how to deal with nuget packages

It didn't help me in first shot. It was telling that solution was not found

sln not finding

The exact error goes as below

MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
This folder contains no solution files, nor packages.config files.
Command exited with code 1

Nowhere it tells its due to nuget except 'nor packages.config'. Googled and immediately found the below link which explains if the solution is in inner folder in github src, we need to explicitly mention the .sln file path in nuget restore command as parameter.
http://help.appveyor.com/discussions/problems/1446-yml-file-isnt-finding-my-solution-file

VS Extension issue due to AWS

AppVeyor's console output for build is really awesome. It shows real time status about build. It showed below error message.

Setting up Visual Studio for debugging extensions. This one-time operation may take a minute or more.
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe /RootSuffix Exp /ResetSettings General.vssettings /Embedding /Command File.Exit
log4net : error XmlHierarchyConfigurator: Could not create Appender [RollingFileAppender] of type [log4net.Appender.RollingFileAppender]. Reported error follows. [C:\projects\joyful-visualstudio\src\VS2013\JoyfulTools\VSExtension\VSExtension.csproj]
System.IO.FileNotFoundException: Could not load file or assembly 'AWSToolkit.Util' or one of its dependencies. The system cannot find the file specified.
File name: 'AWSToolkit.Util'
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Util.TypeConverters.TypeConverter.ConvertFrom(Object source)
at log4net.Util.OptionConverter.ConvertStringTo(Type target, String txt)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ConvertStringTo(Type type, String value)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.SetParameter(XmlElement element, Object target)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.SetParameter(XmlElement element, Object target)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.SetParameter(XmlElement element, Object target)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)

I am not at all using AWSToolkit or log4net. This is the time the impression about AppVeyor went down. My initial google didn't give me proper answers so I created a support ticket in their forum

http://help.appveyor.com/discussions/problems/3348-vsix-project-build-fail-on-starting-integration-test

The response to the question came in amazing speed which I never experienced in any other support systems. He really knows the system well he clearly told the issue is related with an extension which is in the Visual Studio installed in their CI machines. Disabling that will solve the issue. He gave PowerShell command to disable the same.

I was not much clear on where to apply this script. This issues was already faced by others as well and they tried the same workaround. So I looked there and tried the normal command to disable the AWSToolkit.
http://help.appveyor.com/discussions/questions/1275-build-failed-log4net-error-xmlhierarchyconfigurator-could-not-create-appender-rollingfileappender

Yes it rocks. Now there is integration happening for each and every check in and I can get the artifact in their site.
https://ci.appveyor.com/project/joymon/joyful-visualstudio/build/1.0.0.27/artifacts

Note : I really don't have any relation with AppVeyor except using their free service. I cannot just stop me from writing about their free service and excellent support for free customers. May be in future they change their policy. But still then they are great.

No comments: