Showing posts with label Source Control. Show all posts
Showing posts with label Source Control. Show all posts
on Friday, 4 May 2012
Just yesterday I was offered a new job with a relative large insurance firm in the UK. My role will be to bring the build management team up to scratch and implement a framework from the ground up. This got me thinking... what are the tools and good practices I cant live without?


Build & Release Website

Every software development outfit should have one of these! Some of the information you would store is:

  • Functional Release Notes
  • Technical Release Notes
  • Continuous Integration Results (Link to tools)
  • Project Documentation (Javadocs or LXR)
  • Runtime Logs
  • Deployed Applications (A list of environments and their current deployments)
  • Application Metrics
  • Third Party Documentation (Tools, Libraries)
  • Misc Documents

This should be maintained by the Build & Release team and should be automated. Our systems are configured to deploy the documentation once its been created.

Build & Release Calendar

Another tool no serious software company should be without. The projects that you support should be able to see your workload and manage requests accordingly. Also, if you need to justify where you're spending your time this acts as a great record for the finance department or Project Managers. There are free calendars available and tools like Jenkins also provide work well with Google Calendar.

Build Framework

No sh!t, really?! It doesn't matter what tools you use, but you should be able to build, package, run unit tests and deploy at very least. The aim here is to produce a framework that can be used with very little configuration and flexible enough to use with new projects. Some of the "powers-to-be" at my office have been trying to get us to switch to Maven for a while now. The argument that we're forced to use a single framework is a fair one, but my counter argument is that our Ant framework is so well made that we wouldn't be achieving anything by switching. Ant is a highly configurable tool but takes a lot to get up and running, however Maven is not so flexible but is much easier to use "out of the box".

Continuous Integration

CI is often considered something only used by large scale projects. This doesn't have to be the case. Even if you're a small operation with only a handful of developers it makes sense to offload the task of compiling your source and running a few simple tests. To put this into context, if you have 5 developers, a build takes 1 hour and each developer builds at least once a day, thats 25 hours wasted on builds a week. At a very generous rate of £15 per hour thats £375 a week and £1500 a month wasted in consumed resources for builds. Thats the build server bought and paid for!!

on Monday, 23 April 2012
Something simple, but very effective!

I want you to do something for me; at the top of the browser you’re reading this on there should be a help button (unless you’re on a mobile device). Click it, then click the about option. You should be presented with something similar to this:



If the application you or your company is developing doesn’t have this feature then you need to give yourself a slap on the wrist and ask yourself, WHY? As a release engineer we’re often expected to know exactly what’s in every environment at all times. If you’re a small organisation with only a few projects and deliveries then this is sometimes possible, but even then what happens if you go on holiday and someone else covers for you??

If you’re using Ant I would advise writing a small task that will pull a few basic parameters from your build machine. Some useful properties to gather are the following:

Username
Build Machine

Date
Time
Build Number

Here’s the Ant target I use. It includes some ClearCase stuff (the source tool we use) but I thought I would leave it in for information.


 <target name="buildinfo" description="Record build metadata">
  
 <echo message="${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="buildby=${env.USERNAME}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="host=${env.COMPUTERNAME}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="builddate=${build.time}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="buildview=${cc.view}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="buildstream=${cc.stream}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="buildproject=${cc.project}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="foundationbaseline=${cc.found-baselines}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="recommendedbaseline=${cc.rec-baseline}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="Projrecommendedbaseline=${cc.rec-bline-stream}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="currentbaselines=${cc.current-baselines}${line.separator}" file="${build.props.file}" append="true"/>
  
 </target>
  


Write some code to get this to display in your app then its job done!

on Thursday, 24 June 2010
Today I'm going to discuss how to create a project, organise it in a clever way using a smart directory structure and maintain it using source control. I was inspired to write this by a book called Game Coding Complete by Mike McShaffry et al.

To begin, I am assuming that you will be using Visual Studio, however the directory structure and source control can be adopted by anyone.

Directory Structure


When creating a project, especially in Visual Studio, it can become very difficult to stay organised as more and more code is created/added. To overcome this common problem Mike proposes a file structure that is both diverse and expandable.

Here it is in its basic form:

Project Name
+ Docs
+ Media
+ Source
+ Obj
+ Bin
+ Test

Most of these are self explanatory but here's a simple overview:

Docs- This would typically include anything you would produce in an "Office" package, I would also advise storing all your UML here too.

Source- This can be expanded to include many child folders. Where I work this is usually split to replicate the different teams that will be working on the project, so you may find a DB, UI, Business and Common sub folder. For Games you would likely have AI, Graphics or 3rd_Party.

*Note - as a rule try to stick to the Linux convention of putting a _ instead of white space when naming files e.g. 3rd_Party instead of 3rd Party. I cant count how many times I have been caught out by errors relating to this at work.

Obj- anyone familiar with Visual Studio will be aware of the temp files created when building your project. One way of keeping your solutions folder organised would be to dump the temp files here... I will provide the VS configuration to do this later in the blog.

Bin- When you build a program you will be presented with a package (often a .exe). This is where you should have your compiler store that package. In this folder you would also have a Debug and Release sub folder where you can store your package depending on the configuration used for the build.

Here's a more advanced file structure (based on a typical game)

Project Name
+ Docs
+ Media
++ 3D_assets
+ Source
++ AI
++ Graphics
++ Maths/Physics
++ 3rd_Party
+ Obj
+ Bin
++ Debug
++ Release
+ Test

Visual Studio Configuration


For this it's probably easier to show you with a few snapshots. From within you project Right click the solution, select properties and configure the project as shown below.

General

Debugging

cppHeader

cppOutput

LinkerDebug

When you now build a project you should find that Visual studio now places the temp files in your obj folder and your release in bin. It's up to you to organise your source code but this is easy enough to do in Visual Studio.

Source Control using Google Code(GC) and TortoiseSVN


I'm not going to discuss these here as there's plenty of information on-line about them. All you need to know is GC will act as your repository (a storage place for code) and TortoiseSVN is a GUI (Graphical User Interface) that enables you to use Subversion (a type of source control).

To begin with you will want to create a project on GC - you can call this anything you like just make sure you can identify which project it relates to. One thing to note is its not always possible to name the project what you want (normally as its saved on your PC) as a project with the same name may already exists.

Now that you have created project and given it an elegant directory structure its time to upload it to GC. To do this you will require your Google username and password but note the password is not the same as your Google account password.

To get the username simply log into GC and select the "Profile" menu - this will give you your user id and select "Settings" to obtain your password.

Finally, in windows explorer, right click your project directory to get the Tortoise context menu and choose "Import...". Tortoise will now prompt you for the repository url. Enter:

https://[project name].googlecode.com/svn/trunk

Enter your user id and password obtained earlier and watch your files and directories get uploaded to the GC repository. From now on you can use the
Tortoise repo-browser and other tools to access it via the url above.