Skip to content
Snippets Groups Projects
github-actions.yml 2.08 KiB
Newer Older
Psnail's avatar
Psnail committed
name: CI

on:
  push:
Psnail's avatar
Psnail committed
    branches: [master, develop]
Psnail's avatar
Psnail committed
  pull_request:
    branches: "*"

jobs:

  build:
Psnail's avatar
Psnail committed
    name: ${{ matrix.os }} - Go ${{ matrix.go_version }}
    runs-on: ${{ matrix.os }}
Psnail's avatar
Psnail committed
    strategy:
      # If you want to matrix build , you can append the following list.
Psnail's avatar
Psnail committed
      matrix:
        go_version:
          - 1.13
        os:
          - ubuntu-latest
Psnail's avatar
Psnail committed

AlexStocks's avatar
AlexStocks committed
    env:
      DING_TOKEN: ${{ secrets.DING_TOKEN }}
      DING_SIGN: ${{ secrets.DING_SIGN }}

Psnail's avatar
Psnail committed
    steps:
Psnail's avatar
Psnail committed

    - name: Set up Go 1.x
      uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go_version }}
Psnail's avatar
Psnail committed
      id: go

    - name: Check out code into the Go module directory
      uses: actions/checkout@v2

    - name: Cache dependencies
      uses: actions/cache@v2
      with:
        # Cache
        path: ~/go/pkg/mod
        # Cache key
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        # An ordered list of keys to use for restoring the cache if no cache hit occurred for key
        restore-keys: |
          ${{ runner.os }}-go-

Psnail's avatar
ci  
Psnail committed
    - name: Get dependencies
      run: |
        if [ -f Gopkg.toml ]; then
            curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
            dep ensure
        else
            go get -v -t -d ./...
Psnail's avatar
ci  
Psnail committed
        fi
AlexStocks's avatar
AlexStocks committed

AlexStocks's avatar
AlexStocks committed
    - name: gofmt
      run: |
        go fmt ./... && git checkout -- go.mod && git status && [[ -z `git status -s` ]]
        # diff -u <(echo -n) <(gofmt -d -s .)

AlexStocks's avatar
AlexStocks committed
    - name: Install go ci lint
      run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0

    - name: Run Linter
      run: golangci-lint run --timeout=10m -v

    - name: Verify
Psnail's avatar
ci  
Psnail committed
      run: |
        make verify
tiecheng's avatar
tiecheng committed
#    - name: Integrate Test
#      run: |
#        chmod +x integrate_test.sh && ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}}
邹毅贤's avatar
邹毅贤 committed

    - name: Post Coverage
AlexStocks's avatar
AlexStocks committed
      run: bash <(curl -s https://codecov.io/bash)

    - name: Hello world
      run: echo Hello world ${{ secrets.DING_TOKEN }} ${{ secrets.DING_SIGN }}