Skip to content

Commit a3b3f2b

Browse files
author
parisb
committed
ci: add azdo
1 parent 0230ea3 commit a3b3f2b

37 files changed

+2858
-1019
lines changed

.azdo/pr.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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'

.github/copilot-instructions.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22

33
<!-- Testing -->
44

5-
When generating unit tests for go, use table-driven tests where appropriate and always use the arrange, act, assert pattern and indicate these "regions" with comments, even if there is nothing to do in that region.
5+
When generating unit tests for go, use table-driven tests where appropriate and always use the arrange, act, assert pattern and indicate these
6+
"regions" with comments, even if there is nothing to do in that region.
7+
8+
When testing the parsing or manipulation of config files (yaml, json, toml), always embed a literal document in the test case itself. Rather than being arbitrary values, they should be like configurations as they would be in normal use of the application.
9+
10+
When testing unexported methods or functions, these tests should be created in a file called `export_test.go` in the same package as the tested method or function.
611

712
Wherever the tested method or function uses the afero package, always use a memmap fs as the filesystem in tests (i.e. don't write to disk where this can be avoided.).
813

914
When writing assertions in tests, do not abstract assertion/verification logic into functions stores in test cases, explicitly define the assertion or verification logic in the "Assert" portion of the test; use conditional logic if needed here.
1015

1116
When creating a test file, the package name should always be the package name with "\_test" appended.
1217

18+
When creating or satisfying a slog logger on services, always use the DiscardHandler
19+
1320
<!-- Style -->
1421

1522
Any comments you include above functions or types should end with a period.

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ linters:
344344
nolintlint:
345345
# Exclude following linters from requiring an explanation.
346346
# Default: []
347-
allow-no-explanation: [funlen, gocognit, golines, mnd]
347+
allow-no-explanation: [funlen, gocognit, golines, mnd, nestif]
348348
# Enable to require an explanation of nonzero length after each nolint directive.
349349
# Default: false
350350
require-explanation: true

0 commit comments

Comments
 (0)