Add golangci-lint and fix lint issues; add ci for macOS and windows #177
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 --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 | |
- run: echo "PATH=$env:PATH;$env:RUNNER_TEMP\tongsuo\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
- name: Test on Windows | |
shell: cmd | |
run: | | |
echo %PATH% | |
set CGO_CFLAGS=-Wall -I%RUNNER_TEMP%\tongsuo\include -Wno-deprecated-declarations | |
set CGO_LDFLAGS=-L%RUNNER_TEMP%\tongsuo\lib | |
go test ./... |