create file .github/workflows/master.yml
After the first creation, The Actions will be auto build.
- Create file
master.ymldirectly
name: Build and Test
on:
push:
branches: [ master ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: go mod vendor
- name: Test
run: go test -v .
# If it does not has the main function and doesn't need to build.
# - name: Build
# run: go build -v .- Create file
master.ymlby github page
- page 1
- page 2
- page 3
[](http://golang.org)[](https://github.com/<OWNER>/<REPOSITORY>)You must be created with License file
- page 1
- page 2
- page 3
- page 4
Sometimes it is not automatically created, and officials offer two solutions.
- First:
I used this method, but still not working
Making a request to proxy.golang.org for the module version, to any endpoint specified by the Module proxy protocol. For example: https://proxy.golang.org/example.com/my/module/@v/v1.0.0.info
curl https://proxy.golang.org/github.com/sillyhatxu/learning-github-actions/@latest
{"Version":"v1.0.0","Time":"2020-08-04T15:50:54Z"}
curl https://proxy.golang.org/github.com/sillyhatxu/learning-github-actions/@v/v1.0.0.info
{"Version":"v1.0.0","Time":"2020-08-04T15:50:54Z"}
- Second:
Create another golang project,after go mod init. Used go get command create Go Reference
Downloading the package via the go command. For example: GOPROXY=https://proxy.golang.org GO111MODULE=on go get example.com/my/module@v1.0.0
create new project xxxxxx
go mod init xxxxxx
go get github.com/sillyhatxu/learning-github-actions/@v1.0.2
[](https://pkg.go.dev/github.com/<OWNER>/<REPOSITORY>)[](https://github.com/sillyhatxu/learning-github-actions/actions)- Login codecov
- Add new repository
- Choose a new repository below
- Copy token
- Return Github Page
project->Settings->Secrets->New Secret
- Create Secret
CODECOV_TOKEN=xxxxxpaste codecov token
- Create workflows
coverage.yml
name: Coverage
on:
push:
branches: [ master ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: go mod vendor
- name: Create coverage file
run: |
set -e
echo "" > coverage.txt
for d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic "$d"
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
- name: Coverage
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}[](https://goreportcard.com/report/github.com/<OWNER>/<REPOSITORY>)[](https://github.com/<OWNER>/<REPOSITORY>/releases)[](https://choosealicense.com/licenses/mit/)











