Skip to content

Commit

Permalink
Attempts to save version vars for release stage
Browse files Browse the repository at this point in the history
Also  modifies git_version to use correct branch even with a detached head.
git_version will also now set azure pipelines variables when invoked with -set_ci

Also simplifies the testing commands. I'm at the point where since I'm customizing nearly every option of dotnetcli@2 test theere's no reason to continue using it - it just obscure the actual command.

[WIP] starts work for release notes

Work done for #196
  • Loading branch information
atruskie committed Apr 2, 2020
1 parent e2a5a6b commit 53e9efb
Show file tree
Hide file tree
Showing 13 changed files with 775 additions and 105 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,9 @@ Icon
Network Trash Folder
Temporary Items
.apdisk

# FSharp
.ionide/symbolCache.db

# dotnet global tools
.store
6 changes: 6 additions & 0 deletions .grenrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dataSource: "issues"
prefix: "v"
onlyMilestones: false
groupBy: "label"
changelogFilename: "CHANGELOG.md"
561 changes: 561 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
and improve on this.

[![codecov](https://codecov.io/gh/QutEcoacoustics/audio-analysis/branch/master/graph/badge.svg)](https://codecov.io/gh/QutEcoacoustics/audio-analysis)
- Try to structure commit messages in a format recognised by our release note generator
[![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/)


## Required Software

Expand Down
47 changes: 44 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
name: $(Date:yyyyMMdd)$(Rev:.r)

schedules:
# at midnight every monday (UTC)
- cron: 0 0 * * 0
displayName: Weekly Release
branches:
include: master


variables:
build: '$(Build.BuildID)'
system.debug: true
NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
CI: true

# Run on all commits, except for some folders
trigger:
batch: true
branches:
include:
- '*'
- '*'
exclude:
- refs/tags/*
paths:
exclude:
- docs/*
Expand All @@ -21,5 +32,35 @@ stages:
- stage: build
jobs:
- template: build/azure-pipelines-build.yml
#- stage: release

- stage: release
jobs:
displayName: Release
variables:
manualRelease: $( contains(variables['Build.SourceVersionMessage'], '[release]')
weeklyRelease: $( eq(variables['Build.Reason'],'Schedule'))
steps:
- pwsh: Write-Host "##vso[task.complete result=Canceled;]Skipping release"
# cancel the job, if
# it is not a weekly release
# and
# it is not a manual release
condition: and(ne(weeklyRelease, true), ne(manualRelease, true))
displayName: Cancel the release unless we want it to continue

# downloads to $(System.ArtifactsDirectory)
- task: DownloadBuildArtifacts@0
inputs:
buildType: current
downloadType: all
displayName: Download previous build artefacts

- pwsh: |
Get-ChildItem -recurse $(System.ArtifactsDirectory)
Get-Content $(System.ArtifactsDirectory)/AP_version_vars.txt | Write-Output
displayName: Reconstitute variables
- pwsh: ./build/
env:
GREN_GITHUB_TOKEN: $(GREN_GITHUB_TOKEN)
displayName: Generate release notes

9 changes: 0 additions & 9 deletions build.ps1

This file was deleted.

106 changes: 66 additions & 40 deletions build/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ parameters:
# cross-product not supported
# https://github.com/microsoft/azure-pipelines-yaml/issues/20

# useful article on directory layout: https://github.com/microsoft/azure-pipelines-agent/blob/master/docs/jobdirectories.md#build
jobs:
- ${{ each platform in parameters.platforms }}:
- ${{ each configuration in platform.configurations }}:
Expand Down Expand Up @@ -108,8 +109,14 @@ jobs:
nugetConfigPath: NuGet.config
displayName: Restore solution dependencies

- pwsh: src/git_version.ps1 -build_type ${{ configuration }}
displayName: debug git_version.ps1 script
- pwsh: src/git_version.ps1 -build_type ${{ configuration }} -set_ci | Tee-Object '$(Build.ArtifactStagingDirectory)/AP_version_vars.txt'
displayName: run git_version.ps1 script
name: git_version

- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/AP_version_vars.txt'
artifactName: AP_$(platformTag)$(configurationTag)

- task: DotNetCoreCLI@2
inputs:
Expand All @@ -119,40 +126,56 @@ jobs:
displayName: Build solution (${{ configuration }}, ${{ coalesce(platform.rid, 'any') }})

# https://github.com/microsoft/vstest/issues/2202 -- need to remove --no-build to make tests work on linux
- task: DotNetCoreCLI@2
inputs:
command: test
projects: tests/Acoustics.Test/Acoustics.Test.csproj
publishTestResults: true
testRunTitle: "Acoustics.Test for ${{ coalesce(platform.rid, 'any') }} ${{ configuration }}"
arguments: >
$(runtimeArgument)
--configuration ${{ configuration }}
--settings tests/Acoustics.Test/.runsettings
--logger trx
--collect:"XPlat Code Coverage"
--
RunConfiguration.DisableAppDomain=true
- pwsh: >
dotnet test
tests/Acoustics.Test/Acoustics.Test.csproj
$(runtimeArgument)
--configuration ${{ configuration }}
--logger trx
--settings tests/Acoustics.Test/.runsettings
--collect:"XPlat Code Coverage"
--results-directory '$(Agent.TempDirectory)/Acoustics.Test_Results'
--
RunConfiguration.DisableAppDomain=true
displayName: Run Acoustics.Test
- task: PublishTestResults@2
inputs:
testResultFormat: VSTest
testResultFiles: '$(Agent.TempDirectory)/Acoustics.Test_Results/**/*.trx'
testRunTitle: "Acoustics.Test for ${{ platform.rid }} ${{ configuration }}"
buildConfig: ${{ configuration }}
buildPlatform: $(platformTag)
publishRunAttachments: true
condition: succeededOrFailed()
displayName: Publish Acoustics.Tests results

# https://github.com/microsoft/vstest/issues/2202 -- need to remove --no-build to make tests work on linux
- task: DotNetCoreCLI@2
# run even if other tests failed
- pwsh: >
dotnet test
tests/AED.Test/AED.Test.fsproj
$(runtimeArgument)
--configuration ${{ configuration }}
--logger trx
--settings tests/AED.Test/.runsettings
--collect:"XPlat Code Coverage"
--results-directory '$(Agent.TempDirectory)/AED.Test_Results'
--
RunConfiguration.DisableAppDomain=true
# run even if other tests failed
condition: succeededOrFailed()
displayName: Run AED.Test

- task: PublishTestResults@2
inputs:
testResultFormat: VSTest
testResultFiles: '$(Agent.TempDirectory)/AED.Test_Results/**/*.trx'
testRunTitle: ".Test for ${{ platform.rid }} ${{ configuration }}"
buildConfig: ${{ configuration }}
buildPlatform: $(platformTag)
publishRunAttachments: true
condition: succeededOrFailed()
inputs:
command: test
projects: tests/AED.Test/AED.Test.fsproj
publishTestResults: true
testRunTitle: "AED.Test for ${{ platform.rid }} ${{ configuration }}"
arguments: >
$(runtimeArgument)
--configuration ${{ configuration }}
--logger trx
--settings tests/AED.Test/.runsettings
--collect:"XPlat Code Coverage"
--
RunConfiguration.DisableAppDomain=true
displayName: Run AED.Test
displayName: Publish AED.Tests results

- task: DotNetCoreCLI@2
condition: succeededOrFailed()
Expand All @@ -162,19 +185,22 @@ jobs:
arguments: install --tool-path . dotnet-reportgenerator-globaltool
displayName: Install ReportGenerator tool

# e.g. /home/vsts/work/_temp/68a005a0-e79f-46ca-a524-52abd13b3678/coverage.cobertura.xml
# e.g. /home/vsts/work/_temp/Acoustics.Test_Results/<guid>/coverage.cobertura.xml
# e.g. /home/vsts/work/_temp/AED.Test_Results/<guid>/coverage.cobertura.xml
# e.g. /home/vsts/work/1/s/coverlet/reports
- pwsh: >
./reportgenerator
-reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml
-targetdir:$(Build.SourcesDirectory)/coverlet/reports
-reports:$(Agent.TempDirectory)/*Test_Results/**/coverage.cobertura.xml
-sourcedirs:$(Build.SourcesDirectory)
-targetdir:'$(Agent.TempDirectory)/coverlet/reports'
-reporttypes:"Cobertura"
displayName: Create reports cobertura reports
-verbosity:verbose
displayName: Create cobertura reports
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml
summaryFileLocation: $(Agent.TempDirectory)/coverlet/reports/Cobertura.xml
displayName: 'Publish code coverage'

- task: DotNetCoreCLI@2
Expand All @@ -185,7 +211,7 @@ jobs:
arguments: install --global Codecov.Tool
displayName: Install CodeCov Tool

- pwsh: codecov -f $(Agent.TempDirectory)/**/coverage.opencover.xml -t $(CODECOV_TOKEN)
- pwsh: codecov -f $(Agent.TempDirectory)/*Test_Results/**/coverage.opencover.xml -t $(CODECOV_TOKEN)
displayName: Upload CodeCov report

- task: DotNetCoreCLI@2
Expand All @@ -212,11 +238,11 @@ jobs:
includeRootFolder: false
${{ if startsWith(platform.pool, 'windows') }}:
archiveType: zip
archiveFile: '$(Build.ArtifactStagingDirectory)/AP_$(platformTag)$(configurationTag)_$(Build.DefinitionName).zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/AP_$(platformTag)$(configurationTag)_$(Build.BuildNumber).zip'
${{ if not(startsWith(platform.pool, 'windows')) }}:
archiveType: tar
tarCompression: xz
archiveFile: '$(Build.ArtifactStagingDirectory)/AP_$(platformTag)$(configurationTag)_$(Build.DefinitionName).tar.xz'
archiveFile: '$(Build.ArtifactStagingDirectory)/AP_$(platformTag)$(configurationTag)_$(Build.BuildNumber).tar.xz'

displayName: Archive published app

Expand Down
5 changes: 0 additions & 5 deletions build/azure-pipelines-test.yml

This file was deleted.

33 changes: 10 additions & 23 deletions build/release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,10 @@
param($tag_name, [bool]$ci = $false, [bool]$pre_release = $true)
$ErrorActionPreference = "Continue"

function script:exec {
[CmdletBinding()]

param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ("Error executing command: {0}" -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0)
{
throw $errorMessage
}
}

function Check-Command($cmdname)
{
return [bool](Get-Command -Name $cmdname -ErrorAction SilentlyContinue)

function Check-Command($cmdname) {
return [bool](Get-Command -Name $cmdname -ErrorAction SilentlyContinue)
}
if (!$ci -and !(Check-Command hub)) {
throw "Cannot find needed executable dependencies";
Expand All @@ -32,11 +19,11 @@ if (!$ci -and !(Check-Command hub)) {

echo "Creating release message"
# we assumed we've already tagged before describing this release
$old_tag_name = exec { git describe --abbrev=0 --always "$tag_name^" }
$old_tag_name = exec { git describe --abbrev=0 --always "$tag_name^" }

$compare_message = "[Compare $old_tag_name...$tag_name](https://github.com/QutBioacoustics/audio-analysis/compare/$old_tag_name...$tag_name)"
$commit_summary = exec { git log --no-merges --pretty=format:"%h %an - %s" "$old_tag_name...$tag_name" -- . ':(exclude,icase)*.r' }
$commit_summary = ($commit_summary | % { "- " + $_ }) -join "`n"
$commit_summary = ($commit_summary | % { "- " + $_ }) -join "`n"
$release_message = "Version $tag_name`n`n$compare_message`n`n$commit_summary"
$env:ApReleaseMessage = $release_message
$release_title = "Ecoacoustics Audio Analysis Software $tag_name"
Expand All @@ -46,13 +33,13 @@ echo "Release strings:`n$release_title`n$release_message"


if (!$ci) {
# create and upload a github release
echo "creating github release"
# create and upload a github release
echo "creating github release"

$artifacts = ((ls .\src\AnalysisPrograms\bin\*.zip) | % { "-a " + $_ }) -join " "
$artifacts = ((ls .\src\AnalysisPrograms\bin\*.zip) | % { "-a " + $_ }) -join " "

hub release create "$(if($pre_release){"-p"})" $artifacts -m $release_message $tag_name
hub release create "$(if($pre_release){"-p"})" $artifacts -m $release_message $tag_name

echo "Release created!"
echo "Release created!"

}
48 changes: 48 additions & 0 deletions build/release_notes.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/pwsh

# Create a release message and changelog.
# Assumes a tag has not yet been created.
param(
$tag_name
)

if ($null -eq (Get-Module PowerShellForGitHub)) {
Install-Module -Name PowerShellForGitHub -Force -Scope CurrentUser
Import-Module PowerShellForGitHub
}

Set-GitHubConfiguration -DefaultOwnerName QutEcoacoustics -DefaultRepositoryName audio-analysis -SuppressTelemetryReminder
$secureString = ($env:RELEASE_NOTES_GITHUB_TOKEN | ConvertTo-SecureString)
$cred = New-Object System.Management.Automation.PSCredential "username is ignored", $secureString
Set-GitHubAuthentication -Credential $cred

function script:exec {
[CmdletBinding()]

param(
[Parameter(Position = 0, Mandatory = 1)][scriptblock]$cmd,
[Parameter(Position = 1, Mandatory = 0)][string]$errorMessage = ("Error executing command: {0}" -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw $errorMessage
}
}

$old_tag_name = exec { git describe --abbrev=0 --always }
#$old_tag_date = exec { git log -1 --format=%ai $old_tag_name }


$compare_message = "[Compare $old_tag_name...$tag_name](https://github.com/QutBioacoustics/audio-analysis/compare/$old_tag_name...$tag_name)"





# list all issues and PRs



# list all commits
# link author
# cite issues
Loading

0 comments on commit 53e9efb

Please sign in to comment.