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.

158 lines
4.6 KiB

  1. name: 2.6.$(Rev:r)
  2. trigger:
  3. - dev
  4. - latest
  5. stages:
  6. - stage: build
  7. displayName: Build stage
  8. jobs:
  9. # -------------------------------
  10. # BUILD - LINUX
  11. # -------------------------------
  12. - job: buildLinux
  13. displayName: Linux Build
  14. timeoutInMinutes: 60
  15. cancelTimeoutInMinutes: 1
  16. pool:
  17. name: Azure Pipelines
  18. vmImage: ubuntu-latest
  19. steps:
  20. - task: CmdLine@2
  21. displayName: Disable dev flag
  22. inputs:
  23. script: |
  24. sudo apt-get install jq -y
  25. mv package.json pkg-temp.json
  26. jq -r '.dev |= false' pkg-temp.json > package.json
  27. rm pkg-temp.json
  28. workingDirectory: '$(Build.SourcesDirectory)'
  29. - task: CmdLine@2
  30. displayName: Set Package Version
  31. inputs:
  32. script: |
  33. mv package.json pkg-temp.json
  34. jq -r '.version |= "$(Build.BuildNumber)"' pkg-temp.json > package.json
  35. rm pkg-temp.json
  36. cat package.json
  37. workingDirectory: '$(Build.SourcesDirectory)'
  38. - task: Docker@2
  39. displayName: Build Docker image
  40. inputs:
  41. containerRegistry: Docker Hub
  42. repository: requarks/wiki
  43. Dockerfile: dev/build/Dockerfile
  44. buildContext: '$(System.DefaultWorkingDirectory)'
  45. tags: |
  46. canary
  47. canary-$(Build.BuildNumber)
  48. addPipelineData: false
  49. - task: CmdLine@2
  50. displayName: Extract compiled files
  51. inputs:
  52. script: |
  53. docker create --name wiki requarks/wiki:canary
  54. docker cp wiki:/wiki $(Build.StagingDirectory)
  55. docker rm wiki
  56. rm $(Build.StagingDirectory)/wiki/config.yml
  57. cp $(System.DefaultWorkingDirectory)/config.sample.yml $(Build.StagingDirectory)/wiki/config.sample.yml
  58. find $(Build.StagingDirectory)/wiki/ -printf "%P\n" | tar -czf wiki-js.tar.gz --no-recursion -C $(Build.StagingDirectory)/wiki/ -T -
  59. workingDirectory: '$(Build.SourcesDirectory)'
  60. - task: PublishBuildArtifacts@1
  61. displayName: Publish Build Artifacts
  62. inputs:
  63. PathtoPublish: 'wiki-js.tar.gz'
  64. ArtifactName: 'drop'
  65. # -------------------------------
  66. # TESTS - CYPRESS E2E TESTS
  67. # -------------------------------
  68. - job: testCypress
  69. displayName: Cypress E2E Tests
  70. dependsOn: buildLinux
  71. strategy:
  72. maxParallel: 5
  73. matrix:
  74. MariaDB:
  75. MATRIXENV: mariadb
  76. MySQL:
  77. MATRIXENV: mysql
  78. MSSQLServer:
  79. MATRIXENV: mssql
  80. PostgreSQL:
  81. MATRIXENV: postgres
  82. SQLite:
  83. MATRIXENV: sqlite
  84. timeoutInMinutes: 30
  85. cancelTimeoutInMinutes: 1
  86. pool:
  87. name: Azure Pipelines
  88. vmImage: ubuntu-latest
  89. steps:
  90. - task: Bash@3
  91. displayName: Setup Environment
  92. inputs:
  93. targetType: filePath
  94. filePath: './dev/cypress/ci-setup.sh'
  95. workingDirectory: '$(Build.SourcesDirectory)'
  96. - script: |
  97. docker run --name cypress --ipc=host --shm-size 1G -v $BUILD_SOURCESDIRECTORY:/e2e -w /e2e cypress/included:4.9.0 --record --key "$(CYPRESS_KEY)" --headless --group "$MATRIXENV" --ci-build-id "$BUILD_BUILDNUMBER" --config baseUrl=http://172.17.0.1:3000
  98. displayName: 'Run Tests'
  99. # -------------------------------
  100. # BUILD - WINDOWS
  101. # -------------------------------
  102. - job: buildWindows
  103. displayName: Windows Build
  104. dependsOn: buildLinux
  105. pool:
  106. name: Azure Pipelines
  107. vmImage: windows-latest
  108. timeoutInMinutes: 30
  109. cancelTimeoutInMinutes: 1
  110. steps:
  111. - task: NodeTool@0
  112. displayName: 'Use Node 14.x'
  113. inputs:
  114. versionSpec: 14.x
  115. - task: 'geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@3'
  116. displayName: 'Use Yarn 1.x'
  117. - task: DownloadBuildArtifacts@0
  118. displayName: 'Download Build Artifacts'
  119. inputs:
  120. artifactName: drop
  121. - script: |
  122. mkdir -p $(Build.SourcesDirectory)\win
  123. tar -xzf $(System.ArtifactsDirectory)\drop\wiki-js.tar.gz -C $(Build.SourcesDirectory)\win --exclude=node_modules
  124. displayName: 'Extract build'
  125. - script: 'yarn --production --frozen-lockfile --non-interactive'
  126. workingDirectory: win
  127. displayName: 'Install dependencies'
  128. - task: ArchiveFiles@2
  129. displayName: 'Archive app'
  130. inputs:
  131. rootFolderOrFile: '$(System.DefaultWorkingDirectory)\win'
  132. includeRootFolder: false
  133. archiveType: tar
  134. archiveFile: 'wiki-js-windows.tar.gz'
  135. - task: PublishBuildArtifacts@1
  136. displayName: Publish Build Artifacts
  137. inputs:
  138. PathtoPublish: 'wiki-js-windows.tar.gz'
  139. ArtifactName: 'drop-win'