Skip to content

Commit

Permalink
Feature/abzu 159849 pipeline simplification (#273)
Browse files Browse the repository at this point in the history
* New build yaml

* Fix indentation

* Set container

* Put container back

* Pipeline rework

* Fix typo

* Set container

* Further fix

* Add parameters

* Add jobs

* More fixes

* Update code coverage

* More updates

* Further fix

* Fix

* Fix

* Revert rename

* Remove dev retention

* Retain test media

* Remove unused variable

* Remove more commented out code

* Update NVD suppressions
  • Loading branch information
HugoBurgess authored Jun 4, 2024
1 parent 083a179 commit 130ae2f
Show file tree
Hide file tree
Showing 16 changed files with 583 additions and 838 deletions.
29 changes: 0 additions & 29 deletions Deployment/add-lease.ps1

This file was deleted.

53 changes: 24 additions & 29 deletions Deployment/checkwebsitestatus.ps1
Original file line number Diff line number Diff line change
@@ -1,53 +1,48 @@

Param(
[Parameter(mandatory=$true)][string]$fssUIWebUrl,
[Parameter(mandatory=$true)][string]$waitTimeInMinute
param(
[Parameter(mandatory=$true)][string]$FssUiWebUrl,
[Parameter(mandatory=$true)][string]$WaitTimeInMinutes
)

$sleepTimeInSecond = 15
$isServiceActive = 'false'

$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch
$timeSpan = New-TimeSpan -Minutes $waitTimeInMinute
$timeSpan = New-TimeSpan -Minutes $WaitTimeInMinutes
$stopWatch.Start()

do
{
Write-Host "Polling url: $fssUIWebUrl ..."
try{
$HttpRequest = [System.Net.WebRequest]::Create("$fssUIWebUrl")
$HttpResponse = $HttpRequest.GetResponse()
$HttpStatus = $HttpResponse.StatusCode
Write-Host "Status code of web is $HttpStatus ..."
do {
Write-Host "Polling url: $FssUiWebUrl..."

try {
$httpRequest = [System.Net.WebRequest]::Create("$FssUiWebUrl")
$httpResponse = $httpRequest.GetResponse()
$httpStatus = $httpResponse.StatusCode
Write-Host "Status code of web is $httpStatus..."

If ($HttpStatus -eq 200 ) {
if ($httpStatus -eq 200 ) {
Write-Host "Website is up. Stopping Polling ..."
$isServiceActive = 'true'
break
}
Else {
Write-Host "Website not yet Up. Status code: $HttpStatus re-checking after $sleepTimeInSecond sec ..."
} else {
Write-Host "Website not yet up. Status code: $httpStatus, re-checking after $sleepTimeInSecond sec..."
}
}
catch [System.Net.WebException]
{
$HttpStatus = $_.Exception.Response.StatusCode
Write-Host "Website not yet Up.Status: $HttpStatus re-checking after $sleepTimeInSecond sec ..."
$httpStatus = $_.Exception.Response.StatusCode
Write-Host "Website not yet up. Status code: $httpStatus, re-checking after $sleepTimeInSecond sec..."
}

Start-Sleep -Seconds $sleepTimeInSecond
}
until ($stopWatch.Elapsed -ge $timeSpan)
} until ($stopWatch.Elapsed -ge $timeSpan)


If ($HttpResponse -ne $null) {
$HttpResponse.Close()
if ($httpResponse -ne $null) {
$httpResponse.Close()
}

if ($isServiceActive -eq 'true' ) {
Write-Host "Website is up returning from script ..."
}
Else {
Write-Error "Website was not up in $waitTimeInMinute, error while deployment ..."
Write-Host "Website is up, returning from script..."
} else {
Write-Error "Website was not up in $WaitTimeInMinutes, error in deployment."
throw "Error"
}
}
100 changes: 100 additions & 0 deletions Deployment/templates/build-test-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
parameters:
# Skip the NVD dependency check job.
- name: SkipDependencyCheck
type: boolean
default: false
# The Terraform Azure PowerShell container.
- name: Container
type: string

jobs:
- job: Dependencychecker
condition: ne('${{ parameters.SkipDependencyCheck }}', true)
pool: $(WindowPool)
displayName: Dependency checker
workspace:
clean: all
steps:
- task: NodeTool@0
displayName: Install Node.js
inputs:
versionSpec: $(NodeVersion)

- script: |
npm ci
displayName: npm restore
- task: CmdLine@1
displayName: Run OWASP dependency-check
inputs:
filename: 'dependency-check.bat'
arguments: '--project "UKHO.FileShareService.UI - $(Build.SourceBranchName)" --scan "$(Build.SourcesDirectory)" --out "$(Build.ArtifactStagingDirectory)\DCReport" --suppression $(Build.SourcesDirectory)\NVDSuppressions.xml --noupdate --disableYarnAudit'

- task: PublishBuildArtifacts@1
displayName: Publish OWASP dependency-check report
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\DCReport'
ArtifactName: "OWASP Dependency Checker Report"

- task: PowerShell@1
displayName: Fail build if OWASP dependency-check finds any vulnerabilities
inputs:
scriptType: inlineScript
arguments: '-ReportLocation $(Build.ArtifactStagingDirectory)\DCReport\*'
inlineScript: |
param($ReportLocation)
Invoke-VulnerabilityCheck -ReportLocation $ReportLocation
- job: BuildTestPublish
displayName: Build, test and publish
pool: $(DeploymentPool)
container: ${{ parameters.Container }}
workspace:
clean: all
steps:
- checkout: self

- task: NodeTool@0
displayName: Install Node.js
inputs:
versionSpec: $(NodeVersion)

- script: |
npm ci
displayName: npm restore
- script: |
npm run build
displayName: npm build
- script: |
npm run test:unit
continueOnError: false
displayName: Unit test with Jest
- task: PublishTestResults@2
condition: succeededOrFailed()
displayName: Publish unit test results
inputs:
testRunner: 'JUnit'
testResultsFiles: 'junit.xml'
testRunTitle: Unit Test Results

- task: PublishCodeCoverageResults@1
displayName: Publish code coverage results
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
reportDirectory: 'coverage/'

- task: PublishBuildArtifacts@1
displayName: Publish angular app artifacts
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/dist'
ArtifactName: AngularApp

- task: PublishBuildArtifacts@1
displayName: Publish deployment artifact
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/Deployment'
ArtifactName: DeploymentScripts
52 changes: 0 additions & 52 deletions Deployment/templates/continous-deployment.yml

This file was deleted.

Loading

0 comments on commit 130ae2f

Please sign in to comment.