mirror of
https://github.com/gonum/gonum.git
synced 2025-10-09 00:50:16 +08:00
github: add CI action
This commit is contained in:
83
.github/workflows/ci.yml
vendored
Normal file
83
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version: [1.15.x, 1.14.x]
|
||||||
|
platform: [ubuntu-latest, macos-latest]
|
||||||
|
env:
|
||||||
|
- TAGS=""
|
||||||
|
- TAGS="-tags bounds"
|
||||||
|
- TAGS="-tags noasm"
|
||||||
|
- TAGS="-tags safe"
|
||||||
|
- FORCE_GOARCH=386
|
||||||
|
exclude:
|
||||||
|
- platform: macos-latest
|
||||||
|
env: TAGS="-tags bounds"
|
||||||
|
- platform: macos-latest
|
||||||
|
env: TAGS="-tags noasm"
|
||||||
|
- platform: macos-latest
|
||||||
|
env: TAGS="-tags safe"
|
||||||
|
- platform: macos-latest
|
||||||
|
env: FORCE_GOARCH=386
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
env:
|
||||||
|
GO111MODULE: on
|
||||||
|
GOPATH: ${{ github.workspace }}
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: ${{ env.GOPATH }}/src/gonum.org/v1/gonum
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go-version }}
|
||||||
|
|
||||||
|
- name: Cache-Go
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod # Module download cache
|
||||||
|
~/.cache/go-build # Build cache (Linux)
|
||||||
|
~/Library/Caches/go-build # Build cache (Mac)
|
||||||
|
'%LocalAppData%\go-build' # Build cache (Windows)
|
||||||
|
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.GOPATH }}/src/gonum.org/v1/gonum
|
||||||
|
|
||||||
|
- name: Check copyrights+imports+formatting+generate
|
||||||
|
if: matrix.platform == 'ubuntu-latest' && matrix.tags == ''
|
||||||
|
run: |
|
||||||
|
./.travis/script.d/deps.sh
|
||||||
|
./.travis/script.d/check-copyright.sh
|
||||||
|
./.travis/script.d/check-imports.sh
|
||||||
|
./.travis/script.d/check-formatting.sh
|
||||||
|
./.travis/script.d/check-generate.sh
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
./.travis/script.d/test.sh
|
||||||
|
|
||||||
|
- name: Coverage
|
||||||
|
if: matrix.platform == 'ubuntu-latest'
|
||||||
|
run: |
|
||||||
|
./.github/workflows/test-coverage.sh
|
||||||
|
|
||||||
|
- name: Upload-Coverage
|
||||||
|
if: matrix.platform == 'ubuntu-latest'
|
||||||
|
uses: codecov/codecov-action@v1
|
32
.github/workflows/test-coverage.sh
vendored
Executable file
32
.github/workflows/test-coverage.sh
vendored
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MODE=set
|
||||||
|
PROFILE_OUT="${PWD}/profile.out"
|
||||||
|
ACC_OUT="${PWD}/coverage.txt"
|
||||||
|
|
||||||
|
testCover() {
|
||||||
|
# set the return value to 0 (successful)
|
||||||
|
retval=0
|
||||||
|
# get the directory to check from the parameter. Default to '.'
|
||||||
|
d=${1:-.}
|
||||||
|
# skip if there are no Go files here
|
||||||
|
ls $d/*.go &> /dev/null || return $retval
|
||||||
|
# switch to the directory to check
|
||||||
|
pushd $d > /dev/null
|
||||||
|
# create the coverage profile
|
||||||
|
coverageresult=$(go test $TAGS -coverprofile="${PROFILE_OUT}" -covermode=${MODE})
|
||||||
|
# output the result so we can check the shell output
|
||||||
|
echo ${coverageresult}
|
||||||
|
# append the results to acc.out if coverage didn't fail, else set the retval to 1 (failed)
|
||||||
|
( [[ ${coverageresult} == *FAIL* ]] && retval=1 ) || ( [ -f "${PROFILE_OUT}" ] && grep -v "mode: ${MODE}" "${PROFILE_OUT}" >> "${ACC_OUT}" )
|
||||||
|
# return to our working dir
|
||||||
|
popd > /dev/null
|
||||||
|
# return our return value
|
||||||
|
return $retval
|
||||||
|
}
|
||||||
|
|
||||||
|
# Init coverage.txt
|
||||||
|
echo "mode: ${MODE}" > $ACC_OUT
|
||||||
|
|
||||||
|
# Run test coverage on all directories containing go files except testlapack, testblas, testgraph and testrand.
|
||||||
|
find . -type d -not -path '*testlapack*' -and -not -path '*testblas*' -and -not -path '*testgraph*' -and -not -path '*testrand*' | while read d; do testCover $d || exit; done
|
@@ -15,3 +15,6 @@ if [ -n "$(git diff)" ]; then
|
|||||||
git diff
|
git diff
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rm -rf *
|
||||||
|
git reset --hard
|
||||||
|
Reference in New Issue
Block a user