diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6c7d3bf..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,54 +0,0 @@ -version: 2 - -templates: - gomod-template: &gomod-template - working_directory: /home/circleci/uio - environment: - - CGO_ENABLED: 0 - - GO111MODULE: "on" - - go116-template: &go116-template - docker: - - image: circleci/golang:1.16 - -workflows: - version: 2 - build: - jobs: - - clean - - build: - requires: - - clean - -jobs: - clean: - <<: [*go116-template, *gomod-template] - steps: - - checkout - - run: - name: vet - command: go vet ./... - - run: - name: gofmt - command: | - test -z "$(gofmt -s -l $(find -name '*.go' | grep -v /vendor/))" - - run: - name: go mod tidy - command: | - go mod tidy - git status - if [[ -n "$(git status --porcelain .)" ]]; then - echo 'go.mod/go.sum is out-of-date: run `go mod tidy` and then check in the changes' - echo 'If `go mod tidy` results in no changes, make sure you are using the latest relase of Go' - git status --porcelain . - exit 1 - fi - - build: - <<: [*go116-template, *gomod-template] - steps: - - checkout - - run: go env - - run: go build ./... - - run: go test ./... - - run: ./cross-compile.sh diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..03a500c --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,81 @@ +name: Go + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +# Cancel running workflows on new push to a PR. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + tidy: + name: Tidy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.22.x' + + - name: gofmt + run: test -z "$(gofmt -s -l $(find -name '*.go'))" + + - name: go mod tidy + run: | + go mod tidy + git status + if [[ -n "$(git status --porcelain .)" ]]; then + echo 'go.mod/go.sum is out-of-date: run `go mod tidy` and then check in the changes' + echo 'If `go mod tidy` results in no changes, make sure you are using the latest relase of Go' + git status --porcelain . + exit 1 + fi + + build: + name: Build + runs-on: ubuntu-latest + strategy: + matrix: + goversion: ['1.21.x', '1.22.x'] + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.goversion }} + + - run: go build -v ./... + + - run: ./cross-compile.sh + + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + goversion: ['1.21.x', '1.22.x'] + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.goversion }} + + - name: Test + run: go test -v -covermode atomic -coverpkg ./... -coverprofile cover.out ./... + + - name: Race + run: go test -race -v ./... + + - uses: codecov/codecov-action@v4-beta + env: + CODECOV_TOKEN: '9f38c23a-5d79-4a19-a90f-72edcac95ce1' + with: + flags: ${{ matrix.goversion }} + fail_ci_if_error: true + verbose: true