development.yml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. name: CI
  2. on:
  3. push:
  4. branches: [master]
  5. pull_request:
  6. jobs:
  7. test-deploy:
  8. name: Test and deploy
  9. runs-on: ${{ matrix.os }}
  10. strategy:
  11. matrix:
  12. go: [1.15]
  13. os: [ubuntu-latest, macos-latest]
  14. upload-coverage: [true]
  15. include:
  16. - go: 1.13
  17. os: ubuntu-latest
  18. upload-coverage: false
  19. - go: 1.14
  20. os: ubuntu-latest
  21. upload-coverage: false
  22. - go: 1.15
  23. os: windows-latest
  24. upload-coverage: false
  25. steps:
  26. - uses: actions/checkout@v2
  27. - name: Set up Go
  28. uses: actions/setup-go@v2
  29. with:
  30. go-version: ${{ matrix.go }}
  31. - name: Build for Linux/macOS
  32. if: startsWith(matrix.os, 'windows-') != true
  33. run: go build -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo
  34. - name: Build for Windows
  35. if: startsWith(matrix.os, 'windows-')
  36. run: |
  37. $GIT_COMMIT = (git describe --always --dirty) | Out-String
  38. $DATE_TIME = ([datetime]::Now.ToUniversalTime().toString("yyyy-MM-ddTHH:mm:ssZ")) | Out-String
  39. go build -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/version.date=$DATE_TIME" -o sftpgo.exe
  40. - name: Initialize data provider
  41. run: ./sftpgo initprovider
  42. shell: bash
  43. - name: Run test cases using SQLite provider
  44. run: go test -v -p 1 -timeout 5m ./... -coverprofile=coverage.txt -covermode=atomic
  45. - name: Upload coverage to Codecov
  46. if: ${{ matrix.upload-coverage }}
  47. uses: codecov/codecov-action@v1
  48. with:
  49. file: ./coverage.txt
  50. fail_ci_if_error: false
  51. - name: Run test cases using bolt provider
  52. run: |
  53. go test -v -p 1 -timeout 1m ./config -covermode=atomic
  54. go test -v -p 1 -timeout 1m ./common -covermode=atomic
  55. go test -v -p 1 -timeout 2m ./httpd -covermode=atomic
  56. go test -v -p 1 -timeout 5m ./sftpd -covermode=atomic
  57. go test -v -p 1 -timeout 2m ./ftpd -covermode=atomic
  58. go test -v -p 1 -timeout 2m ./webdavd -covermode=atomic
  59. env:
  60. SFTPGO_DATA_PROVIDER__DRIVER: bolt
  61. SFTPGO_DATA_PROVIDER__NAME: 'sftpgo_bolt.db'
  62. - name: Run test cases using memory provider
  63. run: go test -v -p 1 -timeout 5m ./... -covermode=atomic
  64. env:
  65. SFTPGO_DATA_PROVIDER__DRIVER: memory
  66. SFTPGO_DATA_PROVIDER__NAME: ''
  67. - name: Prepare build artifact for Linux/macOS
  68. if: startsWith(matrix.os, 'windows-') != true
  69. run: |
  70. mkdir -p output/{bash_completion,zsh_completion}
  71. cp sftpgo output/
  72. cp sftpgo.json output/
  73. cp -r templates output/
  74. cp -r static output/
  75. ./sftpgo gen completion bash > output/bash_completion/sftpgo-completion.bash
  76. ./sftpgo gen completion zsh > output/zsh_completion/_sftpgo
  77. ./sftpgo gen man -d output/man/man1
  78. gzip output/man/man1/*
  79. - name: Prepare build artifact for Windows
  80. if: startsWith(matrix.os, 'windows-')
  81. run: |
  82. mkdir output
  83. copy .\sftpgo.exe .\output
  84. copy .\sftpgo.json .\output
  85. mkdir output\templates
  86. xcopy .\templates .\output\templates\ /E
  87. mkdir output\static
  88. xcopy .\static .\output\static\ /E
  89. - name: Upload build artifact
  90. uses: actions/upload-artifact@v2
  91. with:
  92. name: sftpgo-${{ matrix.os }}-go${{ matrix.go }}
  93. path: output
  94. test-postgresql-mysql:
  95. name: Test with PostgreSQL/MySQL
  96. runs-on: ubuntu-latest
  97. services:
  98. postgres:
  99. image: postgres:latest
  100. env:
  101. POSTGRES_PASSWORD: postgres
  102. POSTGRES_DB: sftpgo
  103. options: >-
  104. --health-cmd pg_isready
  105. --health-interval 10s
  106. --health-timeout 5s
  107. --health-retries 5
  108. ports:
  109. - 5432:5432
  110. mariadb:
  111. image: mariadb:latest
  112. env:
  113. MYSQL_ROOT_PASSWORD: mysql
  114. MYSQL_DATABASE: sftpgo
  115. MYSQL_USER: sftpgo
  116. MYSQL_PASSWORD: sftpgo
  117. options: >-
  118. --health-cmd "mysqladmin status -h 127.0.0.1 -P 3306 -u root -p$MYSQL_ROOT_PASSWORD"
  119. --health-interval 10s
  120. --health-timeout 5s
  121. --health-retries 6
  122. ports:
  123. - 3307:3306
  124. steps:
  125. - uses: actions/checkout@v2
  126. - name: Set up Go
  127. uses: actions/setup-go@v2
  128. with:
  129. go-version: 1.15
  130. - name: Build
  131. run: go build -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo
  132. - name: Run tests using PostgreSQL provider
  133. run: |
  134. ./sftpgo initprovider
  135. go test -v -p 1 -timeout 5m ./... -covermode=atomic
  136. env:
  137. SFTPGO_DATA_PROVIDER__DRIVER: postgresql
  138. SFTPGO_DATA_PROVIDER__NAME: sftpgo
  139. SFTPGO_DATA_PROVIDER__HOST: localhost
  140. SFTPGO_DATA_PROVIDER__PORT: 5432
  141. SFTPGO_DATA_PROVIDER__USERNAME: postgres
  142. SFTPGO_DATA_PROVIDER__PASSWORD: postgres
  143. - name: Run tests using MySQL provider
  144. run: |
  145. ./sftpgo initprovider
  146. go test -v -p 1 -timeout 5m ./... -covermode=atomic
  147. env:
  148. SFTPGO_DATA_PROVIDER__DRIVER: mysql
  149. SFTPGO_DATA_PROVIDER__NAME: sftpgo
  150. SFTPGO_DATA_PROVIDER__HOST: localhost
  151. SFTPGO_DATA_PROVIDER__PORT: 3307
  152. SFTPGO_DATA_PROVIDER__USERNAME: sftpgo
  153. SFTPGO_DATA_PROVIDER__PASSWORD: sftpgo
  154. golangci-lint:
  155. name: golangci-lint
  156. runs-on: ubuntu-latest
  157. steps:
  158. - uses: actions/checkout@v2
  159. - name: Run golangci-lint
  160. uses: golangci/golangci-lint-action@v1
  161. with:
  162. version: v1.30