Reporting Pester Code Coverage Metrics to TeamCity

As previously mentioned I’ve been doing a lot of work with PowerShell modules at work where I have recently gotten all the parts for a full continuous delivery pipeline working for those modules. A big section of that pipeline runs through TeamCity and while the existing ability to have Pester test results show up in the build results is really great, code coverage is slightly less obvious but in the end fairly simple.

The trick is to use the -PassThru parameter with Invoke-Pester and then use TeamCity’s build reporting interaction to get the values into the system. The end result will look a lot like this:

$testResults = Invoke-Pester -OutputFile Test.xml -OutputFormat NUnitXml -CodeCoverage (Get-ChildItem -Path $PSScriptRoot\*.ps1 -Exclude *.Tests.* ).FullName -PassThru
Write-Output "##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='$($testResults.CodeCoverage.NumberOfCommandsAnalyzed)']"
Write-Output "##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='$($testResults.CodeCoverage.NumberOfCommandsExecuted)']"
Pester code coverage right in your TeamCity build results!

Pester code coverage right in your TeamCity build results!

Simple test coverage check for script modules

I’ve been spending a lot of time at work writing PowerShell modules and as part of that effort we’ve been trying to make sure we’re doing at least some unit testing on those module functions (Using Pester of course!). Unfortunately we’ve had a few instances where a new function gets added to a module without any unit tests being added. We’ve structured our modules so that every function has it’s own source file and accompanying tests file and all of them are located in a \Functions\ folder in the project. Ideally the CodeCoverage parameter for Invoke-Pester would catch this sort of problem but it only runs tests for files with a certain file name structure and so if it runs across Some-Function.ps1 without an accompanying Some-Function.Tests.ps1 it doesn’t care. Today I finally got a little tired of finding broken functions and decided to do something about it, the result is Coverage.Tests.ps1:

Describe "Coverage" {
    Context "All functions should have tests" {
        $functions = Get-ChildItem -Path $PSScriptRoot\*.ps1 -Exclude *.Tests.ps1
        foreach ( $function in $functions ) {
            $name = $function.name.Split(".")[0]
            It "$name should have a testing script" {
                Test-Path "$PSScriptRoot\$name.Tests.ps1" | Should Be $true
            }
        }
    }
}

I’ve got to think that it shouldn’t be hard to add a similar test for my other pet peeve: Missing help comment blocks!

My Year in Soda: 2014

I’ve been trying to remember to post my impressions of sodas that I try to Twitter through the year and figured I’d put together a Year In Review to collect all of the notes for posterity.

This year’s high points: Phancy Sparkling Limeade and Empire Spruce Beer.

Virtual Micropolis: Progress and Upcoming Display!

I mentioned back in March that I had started working on a wiki to provide further information about our Micropolis modules and I am fairly proud to say that we’re definitely making progress on filling the site with content. It’s not complete yet, by any stretch of the imagination, but it’s got a good base of content and the visual style is starting to come together as well.

If you haven’t had a chance to look at it, or you haven’t looked since last March, now is a great time to go take a peek at http://www.virtualmicropolis.com and you can get updates by subscribing to any of the RSS feeds on the site or by following the Mayor’s twitter feed @vmicropolis!

We have also been invited back to the Saint Anthony Park Library to display our layout as part of their post-renovation grand re-opening party! If you missed the display in March this is a great time to come out and have a look at our layout with some additional modules by Thomas Anderson. Plus Peter Hoh is returning with his educational models, the travelling DK Books display for their Star Wars LEGO books we be on hand, at least one stormtrooper from the local 501st, and refreshments provided by the little grocery store up the street! Mark your calendars for Wednesday August 14, 2013 from 6-8pm and be sure to tell anyone else who likes LEGO.

LibraryShowFlyer_August Saint Anthony Park Library Show - August 2013

 

(PDF Version of August Library Show Flyer)

How To Hard Boil Eggs

  1. Put eggs in pot
  2. Cover eggs with cold water
  3. Cover pot with lid
  4. Place pot on stove and set heat to high
  5. Set timer for 20 minutes
  6. When water boils remove lid and remove pot from burner
  7. Let eggs cool slightly, then chill in refrigerator

You wouldn’t think that I would need to write that down in a place that, in theory, I will never forget it but every year around this time I ask Jennifer or Sigrid something along the lines of, “How do you boil eggs again?”. Clearly even though I have been coloring eggs with the kids for the past five or six years, hard boiling eggs once a year is not enough for it to be retained in my long term memory. So this time I am writing it down so that next year I don’t have to ask them for it yet again. I hope that I’m not betraying part of the tradition by doing so…

The observant among you may be thinking something along the lines of, “I didn’t think he was a Christrian…” and in fact I am not. At least I have not been for approximately the past nearly twenty years. My faith in that particular range of beliefs was already starting to fall apart during high school despite my family and community’s sincere and steadfast efforts to the contrary and getting out into the world on my own took care of the rest of it pretty quickly. As with many people who were newly “Not a Christian” I did go through a phase of pretty explicitly and strongly rejecting anything and everything associated with it and I still feel that way vaguely about things like Christmas (though for quite awhile really due more to the orgiastic consumer culture aspects of it than anything else) but a year or two after Jennifer and I got together I suggested that I might like to color eggs with the kids once they were old enough to have just enough attention span and manual dexterity to make it not also involve repainting the dining room.

Every year since then I have looked forward to coloring eggs some spring-ish Saturday afternoon before a holiday that I otherwise don’t really participate in.

Partly I enjoy spending the time with the kids. Partly I just enjoy the challenge and entertainment of coloring my own eggs (I get to do half to one-third of the dozen). In large part though I do it because I have fond memories of spring-ish Saturday afternoons in my childhood with the rest of the family around the house for once before one of the busiest days, for my family at least, of the year. My dad had planted his Good Friday potatoes and was taking most of the day off in a set of weeks that he otherwise had none. My mom was worrying over getting the house cleaned and everyone’s clothes ready and the food cooked and keeping us kids from maiming each other and keeping whatever other plates spinning that I, as an adult about the same age as she was at the time, only now begin to comprehend.

But really the rush and press of spring and summer is nearly upon us and it’s nice to just sit and color some eggs.

No tag for this post.

Introducing Virtual Micropolis

Virtual Micrpolis Logo

After a few years of owning the domain name, I am finally getting off my proverbial butt and doing something with VirtualMicropolis.com. My original idea had been, as is somewhat usual for me, a bit grandiose. I was going to get the spec moved over there and make it a community for everyone who built Micropolis to come and post their stuff. Because there aren’t any other places on the Internet to build a community (like Flickr, MOCPages, Facebook, Google+, ad infinitum…), or something.

Anyway, the point really came home last weekend in Des Moines where we were displaying our little corner of Micropolis again and we also had the TwinLUG QR Code out on the table next to it. As usual we got several people who tried to use it, and mostly it worked (The lighting was a bit weird), but the overwhelming response to being sent to the TwinLUG site was one of disappointment. What people really wanted to see was lots of pictures and maybe some more stuff about what they were looking at right then. Obviously it was finally time to do something about it.

To get this really rolling though I was going to need to scale things back to just a place where we could put up information and pictures about just the modules that Jennifer and I own. Almost all of them are ones that we designed with the exceptions of some that I bought off a TwinLUG member before he moved out of the country a few years ago (Hi Gary!). Thanks to the wonderful photography skills of Alyska Bailey-Peterson we had a base of some excellent photos to go along with the drek that I manage to shoot so that we could at least get the site off the ground before having to figure out where we were going to get more good pictures.

For this project I think we really needed a Wiki. A blog or other groupware CMS system was just going to have too much overhead and complexity for the basic requirements of setting up easily linkable pages that could be simply protected from spam or other ne’er-do-wells with some file management capabilities. I finally settled on DokuWiki and I’m pretty happy with the results so far. My one small issue is that for some reason there are no simple methods of setting text alignment, but everything else is great so I’m ignoring that as much as possible. If you’re looking for a good Wiki platform you should definitely add them to your list of candidates.

As of right now I’ve got pages up for eight modules and material for a couple more before we start to run out of images, but I think it’s a decent start and hopefully we’ll be able to keep some momentum on the project for awhile.

While right now the site is all about our collection and the layouts that we have been part of but I think we would be glad to broaden the content in the not too distant future. I do have things locked down so that even if you register for an account you can not make any edits until I tweak the account so please contact me if that is your intent.

Good Display at the Library

Decent Sized Layout

As I mentioned a couple of weeks ago, Jennifer and I put together a little display of our Micropolis modules at the library yesterday. I took the photo above just before we started to take it apart and get it home. I have no idea who the kid is, but I think the image turned out pretty well even if a solitary figure like that doesn’t given any good idea of how busy it got.

Going in yesterday afternoon we really didn’t know how many people were going to show up. We had put it together on pretty short notice so it hadn’t gotten into the Library’s regular promotional material and we had only sent it around to the neighborhood mailing list and a few groups and friends. So we were very slightly worried that very few people were going to show. Well, there were no worries about that.

We don’t really have any good way of estimating how many people came through, though the consensus appears to be that we can safely figure there were at least a hundred people who came through. From there, depending on who you ask, it was maybe as high as three hundred. The first hour was the most busy and for awhile the crowd around Micropolis was 2-3 deep.

Peter’s display got a lot of attention too and I’d be surprised if he wasn’t really hoarse given how much chatting he did with people while demonstrating his stuff. I was pretty sure he’d be a good fit when we invited him to show with us and I’m glad I was right. He really has a great way of interacting with everyone. When I asked him how well he thought it went during the display, he answered by showing me that he had handed out a third of the brochures for the Science Museum of Minnesota’s summer education series. Granted, this neighborhood is a pretty good crowd for that sort of thing and you can never tell how many of those made it home AND didn’t go immediately into the recycling bin, but it’s at least a nice anecdotal metric.

I should also publicly and sincerely thank my sister and brother-in-law who came in and monitored our free play areas for us while we were busy interacting with everyone around the main display. The library had said that having bins of parts out for general play would be absolutely fine but that they had to be closely monitored for liability reasons. Becca and Raulie arrived in plenty of time and took care of things for the full two hours. Having those areas available so that when the kids got done NOT being able to touch the city they could go and put together their own stuff worked out beautifully, and we couldn’t have done it without them.

As for the Micropolis display itself it ended up being a perfect rectangle at 5.5 by 10.5 blocks. Considering that it only included modules that the two of us own I am really proud of the size of that display. We did leave out two lesser quarter block modules and some waterfront but it wasn’t a tough choice to do so. It was also extremely gratifying to finally see a properly complete Bluff portion of the display. Up until this point my gorge module has always had to be tucked away into a corner because we didn’t have enough other bluff modules to cover two of the sides but the spurt of building in the last couple of weeks meant that finally we had a nice hill. Three of those modules are non-compliant with the spec, but in a case like this it’s easy to make that kind of exception. In a larger display with more contributors I think it still might work but we’ll have to see.

As usual one of the most common questions we got was, “How many LEGO bricks/parts are in this?” and I had taken the time to figure out an answer before we got there: About 100,000. I think we’re probably easily within 10-15% of that, but at some point I’m going to have to figure out a more accurate number. I arrived at that estimate by estimating an average of 500 parts per quarter block. If we expand that out to 5.5 x 10.5 blocks or 11 x 21 quarter blocks, which is 231 quarter blocks times 500 to get 115,500. I do think it’s possible that the average per quarter block is a bit high but I don’t see it being any lower then 400 and that still puts us in spitting distance of 100,000 so I’m just going to go with that for now.

I find it consistently interesting seeing what other people appreciate in a bigger layout like this. Living with the collection and getting the family’s opinion tends to split two, and occasionally three, ways depending on where Jennifer and I are at on particular questions. Run about a hundred people through the room though and the diversity of opinion explodes. People point out modules that maybe one of us thinks isn’t the best work, but something about it speaks to that individual. It’s a great thing to watch happen.

In any case, I think we can call the display an unqualified success. We’re vaguely discussing the possibility of doing it again next year. In many ways though, it was a good dress rehearsal for two weeks from now in Des Moines, IA.

No tag for this post.

Little LEGO Show – March 2, 2013

LEGO Show March 2, 2013 at St Anthony Park Library

LEGO Show March 2, 2013 at St Anthony Park Library

My partner Jennifer and I are doing a little display at the local library with our friend Peter. Anyone who has been over to our house will have seen the shelves filling our living room with various parts of Micropolis. I attempted my very first module back in August of 2008 and Jennifer built her first module only a month or two later. Since then we’ve both built quite a few different contributions, but Jennifer more then most. Of the more then 40 square feet of Micropolis that we have together she has been personally responsible for probably 2/3rds of it.

One of the great features of the Micropolis standard, and part of reason for the standard, is that unlike a similarly sized model train layout each module can be moved around independently of the others for the most part and allow for a very large number of different configurations. But at a certain point it is just not easily possible to put the whole city together in one contiguous display. I’m pretty sure we passed that point over 20sq feet ago.

So this show is mostly about being able to put our Micropolis on a big set of tables and be able to see it all in one place for the first time in a long while. However, when we got to see the room on Wednesday it was pretty plan to us that despite it being a fairly decent sized display by itself, it would be somewhat dwarfed by the room we’re going to be in next Saturday. So we asked Peter if he wanted to come by with his stuff too.

Peter doesn’t build Micropolis, but instead does something completely different and very cool with LEGO: He teaches science and engineering with it. He’s been running classes locally for several years, including at Leonardo’s Basement and the Science Museum of Minnesota. He’s not there in any official capacity with either of those organizations but his passion for the subject matter and the fun variety of models that he uses will be a great fit for the library and the people in the homeschool community that Jennifer interacts with.

So it’ll be a little show for only 2 hours. Not a whole lot to see, but hopefully people will like what’s available. Maybe if it goes well we’ll see about doing something a bit bigger again some day.


View Larger Map

Small update: The flyer up top is available in PDF format too..

No tag for this post.

When did I become _that_ guy?

The other evening @SigridEllis was talking with me about the problems she’s been having with her phone. I am the household tech support and as such it’s important for me to listen in this sorts of circumstances and try and help out as much as I can, or am asked to, and try to minimize the condescension or patronizing tone that people so often associate with those who provide tech support (deservedly or not depending on the circumstances). Unfortunately this time I was having a horrible time paying attention, though I think I got a pretty good idea of what was happening, because I could not stop thinking, “You know, I’ve never had that kind of trouble with my Windows Phone…”.

I did manage to not say it until much later in the conversation when I was able to preface it with a statement about how unhelpful the comment was likely to be and also that it wasn’t actually apropos of the problem at hand but I couldn’t help but realize that at some point I have become that guy. Not even 10 years ago they all used to be Macintosh and Linux fans who seemed to only have single responses to any mention of any Microsoft product along the same lines as that horrible thought I had so much trouble getting past. The situation with my beloved Windows Phone really is about the same as far as marketshare and application availability as either of those platforms during the waning heyday of the desktop PC. All the cool new games come out for iOS or Android. Every one you know has one of those devices, except for those others that you have actively searched for and connected with to share your happiness with your chosen platform. As much as I am irritated at the aspects of humanity that seem to show such an affinity for tribalism it’s always been clear that I’m no exception. I’m just not quite so comfortable with it being so obvious.

Yes, I have invested quite heavily in the Microsoft ecosystem. At this point all of the devices that I use are part of that world and they work really well for me. But please! If you catch me saying something like, “You know I’ve been able to do that on my Windows Phone for years…”, just slap me. I’m pretty sure I’ll deserve it.

No tag for this post.

Some help might be useful

I was out taking a walk through the neighborhood this morning and came up with an idea that, unusually for me, isn’t a crazy idea and most likely won’t lead to my financial ruin so I figured it was worthwhile to follow-up on it.

The city of Saint Paul has an official beautification project to put sidewalk poetry on newly built or replaced sidewalks throughout the city. The northern section of the St Anthony neighborhood, where I live, is no exception to the placement of these poems and it makes for a nice treat to see one while out and about. It occurred to me that it would be nice to have a handy map of such items, and of course the city does have such a map but it is separate from the maps that other cities and organizations maintain of similar art features and doesn’t include something like the Humpty Dumpty sculpture which is private yard art just a few blocks away from my house.

It seemed to me that coming up with a database of such features that user’s (or creators) could submit to easily with associated applications to be able to find local public art would not be much of a project to get off the ground or possibly even to maintain, and that it’s probably something that I should just see about doing.

The problem, as is so common with projects like this, is that all of the obvious domains that I could come up with for the project are already taken or are prohibitively expensive to purchase. So the help I need is to come up with a domain name to use that is available. Ideas?

(I’ll post other thoughts about my plans for the features for the site and apps later, though I would be interested to hear what other people think about the concept and how they might use it.)