workflow: execute test cases on MySQL too

This commit is contained in:
Nicola Murino
2020-06-22 20:02:51 +02:00
parent 0056984d4b
commit ddf99ab706
3 changed files with 56 additions and 22 deletions

View File

@@ -17,7 +17,7 @@ jobs:
version: v1.27 version: v1.27
tests-upload-unix: tests-upload-unix:
name: Run tests and upload build artifacts on Linux and macOS name: Run tests and upload build artifacts
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
@@ -118,16 +118,9 @@ jobs:
name: sftpgo-windows name: sftpgo-windows
path: output path: output
tests-postgresql: tests-postgresql-mysql:
name: Run test cases using PostgreSQL as data provider name: Run test cases using PostgreSQL/MySQL data providers
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
SFTPGO_DATA_PROVIDER__DRIVER: postgresql
SFTPGO_DATA_PROVIDER__NAME: sftpgo
SFTPGO_DATA_PROVIDER__HOST: localhost
SFTPGO_DATA_PROVIDER__PORT: 5432
SFTPGO_DATA_PROVIDER__USERNAME: postgres
SFTPGO_DATA_PROVIDER__PASSWORD: postgres
services: services:
postgres: postgres:
@@ -143,6 +136,21 @@ jobs:
ports: ports:
- 5432:5432 - 5432:5432
mariadb:
image: mariadb:latest
env:
MYSQL_ROOT_PASSWORD: mysql
MYSQL_DATABASE: sftpgo
MYSQL_USER: sftpgo
MYSQL_PASSWORD: sftpgo
options: >-
--health-cmd "mysqladmin status -h 127.0.0.1 -P 3306 -u root -p$MYSQL_ROOT_PASSWORD"
--health-interval 10s
--health-timeout 5s
--health-retries 6
ports:
- 3307:3306
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@@ -154,8 +162,26 @@ jobs:
- name: Build - name: Build
run: go build -i -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 run: go build -i -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
- name: Initialize data provider
run: ./sftpgo initprovider
- name: Run tests using PostgreSQL provider - name: Run tests using PostgreSQL provider
run: go test -v ./... -covermode=atomic run: |
./sftpgo initprovider
go test -v ./... -covermode=atomic
env:
SFTPGO_DATA_PROVIDER__DRIVER: postgresql
SFTPGO_DATA_PROVIDER__NAME: sftpgo
SFTPGO_DATA_PROVIDER__HOST: localhost
SFTPGO_DATA_PROVIDER__PORT: 5432
SFTPGO_DATA_PROVIDER__USERNAME: postgres
SFTPGO_DATA_PROVIDER__PASSWORD: postgres
- name: Run tests using MySQL provider
run: |
./sftpgo initprovider
go test -v ./... -covermode=atomic
env:
SFTPGO_DATA_PROVIDER__DRIVER: mysql
SFTPGO_DATA_PROVIDER__NAME: sftpgo
SFTPGO_DATA_PROVIDER__HOST: localhost
SFTPGO_DATA_PROVIDER__PORT: 3307
SFTPGO_DATA_PROVIDER__USERNAME: sftpgo
SFTPGO_DATA_PROVIDER__PASSWORD: sftpgo

View File

@@ -62,7 +62,7 @@ Some Linux distro packages are available:
- [sftpgo-bin](https://aur.archlinux.org/packages/sftpgo-bin/). This package follows stable releases downloading the prebuilt linux binary from GitHub. It does not require `git`, `gcc` and `go` to build. - [sftpgo-bin](https://aur.archlinux.org/packages/sftpgo-bin/). This package follows stable releases downloading the prebuilt linux binary from GitHub. It does not require `git`, `gcc` and `go` to build.
- [sftpgo-git](https://aur.archlinux.org/packages/sftpgo-git/). This package builds and installs the latest git master. It requires `git`, `gcc` and `go` to build. - [sftpgo-git](https://aur.archlinux.org/packages/sftpgo-git/). This package builds and installs the latest git master. It requires `git`, `gcc` and `go` to build.
You can easily test new features selecting a commit from the [Actions](./actions) page and downloading the matching build artifacts for Linux, macOS or Windows. GitHub stores artifacts for 90 days. You can easily test new features selecting a commit from the [Actions](https://github.com/drakkan/sftpgo/actions) page and downloading the matching build artifacts for Linux, macOS or Windows. GitHub stores artifacts for 90 days.
Alternately, you can [build from source](./docs/build-from-source.md). Alternately, you can [build from source](./docs/build-from-source.md).

View File

@@ -1091,6 +1091,16 @@ func TestStartQuotaScan(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
_, err = httpd.StartFolderQuotaScan(folder, http.StatusCreated) _, err = httpd.StartFolderQuotaScan(folder, http.StatusCreated)
assert.NoError(t, err) assert.NoError(t, err)
for {
quotaScan, _, err := httpd.GetFoldersQuotaScans(http.StatusOK)
if !assert.NoError(t, err, "Error getting active scans") {
break
}
if len(quotaScan) == 0 {
break
}
time.Sleep(100 * time.Millisecond)
}
_, err = httpd.RemoveFolder(folder, http.StatusOK) _, err = httpd.RemoveFolder(folder, http.StatusOK)
assert.NoError(t, err) assert.NoError(t, err)
} }
@@ -1875,14 +1885,13 @@ func TestStartQuotaScanMock(t *testing.T) {
rr = executeRequest(req) rr = executeRequest(req)
checkResponseCode(t, http.StatusCreated, rr.Code) checkResponseCode(t, http.StatusCreated, rr.Code)
var scans []sftpd.ActiveQuotaScan
for { for {
var scans []sftpd.ActiveQuotaScan
req, _ = http.NewRequest(http.MethodGet, quotaScanPath, nil) req, _ = http.NewRequest(http.MethodGet, quotaScanPath, nil)
rr = executeRequest(req) rr = executeRequest(req)
checkResponseCode(t, http.StatusOK, rr.Code) checkResponseCode(t, http.StatusOK, rr.Code)
err = render.DecodeJSON(rr.Body, &scans) err = render.DecodeJSON(rr.Body, &scans)
if !assert.NoError(t, err) { if !assert.NoError(t, err, "Error getting active scans") {
assert.Fail(t, err.Error(), "Error get active scans")
break break
} }
if len(scans) == 0 { if len(scans) == 0 {
@@ -1899,14 +1908,14 @@ func TestStartQuotaScanMock(t *testing.T) {
rr = executeRequest(req) rr = executeRequest(req)
checkResponseCode(t, http.StatusCreated, rr.Code) checkResponseCode(t, http.StatusCreated, rr.Code)
scans = nil
for { for {
var scans []sftpd.ActiveQuotaScan
req, _ = http.NewRequest(http.MethodGet, quotaScanPath, nil) req, _ = http.NewRequest(http.MethodGet, quotaScanPath, nil)
rr = executeRequest(req) rr = executeRequest(req)
checkResponseCode(t, http.StatusOK, rr.Code) checkResponseCode(t, http.StatusOK, rr.Code)
err = render.DecodeJSON(rr.Body, &scans) err = render.DecodeJSON(rr.Body, &scans)
if !assert.NoError(t, err) { if !assert.NoError(t, err) {
assert.Fail(t, err.Error(), "Error get active scans") assert.Fail(t, err.Error(), "Error getting active scans")
break break
} }
if len(scans) == 0 { if len(scans) == 0 {
@@ -2017,8 +2026,7 @@ func TestStartFolderQuotaScanMock(t *testing.T) {
rr = executeRequest(req) rr = executeRequest(req)
checkResponseCode(t, http.StatusOK, rr.Code) checkResponseCode(t, http.StatusOK, rr.Code)
err = render.DecodeJSON(rr.Body, &scans) err = render.DecodeJSON(rr.Body, &scans)
if !assert.NoError(t, err) { if !assert.NoError(t, err, "Error getting active folders scans") {
assert.Fail(t, err.Error(), "Error get active folders scans")
break break
} }
if len(scans) == 0 { if len(scans) == 0 {