|
| 1 | +trigger: none |
| 2 | + |
| 3 | +resources: |
| 4 | + containers: |
| 5 | + - container: 'sonarscan' |
| 6 | + image: 'sonarsource/sonarcloud-scan' |
| 7 | + repositories: |
| 8 | + - repository: pipelineTemplates |
| 9 | + type: git |
| 10 | + name: "PLT.INFRA.PIPELINES/PLT.INFRA.PIPELINES" |
| 11 | + ref: "refs/heads/main" |
| 12 | + |
| 13 | +variables: |
| 14 | + orgName: 'parisbrooker-iac' |
| 15 | +stages: |
| 16 | + - stage: entry_criteria |
| 17 | + displayName: "[STAGE] Entry Criteria" |
| 18 | + jobs: |
| 19 | + - template: "/jobs/precommit_checks_job.yaml@pipelineTemplates" |
| 20 | + - template: "/jobs/commitlint_lint_job.yaml@pipelineTemplates" |
| 21 | + - stage: 'stage_test_build' |
| 22 | + displayName: '[STAGE] Test and Build' |
| 23 | + variables: |
| 24 | + GOVERSION: '1.23.5' # Version of Go tools used for building and testing |
| 25 | + CGO_ENABLED: '0' # Disable cgo to get a static binary |
| 26 | + GOOS: 'linux' |
| 27 | + GOARCH: 'amd64' |
| 28 | + jobs: |
| 29 | + |
| 30 | + - job: job_go_test_build |
| 31 | + displayName: '[JOB] Test and Build' |
| 32 | + pool: |
| 33 | + vmImage: 'ubuntu-latest' |
| 34 | + |
| 35 | + steps: |
| 36 | + - checkout: self |
| 37 | + fetchDepth: 0 |
| 38 | + |
| 39 | + - task: GoTool@0 |
| 40 | + displayName: '[TOOLS] Install Go $(GOVERSION)' |
| 41 | + inputs: |
| 42 | + version: $(GOVERSION) |
| 43 | + |
| 44 | + - task: UseDotNet@2 |
| 45 | + displayName: '[TOOLS] Install .NET Core sdk 8.0.x' |
| 46 | + inputs: |
| 47 | + version: 8.0.x |
| 48 | + |
| 49 | + - script: | |
| 50 | + sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin |
| 51 | + name: taskfile |
| 52 | + displayName: '[TOOLS] Install Taskfile' |
| 53 | +
|
| 54 | + - task: SonarCloudPrepare@3 |
| 55 | + displayName: '[SCAN] Prepare analysis configuration' |
| 56 | + inputs: |
| 57 | + SonarCloud: 'testing' |
| 58 | + organization: 'parisbrooker-iac' |
| 59 | + scannerMode: 'CLI' |
| 60 | + projectKey: parisbrooker-iac_rp.plt.product.tmpltr |
| 61 | + projectName: rp.plt.product.tmpltr |
| 62 | + |
| 63 | + - script: | |
| 64 | + # Get tools for converting Go's test reports |
| 65 | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.63.4 |
| 66 | + ~/.local/bin/task get_test_dependencies |
| 67 | + ~/.local/bin/task test_coverage |
| 68 | + $HOME/go/bin/golangci-lint run ./... |
| 69 | +
|
| 70 | + displayName: '[TEST] Go Test' |
| 71 | + failOnStderr: false |
| 72 | +
|
| 73 | + - script: | |
| 74 | + ~/.local/bin/task build |
| 75 | + displayName: '[BUILD] Go Binary' |
| 76 | +
|
| 77 | + - task: SonarCloudAnalyze@3 |
| 78 | + displayName: '[SCAN] Run SonarCloud analysis' |
| 79 | + |
| 80 | + - task: SonarCloudPublish@3 |
| 81 | + displayName: '[SCAN] Publish results on build summary' |
| 82 | + |
| 83 | + - task: reportgenerator@5 |
| 84 | + displayName: '[TEST] Generate Report' |
| 85 | + inputs: |
| 86 | + reports: 'coverage.xml' |
| 87 | + reportTypes: "HtmlInline_AzurePipelines_Dark;Cobertura" |
| 88 | + publishCodeCoverageResults: true |
| 89 | + |
| 90 | + - task: PublishTestResults@2 |
| 91 | + displayName: '[TEST] Publish Test Results' |
| 92 | + inputs: |
| 93 | + testRunner: JUnit |
| 94 | + testResultsFiles: $(Build.SourcesDirectory)/report.xml |
| 95 | + searchFolder: $(Build.SourcesDirectory) |
| 96 | + |
| 97 | + - publish: '$(Build.SourcesDirectory)/bin/tmpltr' |
| 98 | + artifact: 'Executable' |
| 99 | + displayName: '[BUILD] Publish pipeline artifact' |
0 commit comments