diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..bccfeeab0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# Tell Git to use LF for line endings on all platforms. +# Required to have correct test data on Windows. +# https://github.com/mvdan/github-actions-golang#caveats +# https://github.com/actions/checkout/issues/135#issuecomment-613361104 +* text eol=lf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 225dcc404..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,103 +0,0 @@ -name: go-workflow -on: - push: - branches: - - master - - release/** - pull_request: -jobs: - golang-tests: - name: tests - runs-on: ubuntu-latest - timeout-minutes: 10 - strategy: - matrix: - go-version: ["tip", "1.15", "1.14", "1.13"] - go111module: ["on", "off"] - include: - # includes goflags when go111module is on - - go111module: "on" - goflags: -mod=readonly - env: - GO111MODULE: ${{ matrix.go111module }} - # XXX: Investigate why GOPATH is needed for Modules off - GOPATH: ${{ github.workspace }} - # Required for building with GOPATH - # https://github.com/mvdan/github-actions-golang#how-do-i-set-up-a-gopath-build - defaults: - run: - working-directory: ${{ github.workspace }}/src/github.com/getsentry/sentry-go - steps: - - uses: actions/setup-go@v2 - if: matrix.go-version != 'tip' - with: - go-version: ${{ matrix.go-version}} - - name: Run setup-go for tip - if: matrix.go-version == 'tip' - working-directory: ${{ github.workspace }} - run: | - git clone https://go.googlesource.com/go $HOME/gotip - cd $HOME/gotip/src - ./make.bash - echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV - echo "PATH=$HOME/gotip/bin:$PATH" >> $GITHUB_ENV - - uses: actions/checkout@v2 - with: - # Relative path under Github workspace - path: ${{ github.workspace }}/src/github.com/getsentry/sentry-go - # Getting all history enables using `git merge-base origin/master HEAD` - fetch-depth: 0 - - name: Adjustments for Module mode enabled - if: matrix.go111module == 'on' - run: | - echo "GOFLAGS=${{ matrix.goflags }}" >> $GITHUB_ENV - - name: Adjustments for Module mode disabled - if: matrix.go111module == 'off' - run: | - # Iris does not supported in legacy GOPATH mode. We delete the source code - # because otherwise lint, build, and test steps would fail. - rm -vrf ./iris/ ./example/iris/ - # go get is not required in Module mode - go get -v -t ./... - - name: Build - run: go build ./... - - name: Tests - run: | - go test ./... - go test ./... -race - - name: Run linting if Go Module is on - if: matrix.go111module == 'on' - run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/v1.27.0/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0 - git fetch origin master:remotes/origin/master - $(go env GOPATH)/bin/golangci-lint run --new-from-rev=$(git merge-base origin/master HEAD) - - golang-outside-gopath: - name: Module support outside GOPATH - runs-on: ubuntu-latest - timeout-minutes: 5 - env: - GO111MODULE: on - GOFLAGS: -mod=readonly - GOPATH: ${{ github.workspace }} - # Required for building with GOPATH - # https://github.com/mvdan/github-actions-golang#how-do-i-set-up-a-gopath-build - defaults: - run: - working-directory: ${{ env.GOPATH }}/src/github.com/getsentry/sentry-go - steps: - - uses: actions/checkout@v2 - with: - # Relative path under Github workspace - path: src/github.com/getsentry/sentry-go - - uses: actions/setup-go@v2 - with: - go-version: 1.15 - - name: Run tests outside of GOPATH - run: | - mv $GOPATH/src/github.com/getsentry/sentry-go ~/sentry-go - cd ~/sentry-go - export GOPATH= - go env GOPATH - go test ./... - go test ./... -race diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..e15e27e35 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +name: Lint +on: + push: + branches: + - master + - release/** + pull_request: +permissions: + contents: read +defaults: + run: + shell: bash +concurrency: + group: lint-${{ github.ref }} + cancel-in-progress: true +jobs: + golangci-lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.40.1 + only-new-issues: true + timeout-minutes: 10 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..40e588197 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,107 @@ +name: Test +on: + push: + branches: + - master + - release/** + pull_request: +permissions: + contents: read +defaults: + run: + shell: bash +concurrency: + group: test-${{ github.ref }} + cancel-in-progress: true +jobs: + test: + name: Module Mode + runs-on: ${{ matrix.os }}-latest + env: + GO111MODULE: "on" + GOFLAGS: "-mod=readonly" + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + %LocalAppData%\go-build + key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ matrix.go }}- + ${{ runner.os }}-go- + - uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + - name: Build + run: go build ./... + - name: Vet + run: go vet ./... + - name: Test + run: go test ./... + - name: Test (race) + run: go test -race ./... + timeout-minutes: 10 + strategy: + matrix: + go: ["1.16", "1.15", "1.14"] + os: [ubuntu, windows, macos] + fail-fast: false + test-gopath: + name: GOPATH Mode + runs-on: ubuntu-latest + env: + # We use two paths in GOPATH. + # The first one is where 'go get' will download dependencies, and + # the second is where sentry-go itself will be checked out. + GOPATH: ${{ github.workspace }}/deps:${{ github.workspace }}/main + GO111MODULE: "off" + WORKDIR: ${{ github.workspace }}/main/src/github.com/getsentry/sentry-go + defaults: + run: + working-directory: ${{ env.WORKDIR }} + steps: + - uses: actions/checkout@v2 + with: + path: ${{ env.WORKDIR }} + # TODO: cache dependencies + # - uses: actions/cache@v2 + # with: + # # In order: + # # * GOPATH with dependencies (but without sentry-go) + # # * GOPATH with sentry-go installed package objects (*.a files) + # # * Build cache (Linux) + # path: | + # ${{ github.workspace }}/deps + # ${{ github.workspace }}/main/pkg + # ~/.cache/go-build + # key: gopath-${{ github.ref }} + # restore-keys: | + # gopath- + - uses: actions/setup-go@v2 + with: + go-version: "1" + - name: Remove Unsupported Code + run: | + # Iris requires Module mode, therefore we delete the relevant code to + # skip testing it in GOPATH mode. + rm -vrf ./iris/ ./example/iris/ + - name: Download Dependencies + run: go get -d -t -v ./... + - name: Build + run: go build ./... + - name: Vet + run: go vet ./... + - name: Test + run: go test ./... + - name: Test (race) + run: go test -race ./... + timeout-minutes: 10