Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Rewrite GitHub Action workflows #346

Merged
merged 1 commit into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
103 changes: 0 additions & 103 deletions .github/workflows/ci.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
107 changes: 107 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't enable this step for now because it requires a bit more thought on the cache key or how to update dependencies.

In GOPATH Mode we download all dependencies in their latest commits. With too aggressive caching or missing an update step (a la go get -u) we'd be testing against stale dependencies.

We can't use go get -d -t -u -v ./... because that would also try to update sentry-go itself. The solution probably requires resorting to go list and would need to work no matter if we got a cache hit or miss. Deferring that for later.

This job is obviously prone to breakage (dependencies are changing out of our control) and not going to be required to merge changes.

# - 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