Skip to content

Add golangci-lint and fix lint issues; add ci for macOS and windows #190

Add golangci-lint and fix lint issues; add ci for macOS and windows

Add golangci-lint and fix lint issues; add ci for macOS and windows #190

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: CI
on: [push, pull_request]
jobs:
golang-lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Go fmt Check
uses: Jerome1337/[email protected]
with:
gofmt-path: './'
gofmt-flags: '-l -d'
- name: Go Mod
run: go mod tidy
- name: Clone Tongsuo
uses: actions/checkout@v3
with:
repository: Tongsuo-Project/Tongsuo
path: Tongsuo
ref: 8.3-stable
- name: Build Tongsuo
run: |
cd Tongsuo
./config --prefix=${RUNNER_TEMP}/tongsuo --libdir=${RUNNER_TEMP}/tongsuo/lib enable-ntls
make -j4
make install
- name: Golang lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin v1.61.0
LD_LIBRARY_PATH=${RUNNER_TEMP}/tongsuo/lib CGO_CFLAGS="-Wall -I${RUNNER_TEMP}/tongsuo/include -Wno-deprecated-declarations" CGO_LDFLAGS="-L${RUNNER_TEMP}/tongsuo/lib" golangci-lint run ./...
build-and-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Clone Tongsuo
uses: actions/checkout@v3
with:
repository: Tongsuo-Project/Tongsuo
path: Tongsuo
ref: 8.3-stable
- name: Build Tongsuo
run: |
cd Tongsuo
./config --prefix=${RUNNER_TEMP}/tongsuo --libdir=${RUNNER_TEMP}/tongsuo/lib enable-ntls
make -j4
make install
- name: Build
run: CGO_CFLAGS="-Wall -I${RUNNER_TEMP}/tongsuo/include -Wno-deprecated-declarations" CGO_LDFLAGS="-L${RUNNER_TEMP}/tongsuo/lib" go build
- name: Test on Ubuntu
run: LD_LIBRARY_PATH=${RUNNER_TEMP}/tongsuo/lib CGO_CFLAGS="-Wall -I${RUNNER_TEMP}/tongsuo/include -Wno-deprecated-declarations" CGO_LDFLAGS="-L${RUNNER_TEMP}/tongsuo/lib" go test ./...
if: matrix.os == 'ubuntu-latest'
- name: Test on macOS
run: DYLD_LIBRARY_PATH=${RUNNER_TEMP}/tongsuo/lib CGO_CFLAGS="-Wall -I${RUNNER_TEMP}/tongsuo/include -Wno-deprecated-declarations" CGO_LDFLAGS="-L${RUNNER_TEMP}/tongsuo/lib" go test ./...
if: matrix.os == 'macos-latest'
build-static:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Clone Tongsuo
uses: actions/checkout@v3
with:
repository: Tongsuo-Project/Tongsuo
path: tongsuo
ref: 8.3-stable
- name: Build Tongsuo Static
run: |
cd tongsuo
./config --prefix=${RUNNER_TEMP}/tongsuo --libdir=${RUNNER_TEMP}/tongsuo/lib enable-ntls no-shared
make -j4
make install
- name: Build
run: CGO_CFLAGS="-Wall -I${RUNNER_TEMP}/tongsuo/include -Wno-deprecated-declarations" CGO_LDFLAGS="-L${RUNNER_TEMP}/tongsuo/lib" go build
- name: Test on Ubuntu
run: LD_LIBRARY_PATH=${RUNNER_TEMP}/tongsuo/lib CGO_CFLAGS="-Wall -I${RUNNER_TEMP}/tongsuo/include -Wno-deprecated-declarations" CGO_LDFLAGS="-L${RUNNER_TEMP}/tongsuo/lib" go test ./...
if: matrix.os == 'ubuntu-latest'
- name: Test on macOS
run: DYLD_LIBRARY_PATH=${RUNNER_TEMP}/tongsuo/lib CGO_CFLAGS="-Wall -I${RUNNER_TEMP}/tongsuo/include -Wno-deprecated-declarations" CGO_LDFLAGS="-L${RUNNER_TEMP}/tongsuo/lib" go test ./...
if: matrix.os == 'macos-latest'
build-on-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Clone Tongsuo
uses: actions/checkout@v3
with:
repository: Tongsuo-Project/Tongsuo
path: Tongsuo
ref: 8.3-stable
- uses: ilammy/msvc-dev-cmd@v1
- uses: ilammy/setup-nasm@v1
- uses: shogo82148/actions-setup-perl@v1
- name: Build Tongsuo
shell: cmd
run: |
mkdir _build
cd _build
perl ..\Configure VC-WIN64A no-makedepend --prefix=%RUNNER_TEMP%\tongsuo enable-ntls
nmake /S
nmake install
working-directory: Tongsuo
- name: Build
shell: cmd
run: |
set CGO_CFLAGS=-Wall -I%RUNNER_TEMP%\tongsuo\include -Wno-deprecated-declarations
set CGO_LDFLAGS=-L%RUNNER_TEMP%\tongsuo\lib"
go build
- name: debug
shell: cmd
run: |
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\VCPackages"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin\Roslyn"
dir "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\"
dir "C:\Program Files (x86)\HTML Help Workshop"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\DiagnosticsHub\Collector"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\CodeCoverage.Console"
dir "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\\x64"
dir "C:\Program Files (x86)\Windows Kits\10\bin\\x64"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\\MSBuild\Current\Bin\amd64"
dir "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\"
dir "C:\Users\runneradmin\go\bin;C:\hostedtoolcache\windows\go\1.19.13\x64\bin"
dir "C:\Program Files\MongoDB\Server\5.0\bin"
dir "C:\aliyun-cli"
dir "C:\vcpkg"
dir "C:\Program Files (x86)\NSIS\"
dir "C:\tools\zstd"
dir "C:\Program Files\Mercurial\"
dir "C:\hostedtoolcache\windows\stack\3.1.1\x64"
dir "C:\cabal\bin"
dir "C:\\ghcup\bin"
dir "C:\mingw64\bin"
dir "C:\Program Files\dotnet"
dir "C:\Program Files\MySQL\MySQL Server 8.0\bin"
dir "C:\Program Files\R\R-4.4.1\bin\x64"
dir "C:\SeleniumWebDrivers\GeckoDriver"
dir "C:\SeleniumWebDrivers\EdgeDriver\"
dir "C:\SeleniumWebDrivers\ChromeDriver"
dir "C:\Program Files (x86)\sbt\bin"
dir "C:\Program Files (x86)\GitHub CLI"
dir "C:\Program Files\Git\bin"
dir "C:\Program Files (x86)\pipx_bin"
dir "C:\npm\prefix"
dir "C:\hostedtoolcache\windows\go\1.21.13\x64\bin"
dir "C:\hostedtoolcache\windows\Python\3.9.13\x64\Scripts"
dir "C:\hostedtoolcache\windows\Python\3.9.13\x64"
dir "C:\hostedtoolcache\windows\Ruby\3.0.7\x64\bin"
dir "C:\Program Files\OpenSSL\bin"
dir "C:\tools\kotlinc\bin"
dir "C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\8.0.432-6\x64\bin"
dir "C:\Program Files\ImageMagick-7.1.1-Q16-HDRI"
dir "C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin"
dir "C:\ProgramData\kind"
dir "C:\ProgramData\Chocolatey\bin"
dir "C:\Windows\system32"
dir "C:\Windows"
dir "C:\Windows\System32\Wbem"
dir "C:\Windows\System32\WindowsPowerShell\v1.0\"
dir "C:\Windows\System32\OpenSSH\"
dir "C:\Program Files\dotnet\"
dir "C:\Program Files\PowerShell\7\"
dir "C:\Program Files\Microsoft\Web Platform Installer\"
dir "C:\Program Files\TortoiseSVN\bin"
dir "C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\"
dir "C:\Program Files\Microsoft SQL Server\150\Tools\Binn\"
dir "C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\"
dir "C:\Program Files (x86)\WiX Toolset v3.14\bin"
dir "C:\Program Files\Microsoft SQL Server\130\DTS\Binn\"
dir "C:\Program Files\Microsoft SQL Server\140\DTS\Binn\"
dir "C:\Program Files\Microsoft SQL Server\150\DTS\Binn\"
dir "C:\Program Files\Microsoft SQL Server\160\DTS\Binn\"
dir "C:\Strawberry\c\bin"
dir "C:\Strawberry\perl\site\bin"
dir "C:\Strawberry\perl\bin"
dir "C:\ProgramData\chocolatey\lib\pulumi\tools\Pulumi\bin"
dir "C:\Program Files\CMake\bin"
dir "C:\ProgramData\chocolatey\lib\maven\apache-maven-3.8.7\bin"
dir "C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code"
dir "C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager"
dir "C:\Program Files\nodejs\"
dir "C:\Program Files\Git\cmd"
dir "C:\Program Files\Git\mingw64\bin"
dir "C:\Program Files\Git\usr\bin"
dir "C:\Program Files\GitHub CLI\"
dir "c:\tools\php"
dir "C:\Program Files\Amazon\AWSCLIV2\"
dir "C:\Program Files\Amazon\SessionManagerPlugin\bin\"
dir "C:\Program Files\Amazon\AWSSAMCLI\bin\"
dir "C:\Program Files\Microsoft SQL Server\130\Tools\Binn\"
dir "C:\Program Files\LLVM\bin"
dir "C:\Users\runneradmin\.dotnet\tools"
dir "C:\Users\runneradmin\.cargo\bin"
dir "C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps"
dir "C:\Program Files (x86)\Microsoft Visual Studio\Installer"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\x64\bin"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\Linux\bin\ConnectionManagerExe"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\vcpkg"
- name: Set PATH for go test runtime library search
shell: perl {0}
run: |
use Actions::Core;
add_path("$ENV{RUNNER_TEMP}\\tongsuo\\bin");
add_path("$ENV{RUNNER_TEMP}\\tongsuo\\lib");
- name: Test on Windows
shell: cmd
run: |
set CGO_CFLAGS=-Wall -I%RUNNER_TEMP%\tongsuo\include -Wno-deprecated-declarations
set CGO_LDFLAGS=-L%RUNNER_TEMP%\tongsuo\lib
go env
echo %PATH%
go test ./...