github.com/vertgenlab/gonomics@v1.0.0/.github/workflows/go.yml (about) 1 name: Go 2 on: 3 push: 4 branches: main 5 pull_request: 6 branches: main 7 env: 8 GOLANG: 1.20.3 9 jobs: 10 format: 11 runs-on: ubuntu-latest 12 steps: 13 - uses: actions/checkout@v3 14 with: 15 ref: ${{ github.head_ref }} 16 - uses: actions/setup-go@v4 17 with: 18 go-version: ${{ env.GOLANG }} 19 - name: Setup lint 20 run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.0 && go install github.com/google/yamlfmt/cmd/yamlfmt@latest 21 - name: Test then Install 22 run: go test ./... && go install ./... 23 - name: Lint and automate clean up 24 run: make clean && go install ./... && go test ./... 25 - name: Check and push changes 26 run: | 27 export NAME=$(git log -n 1 --pretty=format:%an) 28 export EMAIL=$(git log -n 1 --pretty=format:%ae) 29 git config user.name "NAME" 30 git config user.email "$EMAIL" 31 if git diff-index --quiet HEAD --; then 32 git add -A 33 git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} 34 git commit -am "style: automated go lint ./... && go fmt ./..." 35 git push 36 fi 37 gitactions: 38 needs: format 39 strategy: 40 matrix: 41 OS: [ubuntu-latest, macos-latest, windows-latest] 42 runs-on: ${{ matrix.OS }} 43 steps: 44 - uses: actions/checkout@v3 45 - uses: actions/setup-go@v4 46 with: 47 go-version: ${{ env.GOLANG }} 48 - name: Install 49 run: make install 50 - name: Test 51 if: matrix.OS == 'ubuntu-latest' || matrix.OS == 'macos-latest' 52 run: make test 53 - name: Coverage 54 if: matrix.OS == 'ubuntu-latest' 55 run: go test -coverprofile=coverage.txt -covermode=atomic ./... 56 - name: Upload 57 if: matrix.OS == 'ubuntu-latest' 58 uses: codecov/codecov-action@v3 59 with: 60 token: ${{ secrets.CODECOV_TOKEN }} 61 fail_ci_if_error: false 62 files: coverage.txt 63 verbose: true