You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

azure-pipelines.yml 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. trigger:
  2. - master
  3. stages:
  4. - stage: fuzzit
  5. displayName: "Run Fuzzit"
  6. dependsOn: []
  7. condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))
  8. jobs:
  9. - job: submit
  10. displayName: "Submit"
  11. pool:
  12. vmImage: ubuntu-latest
  13. steps:
  14. - task: GoTool@0
  15. displayName: "Install Go 1.15"
  16. inputs:
  17. version: "1.15"
  18. - script: echo "##vso[task.setvariable variable=PATH]${PATH}:/home/vsts/go/bin/"
  19. - script: mkdir -p ${HOME}/go/src/github.com/pelletier/go-toml
  20. - script: cp -R . ${HOME}/go/src/github.com/pelletier/go-toml
  21. - task: Bash@3
  22. inputs:
  23. filePath: './fuzzit.sh'
  24. env:
  25. TYPE: fuzzing
  26. FUZZIT_API_KEY: $(FUZZIT_API_KEY)
  27. - stage: run_checks
  28. displayName: "Check"
  29. dependsOn: []
  30. jobs:
  31. - job: fmt
  32. displayName: "fmt"
  33. pool:
  34. vmImage: ubuntu-latest
  35. steps:
  36. - task: GoTool@0
  37. displayName: "Install Go 1.15"
  38. inputs:
  39. version: "1.15"
  40. - task: Go@0
  41. displayName: "go fmt ./..."
  42. inputs:
  43. command: 'custom'
  44. customCommand: 'fmt'
  45. arguments: './...'
  46. - job: coverage
  47. displayName: "coverage"
  48. pool:
  49. vmImage: ubuntu-latest
  50. steps:
  51. - task: GoTool@0
  52. displayName: "Install Go 1.15"
  53. inputs:
  54. version: "1.15"
  55. - task: Go@0
  56. displayName: "Generate coverage"
  57. inputs:
  58. command: 'test'
  59. arguments: "-race -coverprofile=coverage.txt -covermode=atomic"
  60. - task: Bash@3
  61. inputs:
  62. targetType: 'inline'
  63. script: 'bash <(curl -s https://codecov.io/bash) -t ${CODECOV_TOKEN}'
  64. env:
  65. CODECOV_TOKEN: $(CODECOV_TOKEN)
  66. - job: benchmark
  67. displayName: "benchmark"
  68. pool:
  69. vmImage: ubuntu-latest
  70. steps:
  71. - task: GoTool@0
  72. displayName: "Install Go 1.15"
  73. inputs:
  74. version: "1.15"
  75. - script: echo "##vso[task.setvariable variable=PATH]${PATH}:/home/vsts/go/bin/"
  76. - task: Bash@3
  77. inputs:
  78. filePath: './benchmark.sh'
  79. arguments: "master $(Build.Repository.Uri)"
  80. - job: fuzzing
  81. displayName: "fuzzing"
  82. pool:
  83. vmImage: ubuntu-latest
  84. steps:
  85. - task: GoTool@0
  86. displayName: "Install Go 1.15"
  87. inputs:
  88. version: "1.15"
  89. - script: echo "##vso[task.setvariable variable=PATH]${PATH}:/home/vsts/go/bin/"
  90. - script: mkdir -p ${HOME}/go/src/github.com/pelletier/go-toml
  91. - script: cp -R . ${HOME}/go/src/github.com/pelletier/go-toml
  92. - task: Bash@3
  93. inputs:
  94. filePath: './fuzzit.sh'
  95. env:
  96. TYPE: local-regression
  97. - job: go_unit_tests
  98. displayName: "unit tests"
  99. strategy:
  100. matrix:
  101. linux 1.15:
  102. goVersion: '1.15'
  103. imageName: 'ubuntu-latest'
  104. mac 1.15:
  105. goVersion: '1.15'
  106. imageName: 'macOS-latest'
  107. windows 1.15:
  108. goVersion: '1.15'
  109. imageName: 'windows-latest'
  110. linux 1.14:
  111. goVersion: '1.14'
  112. imageName: 'ubuntu-latest'
  113. mac 1.14:
  114. goVersion: '1.14'
  115. imageName: 'macOS-latest'
  116. windows 1.14:
  117. goVersion: '1.14'
  118. imageName: 'windows-latest'
  119. pool:
  120. vmImage: $(imageName)
  121. steps:
  122. - task: GoTool@0
  123. displayName: "Install Go $(goVersion)"
  124. inputs:
  125. version: $(goVersion)
  126. - task: Go@0
  127. displayName: "go test ./..."
  128. inputs:
  129. command: 'test'
  130. arguments: './...'
  131. - stage: build_binaries
  132. displayName: "Build binaries"
  133. dependsOn: run_checks
  134. jobs:
  135. - job: build_binary
  136. displayName: "Build binary"
  137. strategy:
  138. matrix:
  139. linux_amd64:
  140. GOOS: linux
  141. GOARCH: amd64
  142. darwin_amd64:
  143. GOOS: darwin
  144. GOARCH: amd64
  145. windows_amd64:
  146. GOOS: windows
  147. GOARCH: amd64
  148. pool:
  149. vmImage: ubuntu-latest
  150. steps:
  151. - task: GoTool@0
  152. displayName: "Install Go"
  153. inputs:
  154. version: 1.15
  155. - task: Bash@3
  156. inputs:
  157. targetType: inline
  158. script: "make dist"
  159. env:
  160. go.goos: $(GOOS)
  161. go.goarch: $(GOARCH)
  162. - task: CopyFiles@2
  163. inputs:
  164. sourceFolder: '$(Build.SourcesDirectory)'
  165. contents: '*.tar.xz'
  166. TargetFolder: '$(Build.ArtifactStagingDirectory)'
  167. - task: PublishBuildArtifacts@1
  168. inputs:
  169. pathtoPublish: '$(Build.ArtifactStagingDirectory)'
  170. artifactName: binaries
  171. - stage: build_binaries_manifest
  172. displayName: "Build binaries manifest"
  173. dependsOn: build_binaries
  174. jobs:
  175. - job: build_manifest
  176. displayName: "Build binaries manifest"
  177. steps:
  178. - task: DownloadBuildArtifacts@0
  179. inputs:
  180. buildType: 'current'
  181. downloadType: 'single'
  182. artifactName: 'binaries'
  183. downloadPath: '$(Build.SourcesDirectory)'
  184. - task: Bash@3
  185. inputs:
  186. targetType: inline
  187. script: "cd binaries && sha256sum --binary *.tar.xz | tee $(Build.ArtifactStagingDirectory)/sha256sums.txt"
  188. - task: PublishBuildArtifacts@1
  189. inputs:
  190. pathtoPublish: '$(Build.ArtifactStagingDirectory)'
  191. artifactName: manifest
  192. - stage: build_docker_image
  193. displayName: "Build Docker image"
  194. dependsOn: run_checks
  195. jobs:
  196. - job: build
  197. displayName: "Build"
  198. pool:
  199. vmImage: ubuntu-latest
  200. steps:
  201. - task: Docker@2
  202. inputs:
  203. command: 'build'
  204. Dockerfile: 'Dockerfile'
  205. buildContext: '.'
  206. addPipelineData: false
  207. - stage: publish_docker_image
  208. displayName: "Publish Docker image"
  209. dependsOn: build_docker_image
  210. condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))
  211. jobs:
  212. - job: publish
  213. displayName: "Publish"
  214. pool:
  215. vmImage: ubuntu-latest
  216. steps:
  217. - task: Docker@2
  218. inputs:
  219. containerRegistry: 'DockerHub'
  220. repository: 'pelletier/go-toml'
  221. command: 'buildAndPush'
  222. Dockerfile: 'Dockerfile'
  223. buildContext: '.'
  224. tags: 'latest'