Skip to content

Commit

Permalink
Github Action & Telemetry (#363)
Browse files Browse the repository at this point in the history
* Introduce Github Action workflow to automate the builds of WSLab scripts
* Add support for Telemetry collection to Application Insights
* Deprecate Scripts.zip file in the repository in favor of Releases feature in Github

Co-authored-by: Jaromir Kaspar <[email protected]>
Former-commit-id: c373ca5
  • Loading branch information
machv and Jaromir Kaspar authored Jul 21, 2020
1 parent 9919e1f commit 42218e9
Show file tree
Hide file tree
Showing 12 changed files with 875 additions and 132 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Create release

defaults:
run:
shell: powershell

on:
push:
paths:
- 'Scripts/**'
branches: [ master ]

jobs:
new-version:
name: Bump version
runs-on: windows-2019
outputs:
previous_tag: ${{ steps.bump.outputs.previous_tag }}
new_tag: ${{ steps.bump.outputs.new_tag }}
steps:
- uses: actions/checkout@v2
- id: bump
name: Bump version
run: |
$today = Get-Date
$newVersion = @($today.ToString("yy"), $today.ToString("MM"), "1")
git fetch --tags
$hash = git rev-list --tags --topo-order --max-count=1
if($hash) {
$currentTag = git describe --tags $hash
$parts = $currentTag.Substring(1) -split '\.'
if($parts[1] -eq $today.ToString("MM") -and $parts[0] -eq $today.ToString("yy")) { $newVersion[2] = ([int]$parts[2] + 1).ToString("0") }
}
$newTag = "v" + ($newVersion -join ".")
git tag $newTag
"New version: $newTag"
echo "::set-output name=previous_tag::$currentTag"
echo "::set-output name=new_tag::$newTag"
- name: Push version tag
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tags: true

new-release:
name: Create release
runs-on: windows-2019
needs: new-version
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build scripts
shell: powershell
run: |
./build.ps1 -Version ${{ needs.new-version.outputs.new_tag }}
- name: Create changelog
id: changelog
shell: powershell
run: |
if("${{ needs.new-version.outputs.previous_tag }}" -ne "") {
$changelog = (& { git log ${{ needs.new-version.outputs.previous_tag }}..HEAD --pretty=format:'- %s (%h)' --abbrev-commit -- Scripts }) -join '%0D%0A'
"Changes for ${{ needs.new-version.outputs.previous_tag }} are:"
$changelog
} else {
$changelog = ""
}
echo "::set-output name=changelog::$changelog"
- name: Create Github Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.new-version.outputs.new_tag }} # ${{ github.ref }}
release_name: Release ${{ needs.new-version.outputs.new_tag }} # ${{ github.ref }}
body: |
Changes in this version:
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false

- name: Upload ZIP to Release
id: upload-scripts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Release.zip
asset_name: wslab_${{ needs.new-version.outputs.new_tag }}.zip
asset_content_type: application/zip
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/Output
Release.zip
6 changes: 6 additions & 0 deletions Docs/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: Hydration
href: wslab-hydration.md
- name: Deployment
href: wslab-deployment.md
- name: Telemetry
href: wslab-telemetry.md
121 changes: 121 additions & 0 deletions Docs/wslab-telemetry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# WSLab Telemetry

## Introduction

We started to collect telemetry to better understand impact of WSLab scripts as currently we cannot determine number of VMs deployed and where is WSLab being used. Data are hosted in Azure Application Insights and it is absolutely transparent what information is being collected, since all is visible in PowerShell Scripts.

Currently there is no public facing interface, however we plan to create PowerBI dashboards, where we will present Leader Boards and some nice statistics - such as how many VMs were deployed and we will be able to create statistics that will show in what countries is WSLab running and many more

## Verbosity level

Currently there are 3 different levels: **None**, **Basic** and **Full**. If nothing is configured in LabConfig, you will be asked to provide your preferred option.

### None

If you don't want to send anything, or if you are in offline environment.

### Basic

Sends information about deployed lab, that is vital for us to understand impact of WSLab scripts.

### Full

Provides enhanced information such as computer model, amount of RAM and number of cores. This information is not essential, however i will provide interesting insight.

## LabConfig examples

Basic telemetry level

```powershell
$LabConfig = @{
DomainAdminName = 'LabAdmin'
AdminPassword = 'LS1setup!'
Prefix = 'WSLab-'
DCEdition = '4'
Internet = $true
TelemetryLevel = 'Basic'
AdditionalNetworksConfig = @()
VMs = @()
}
```

Full telemetry including NickName that will be included in LeaderBoards once we will publish PowerBI statistics.

```powershell
$LabConfig = @{
DomainAdminName = 'LabAdmin'
AdminPassword = 'LS1setup!'
Prefix = 'WSLab-'
DCEdition = '4'
Internet = $true
TelemetryLevel = 'Full'
TelemetryNickname = 'Jaromirk'
AdditionalNetworksConfig = @()
VMs = @()
}
```

## Collected information

These properties are attached to every telemetry event that is sent to the Application Insights workspace.

| | Basic | Full |Description| Sample Value | Application Insights property |
|---------------------|:-----:|:----:|-----------| --- | ---- |
| Application Version | x | x | Version of WSLab Scripts | v20.07.1 | `ai.application.ver` |
| Telemetry Level | x | x | Which level of telemetry has been set | Full | `telemetry.level` |
| Product type | x | x | Workstation or Server| Workstation | `os.type` |
| Session ID | x | x | One-way hash (`SHA1`) of `MachineGUID`, `PSScriptRoot` and `ComputerName`. Purpose of this session ID is only to link execution of separate scripts within the same lab folder. | 482e33a99e6fb41e5f739d9294ac1b339c7c3c60 | `ai.session.id` |
| Device Locale | x | x | Locale of Host OS | en-US | `ai.device.locale` |
| PowerShell Edition | x | x | Desktop or Core | Core | `powershell.edition` |
| PowerShell Version | x | x | version | 7.0.2 | `powershell.version` |
| TotalDuration | x | x | Duration of script run in seconds | 23,62 | `TotalDuration` |
| Device Manufacturer | | x | Device Manufacturer | LENOVO | `ai.device.oemName` |
| Device model | | x | Device model based on `Win32_ComputerSystem` | ThinkPad P52 | `ai.device.model` |
| Operating System | | x | OS SKU and build | Windows 10 Enterprise (10.0.19041.388)| `ai.device.os` |
| OS Build | | x | OS Build Number | 19041 | `os.build` |
| Amount of RAM | | x | Total amount of RAM in MB | 65311 | `memory.total` |
| Number of Sockets | | x | How many sockets system have | 1 | `cpu.sockets.count` |
| Number of Cores | | x | Total number of CPU cores available | 12 | `cpu.logical.count` |
| Volume Capacity | | x | Capacity of a volume where WSLab was run (in GB) | 954 | `volume.size` |
| Disk Model | | x | Friendly name of a disk where volume with WSLab was run | Samsung SSD 970 PRO 1TB | `disk.model` |
| Disk Media Type | | x | Type of the disk where WSLab was run | SSD | `disk.type` |
| Disk Bus type | | x | Bus connection of the disk where WSLab was run | NVMe | `disk.busType` |

### Specific Events for 2_CreateParentDisks.ps1 script

#### CreateParentDisks.Start
When script is started.
#### CreateParentDisks.Vhd
For each hydrated VHD parent disk.
#### CreateParentDisks.End
When script finished.

### Specific Events to Deploy.ps1 script

#### Deploy.Start
When script is started.

#### Deploy.VM
For each provisioned VM.

#### Deploy.End
When script finished.

| |Basic|Full|Description|
|-----------------------------|:---:|:--:|-----------|
|VMDeploymentDuration |x |x |Duration of Deploy.ps1 script|
|Deployed VM OSBuild |x |x |For example 19041|
|Deployed VM InstallationType |x |x |For example Server Core|
|Deployed VM OsVersion |x |x |For example 10.0.17763.1282|
|Deployed VM EditionID |x |x |For example ServerDatacenter|

### Specific to Cleanup.ps1

| |Basic|Full|Description|
|-----------|:---:|:--:|-----------|
| lab.removed.count |x |x |Number of removed VMs|



4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# WSLab Introduction

| Last Update | Latest Release | |
| --- | --- | -- |
| [![GitHub last commit](https://img.shields.io/github/last-commit/Microsoft/wslab/master.svg?style=flat-square)]() | [![GitHub release](https://img.shields.io/github/release/microsoft/wslab.svg?style=flat-square)](https://aka.ms/wslab/download) | [![Download](https://img.shields.io/static/v1?label=&message=Download+WSLab&color=green&style=for-the-badge)](https://aka.ms/wslab/download) |

<!-- TOC -->

- [WSLab Introduction](#wslab-introduction)
Expand Down
Loading

0 comments on commit 42218e9

Please sign in to comment.