-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bicep build task and add support ro run multiple Npm run scripts (#…
…23) Co-authored-by: philo <[email protected]>
- Loading branch information
Showing
13 changed files
with
254 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#load "Configuration.cake" | ||
|
||
public partial class Configuration { | ||
|
||
public Configuration RegisterBicepPath(string bicepPath) | ||
{ | ||
context.Tools.RegisterFile(bicepPath); | ||
|
||
return this; | ||
} | ||
|
||
public Configuration WithBicepFile(params string[] bicepFilePattern) | ||
{ | ||
var files = bicepFilePattern | ||
.ToList() | ||
.SelectMany(context.GetFiles) | ||
.ToArray(); | ||
|
||
this.TaskParameters.Add("Bicep:Files", files); | ||
|
||
return this; | ||
} | ||
} | ||
|
||
Task("Bicep:Build") | ||
.IsDependeeOf("Build") | ||
.Does<Configuration>(config => | ||
{ | ||
var settings = new ProcessSettings() | ||
{ | ||
RedirectStandardOutput = false | ||
}; | ||
|
||
var bicepExe = Context.Tools.Resolve("bicep.exe"); | ||
|
||
if(bicepExe != null) | ||
{ | ||
var bicepFiles = config.GetTaskParameter<FilePath[]>("Bicep:Files", new FilePath[] { "" }); | ||
|
||
Verbose("Building {0} bicep files", bicepFiles.Count()); | ||
foreach(var bicepFile in bicepFiles.Where(f => FileExists(f))) | ||
{ | ||
Information("Building {0}...", bicepFile); | ||
settings.Arguments = string.Format("build {0}", bicepFile); | ||
|
||
using(var process = StartAndReturnProcess(bicepExe, settings)) | ||
{ | ||
process.WaitForExit(); | ||
if(process.GetExitCode() != 0) | ||
{ | ||
Error("Failed"); | ||
} | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
Error("Unable to resolve bicep tool location"); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,59 @@ | ||
trigger: | ||
batch: true | ||
branches: | ||
include: | ||
- master | ||
- release/* | ||
jobs: | ||
- job: Build | ||
pool: | ||
name: Storm-Build-Production | ||
variables: | ||
cake.buildTarget: 'CI' | ||
build.configuration: 'Release' | ||
cake.verbosity: 'Verbose' | ||
steps: | ||
- checkout: self | ||
clean: true | ||
|
||
- task: ms-codeanalysis.vss-microsoft-security-code-analysis.build-task-credscan.CredScan@2 | ||
displayName: 'Run CredScan' | ||
continueOnError: true | ||
|
||
- powershell: ./build.ps1 -Target "$(cake.buildTarget)" -Configuration "$(build.configuration)" -Verbosity "$(cake.verbosity)" | ||
displayName: 'Cake Build' | ||
|
||
- task: ms-codeanalysis.vss-microsoft-security-code-analysis.build-task-report.SdtReport@1 | ||
displayName: 'Create Security Analysis Report' | ||
inputs: | ||
AllTools: true | ||
ToolLogsNotFoundAction: Error | ||
|
||
- task: ms-codeanalysis.vss-microsoft-security-code-analysis.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2 | ||
displayName: 'Publish Security Analysis Logs' | ||
|
||
- powershell: Write-Host '##vso[build.addbuildtag]PR' | ||
displayName: 'Mark as PR Build' | ||
condition: and(succeeded(), in(variables['Build.Reason'], 'PullRequest')) | ||
|
||
- powershell: Write-Host '##vso[build.addbuildtag]Release' | ||
displayName: 'Mark as Release Build' | ||
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')) | ||
|
||
- task: ms-codeanalysis.vss-microsoft-security-code-analysis.build-task-postanalysis.PostAnalysis@1 | ||
displayName: 'Post Analysis' | ||
inputs: | ||
AllTools: true | ||
- main | ||
- release/* | ||
stages: | ||
- stage: build | ||
displayName: Execute Build | ||
jobs: | ||
- job: BuildArtifacts | ||
displayName: Build Project Artifacts | ||
variables: | ||
NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages | ||
frontend.src: 'src/frontend' | ||
npm_config_cache: $(Pipeline.Workspace)/.npm | ||
bicep.version: 'v0.2.212' | ||
bicep.dir: '$(System.DefaultWorkingDirectory)/tools/bicep' | ||
bicep.exists: false | ||
pool: | ||
vmImage: 'windows-latest' | ||
steps: | ||
- checkout: self | ||
persistCredentials: true | ||
- task: UseDotNet@2 | ||
inputs: | ||
packageType: "sdk" | ||
useGlobalJson: true | ||
- task: UseNode@1 | ||
inputs: | ||
version: 12.x | ||
- task: Cache@2 | ||
inputs: | ||
key: '"$(bicep.version)" | "$(Agent.OS)""' | ||
path: '$(bicep.dir)' | ||
cacheHitVar: 'bicep.exists' | ||
- task: PowerShell@2 | ||
condition: ne(variables['bicep.exists'], 'true') | ||
displayName: Acquire Bicep | ||
inputs: | ||
targetType: 'inline' | ||
script: 'mkdir -Path $(bicep.dir) -Force ; Invoke-WebRequest -Uri https://github.com/Azure/bicep/releases/download/$(bicep.version)/bicep-win-x64.exe -OutFile $(bicep.dir)/bicep.exe' | ||
failOnStderr: true | ||
pwsh: false | ||
workingDirectory: '$(System.DefaultWorkingDirectory)' | ||
- task: DotNetCoreCLI@2 | ||
displayName: Restore dotnet tools | ||
inputs: | ||
command: "custom" | ||
custom: "tool" | ||
arguments: "restore" | ||
- script: dotnet cake" | ||
displayName: Run Cake | ||
- task: GitTag@5 | ||
displayName: "Tag Artifacts" | ||
condition: and(Succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')) | ||
inputs: | ||
workingdir: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)' | ||
tagUser: 'pipeline' | ||
tagEmail: '[email protected]' | ||
tag: '$(build.buildNumber)' | ||
useLightweightTags: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#load ".cake/Configuration.cake" | ||
|
||
/**********************************************************/ | ||
Setup<Configuration>(ctx => | ||
Configuration | ||
.Create(ctx) | ||
.RunNpmScript("ci", "./src/frontend") | ||
.WithBicepFile("./deploy/*.bicep") | ||
.IncludeArtifactCopyTarget("./deploy") | ||
.IncludeAsEfDbContext(p => p.AssemblyName.EndsWith(".Web")) | ||
); | ||
/**********************************************************/ | ||
|
||
#load ".cake/CI.cake" | ||
|
||
// -- DotNetCore | ||
#load ".cake/Npm-RunScript.cake" | ||
#load ".cake/Build-Bicep.cake" | ||
#load ".cake/Restore-DotNetCore.cake" | ||
#load ".cake/Build-DotNetCore.cake" | ||
#load ".cake/Test-DotNetCore.cake" | ||
#load ".cake/Publish-Zip-DotNetCore.cake" | ||
#load ".cake/Publish-Pack-DotNetCore.cake" | ||
#load ".cake/Artifacts-DotNetCore-Ef.cake" | ||
#load ".cake/Artifacts-Copy.cake" | ||
// ------------- | ||
|
||
RunTarget(Argument("target", Argument("Target", "Default"))); |
Oops, something went wrong.