2020-06-28 19:01:03 +00:00
|
|
|
name: CI
|
2020-06-20 19:57:51 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2021-02-18 07:50:42 +00:00
|
|
|
branches: [2.0.x]
|
2020-06-20 19:57:51 +00:00
|
|
|
pull_request:
|
|
|
|
|
2020-06-28 13:57:33 +00:00
|
|
|
jobs:
|
2020-06-29 09:15:24 +00:00
|
|
|
test-deploy:
|
|
|
|
name: Test and deploy
|
2020-06-20 19:57:51 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-03-07 10:57:14 +00:00
|
|
|
go: [1.16]
|
2021-02-21 11:13:22 +00:00
|
|
|
os: [ubuntu-18.04, macos-10.15, windows-2019]
|
|
|
|
upload-coverage: [false]
|
2020-06-20 19:57:51 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2020-09-26 12:07:24 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2020-06-20 19:57:51 +00:00
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Set up Go
|
2020-06-20 19:57:51 +00:00
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: ${{ matrix.go }}
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Build for Linux/macOS
|
2020-06-28 13:57:33 +00:00
|
|
|
if: startsWith(matrix.os, 'windows-') != true
|
2020-07-11 11:03:15 +00:00
|
|
|
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
|
2020-06-20 19:57:51 +00:00
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Build for Windows
|
2020-06-28 13:57:33 +00:00
|
|
|
if: startsWith(matrix.os, 'windows-')
|
|
|
|
run: |
|
|
|
|
$GIT_COMMIT = (git describe --always --dirty) | Out-String
|
|
|
|
$DATE_TIME = ([datetime]::Now.ToUniversalTime().toString("yyyy-MM-ddTHH:mm:ssZ")) | Out-String
|
2020-07-11 11:03:15 +00:00
|
|
|
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
|
2020-06-28 13:57:33 +00:00
|
|
|
|
2020-06-22 21:47:07 +00:00
|
|
|
- name: Run test cases using SQLite provider
|
2020-08-22 08:12:00 +00:00
|
|
|
run: go test -v -p 1 -timeout 10m ./... -coverprofile=coverage.txt -covermode=atomic
|
2020-06-20 19:57:51 +00:00
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Upload coverage to Codecov
|
2020-06-29 18:07:51 +00:00
|
|
|
if: ${{ matrix.upload-coverage }}
|
2020-06-20 19:57:51 +00:00
|
|
|
uses: codecov/codecov-action@v1
|
|
|
|
with:
|
|
|
|
file: ./coverage.txt
|
2020-06-22 21:47:07 +00:00
|
|
|
fail_ci_if_error: false
|
2020-06-20 19:57:51 +00:00
|
|
|
|
2020-06-22 21:47:07 +00:00
|
|
|
- name: Run test cases using bolt provider
|
2020-06-20 21:49:27 +00:00
|
|
|
run: |
|
2020-08-22 08:12:00 +00:00
|
|
|
go test -v -p 1 -timeout 2m ./config -covermode=atomic
|
|
|
|
go test -v -p 1 -timeout 2m ./common -covermode=atomic
|
|
|
|
go test -v -p 1 -timeout 3m ./httpd -covermode=atomic
|
|
|
|
go test -v -p 1 -timeout 8m ./sftpd -covermode=atomic
|
2020-08-11 21:56:10 +00:00
|
|
|
go test -v -p 1 -timeout 2m ./ftpd -covermode=atomic
|
|
|
|
go test -v -p 1 -timeout 2m ./webdavd -covermode=atomic
|
2020-12-18 15:04:42 +00:00
|
|
|
go test -v -p 1 -timeout 2m ./telemetry -covermode=atomic
|
2020-06-21 19:28:59 +00:00
|
|
|
env:
|
|
|
|
SFTPGO_DATA_PROVIDER__DRIVER: bolt
|
2020-06-22 21:47:07 +00:00
|
|
|
SFTPGO_DATA_PROVIDER__NAME: 'sftpgo_bolt.db'
|
2020-06-20 21:49:27 +00:00
|
|
|
|
2020-06-22 21:47:07 +00:00
|
|
|
- name: Run test cases using memory provider
|
2020-08-22 08:12:00 +00:00
|
|
|
run: go test -v -p 1 -timeout 10m ./... -covermode=atomic
|
2020-06-21 19:28:59 +00:00
|
|
|
env:
|
2020-06-28 13:57:33 +00:00
|
|
|
SFTPGO_DATA_PROVIDER__DRIVER: memory
|
|
|
|
SFTPGO_DATA_PROVIDER__NAME: ''
|
2020-06-20 19:57:51 +00:00
|
|
|
|
2020-11-08 05:14:03 +00:00
|
|
|
- name: Gather cross build info
|
|
|
|
id: cross_info
|
|
|
|
if: ${{ matrix.upload-coverage && startsWith(matrix.os, 'ubuntu-') }}
|
|
|
|
run: |
|
|
|
|
GIT_COMMIT=$(git describe --always)
|
|
|
|
BUILD_DATE=$(date -u +%FT%TZ)
|
|
|
|
echo ::set-output name=sha::${GIT_COMMIT}
|
|
|
|
echo ::set-output name=created::${BUILD_DATE}
|
|
|
|
|
|
|
|
- name: Cross build with xgo
|
2021-04-07 13:38:15 +00:00
|
|
|
if: ${{ matrix.upload-coverage && startsWith(matrix.os, 'ubuntu-') }}
|
2020-11-08 05:14:03 +00:00
|
|
|
uses: crazy-max/ghaction-xgo@v1
|
|
|
|
with:
|
2021-03-07 10:57:14 +00:00
|
|
|
go_version: 1.16.x
|
2020-11-08 05:14:03 +00:00
|
|
|
dest: cross
|
|
|
|
prefix: sftpgo
|
2020-11-09 17:39:36 +00:00
|
|
|
targets: linux/arm64,linux/ppc64le
|
2020-11-08 05:14:03 +00:00
|
|
|
v: true
|
|
|
|
x: false
|
|
|
|
race: false
|
|
|
|
ldflags: -s -w -X github.com/drakkan/sftpgo/version.commit=${{ steps.cross_info.outputs.sha }} -X github.com/drakkan/sftpgo/version.date=${{ steps.cross_info.outputs.created }}
|
|
|
|
buildmode: default
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Prepare build artifact for Linux/macOS
|
2020-06-28 13:57:33 +00:00
|
|
|
if: startsWith(matrix.os, 'windows-') != true
|
2020-06-20 19:57:51 +00:00
|
|
|
run: |
|
2020-07-10 21:31:53 +00:00
|
|
|
mkdir -p output/{bash_completion,zsh_completion}
|
2020-06-28 13:57:33 +00:00
|
|
|
cp sftpgo output/
|
|
|
|
cp sftpgo.json output/
|
|
|
|
cp -r templates output/
|
|
|
|
cp -r static output/
|
2020-09-08 07:45:21 +00:00
|
|
|
cp -r init output/
|
2020-10-08 14:02:04 +00:00
|
|
|
./sftpgo gen completion bash > output/bash_completion/sftpgo
|
2020-07-10 21:31:53 +00:00
|
|
|
./sftpgo gen completion zsh > output/zsh_completion/_sftpgo
|
|
|
|
./sftpgo gen man -d output/man/man1
|
|
|
|
gzip output/man/man1/*
|
2020-11-09 17:39:36 +00:00
|
|
|
|
|
|
|
- name: Copy cross compiled Linux binaries
|
|
|
|
if: ${{ matrix.upload-coverage && startsWith(matrix.os, 'ubuntu-') }}
|
|
|
|
run: |
|
|
|
|
cp cross/sftpgo-linux-arm64 output/
|
|
|
|
cp cross/sftpgo-linux-ppc64le output/
|
2020-06-20 19:57:51 +00:00
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Prepare build artifact for Windows
|
2020-06-28 13:57:33 +00:00
|
|
|
if: startsWith(matrix.os, 'windows-')
|
2020-06-20 19:57:51 +00:00
|
|
|
run: |
|
|
|
|
mkdir output
|
2020-06-29 09:15:24 +00:00
|
|
|
copy .\sftpgo.exe .\output
|
|
|
|
copy .\sftpgo.json .\output
|
2020-06-22 21:47:07 +00:00
|
|
|
mkdir output\templates
|
|
|
|
xcopy .\templates .\output\templates\ /E
|
|
|
|
mkdir output\static
|
|
|
|
xcopy .\static .\output\static\ /E
|
2020-06-20 19:57:51 +00:00
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Upload build artifact
|
2020-06-20 19:57:51 +00:00
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
2020-06-28 13:57:33 +00:00
|
|
|
name: sftpgo-${{ matrix.os }}-go${{ matrix.go }}
|
2020-06-20 19:57:51 +00:00
|
|
|
path: output
|
2020-06-21 19:28:59 +00:00
|
|
|
|
2020-09-26 12:07:24 +00:00
|
|
|
- name: Build Linux Packages
|
|
|
|
id: build_linux_pkgs
|
|
|
|
if: ${{ matrix.upload-coverage && startsWith(matrix.os, 'ubuntu-') }}
|
|
|
|
run: |
|
2020-11-08 05:14:03 +00:00
|
|
|
cp -r pkgs pkgs_arm64
|
2020-11-09 17:39:36 +00:00
|
|
|
cp -r pkgs pkgs_ppc64le
|
2020-09-26 12:07:24 +00:00
|
|
|
cd pkgs
|
|
|
|
./build.sh
|
2020-11-08 05:14:03 +00:00
|
|
|
cd ..
|
|
|
|
export NFPM_ARCH=arm64
|
|
|
|
export BIN_SUFFIX=-linux-arm64
|
|
|
|
cp cross/sftpgo${BIN_SUFFIX} .
|
|
|
|
cd pkgs_arm64
|
|
|
|
./build.sh
|
2020-11-09 17:39:36 +00:00
|
|
|
cd ..
|
|
|
|
export NFPM_ARCH=ppc64le
|
|
|
|
export BIN_SUFFIX=-linux-ppc64le
|
|
|
|
cp cross/sftpgo${BIN_SUFFIX} .
|
|
|
|
cd pkgs_ppc64le
|
|
|
|
./build.sh
|
2020-09-26 12:07:24 +00:00
|
|
|
PKG_VERSION=$(cat dist/version)
|
|
|
|
echo "::set-output name=pkg-version::${PKG_VERSION}"
|
|
|
|
|
|
|
|
- name: Upload Debian Package
|
|
|
|
if: ${{ matrix.upload-coverage && startsWith(matrix.os, 'ubuntu-') }}
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: sftpgo-${{ steps.build_linux_pkgs.outputs.pkg-version }}-x86_64-deb
|
|
|
|
path: pkgs/dist/deb/*
|
|
|
|
|
|
|
|
- name: Upload RPM Package
|
|
|
|
if: ${{ matrix.upload-coverage && startsWith(matrix.os, 'ubuntu-') }}
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: sftpgo-${{ steps.build_linux_pkgs.outputs.pkg-version }}-x86_64-rpm
|
|
|
|
path: pkgs/dist/rpm/*
|
|
|
|
|
2020-11-07 18:29:16 +00:00
|
|
|
- name: Upload Debian Package arm64
|
|
|
|
if: ${{ matrix.upload-coverage && startsWith(matrix.os, 'ubuntu-') }}
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: sftpgo-${{ steps.build_linux_pkgs.outputs.pkg-version }}-arm64-deb
|
2020-11-09 17:39:36 +00:00
|
|
|
path: pkgs_arm64/dist/deb/*
|
2020-11-07 18:29:16 +00:00
|
|
|
|
|
|
|
- name: Upload RPM Package arm64
|
|
|
|
if: ${{ matrix.upload-coverage && startsWith(matrix.os, 'ubuntu-') }}
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: sftpgo-${{ steps.build_linux_pkgs.outputs.pkg-version }}-arm64-rpm
|
2020-11-09 17:39:36 +00:00
|
|
|
path: pkgs_arm64/dist/rpm/*
|
|
|
|
|
|
|
|
- name: Upload Debian Package ppc64le
|
|
|
|
if: ${{ matrix.upload-coverage && startsWith(matrix.os, 'ubuntu-') }}
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: sftpgo-${{ steps.build_linux_pkgs.outputs.pkg-version }}-ppc64le-deb
|
|
|
|
path: pkgs_ppc64le/dist/deb/*
|
|
|
|
|
|
|
|
- name: Upload RPM Package ppc64le
|
|
|
|
if: ${{ matrix.upload-coverage && startsWith(matrix.os, 'ubuntu-') }}
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: sftpgo-${{ steps.build_linux_pkgs.outputs.pkg-version }}-ppc64le-rpm
|
|
|
|
path: pkgs_ppc64le/dist/rpm/*
|
2020-11-07 18:29:16 +00:00
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
test-postgresql-mysql:
|
|
|
|
name: Test with PostgreSQL/MySQL
|
2021-02-21 11:09:19 +00:00
|
|
|
runs-on: ubuntu-18.04
|
2020-06-21 19:28:59 +00:00
|
|
|
|
|
|
|
services:
|
|
|
|
postgres:
|
|
|
|
image: postgres:latest
|
|
|
|
env:
|
|
|
|
POSTGRES_PASSWORD: postgres
|
|
|
|
POSTGRES_DB: sftpgo
|
|
|
|
options: >-
|
|
|
|
--health-cmd pg_isready
|
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
|
|
|
ports:
|
|
|
|
- 5432:5432
|
|
|
|
|
2020-06-22 18:02:51 +00:00
|
|
|
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
|
|
|
|
|
2020-06-21 19:28:59 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Set up Go
|
2020-06-21 19:28:59 +00:00
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-03-07 10:57:14 +00:00
|
|
|
go-version: 1.16
|
2020-06-21 19:28:59 +00:00
|
|
|
|
|
|
|
- name: Build
|
2020-07-11 11:03:15 +00:00
|
|
|
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
|
2020-06-21 19:28:59 +00:00
|
|
|
|
|
|
|
- name: Run tests using PostgreSQL provider
|
2020-06-22 18:02:51 +00:00
|
|
|
run: |
|
2020-08-22 08:12:00 +00:00
|
|
|
go test -v -p 1 -timeout 10m ./... -covermode=atomic
|
2020-06-22 18:02:51 +00:00
|
|
|
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: |
|
2020-08-22 08:12:00 +00:00
|
|
|
go test -v -p 1 -timeout 10m ./... -covermode=atomic
|
2020-06-22 18:02:51 +00:00
|
|
|
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
|
2020-06-28 13:57:33 +00:00
|
|
|
|
|
|
|
golangci-lint:
|
|
|
|
name: golangci-lint
|
2021-02-21 11:09:19 +00:00
|
|
|
runs-on: ubuntu-18.04
|
2020-06-28 13:57:33 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Run golangci-lint
|
2020-10-17 20:14:04 +00:00
|
|
|
uses: golangci/golangci-lint-action@v2
|
2020-06-28 13:57:33 +00:00
|
|
|
with:
|
2021-02-21 11:09:19 +00:00
|
|
|
version: v1.37.1
|