git » chasquid » commit d60c03f

tests: Add Cirrus CI integration

author Alberto Bertogli
2020-04-13 10:55:51 UTC
committer Alberto Bertogli
2020-04-14 11:01:01 UTC
parent 2e1e188387d5e9ad958f4cf558081862c80f6c64

tests: Add Cirrus CI integration

This patch adds a configuration for https://cirrus-ci.org/, which
includes running the Go tests on FreeBSD.

.cirrus.yml +70 -0
README.md +2 -1

diff --git a/.cirrus.yml b/.cirrus.yml
new file mode 100644
index 0000000..6a873da
--- /dev/null
+++ b/.cirrus.yml
@@ -0,0 +1,70 @@
+
+# Configuration for https://cirrus-ci.org/
+
+env:
+  GOPROXY: https://proxy.golang.org
+
+# Run go tests under a Linux container.
+# Note that by default it is run as root, which causes the tests to fail since
+# they expect to get permission denied on some cases, so we create a separate
+# user and use that instead.
+linux_task:
+  name: Go tests (Linux)
+  container:
+    image: golang:latest
+  modules_cache:
+    fingerprint_script: cat go.sum
+    folder: $GOPATH/pkg/mod
+  get_script: |
+    useradd --create-home --user-group testing
+    su testing -c "go get ./..."
+  build_script: |
+    su testing -c "go build ./..."
+  test_script: |
+    su testing -c "go test ./..."
+
+# Run go tests under a FreeBSD VM.
+# Same as linux_task, we need to use a separate non-root user.
+freebsd_task:
+  name: Go tests (FreeBSD)
+  freebsd_instance:
+      image_family: freebsd-13-0-snap
+  install_script: |
+    pkg install -y lang/go
+    pw useradd testing -m
+  test_script: |
+    su testing -c "go test ./..."
+
+# GolangCI linter.
+lint_task:
+  name: GolangCI Lint
+  container:
+    image: golangci/golangci-lint:latest
+  environment:
+    LINT_CONFIG: |
+      issues:
+        exclude:
+          - "Error return value of .(.*Errorf?). is not checked"
+          - "Error return value of .(.*SetDeadline). is not checked"
+          - "Error return value of .(.*ListenAndServe). is not checked"
+        exclude-rules:
+          - path: _test\.go
+            linters:
+              - errcheck
+          - linters:
+              - staticcheck
+            text: "SA1015:"
+        exclude-use-default: true
+  lint_config_file:
+    path: /tmp/lint.yml
+    variable_name: LINT_CONFIG
+  run_script: |
+    golangci-lint run -v --out-format json \
+      -c /tmp/lint.yml \
+      > lint-report.json
+  always:
+    golangci_artifacts:
+      path: lint-report.json
+      type: text/json
+      format: golangci
+
diff --git a/README.md b/README.md
index 9284718..754cf26 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,8 @@ It's written in [Go](https://golang.org), and distributed under the
 [Apache license 2.0](http://en.wikipedia.org/wiki/Apache_License).
 
 [![Travis-CI status](https://travis-ci.org/albertito/chasquid.svg?branch=master)](https://travis-ci.org/albertito/chasquid)
-[![Gitlab CI status](https://gitlab.com/albertito/chasquid/badges/master/pipeline.svg)](https://gitlab.com/albertito/chasquid/pipelines)
+[![Cirrus-CI Status](https://api.cirrus-ci.com/github/albertito/chasquid.svg?branch=next)](https://cirrus-ci.com/github/albertito/chasquid)
+[![Gitlab CI status](https://gitlab.com/albertito/chasquid/badges/master/pipeline.svg)](https://gitlab.com/albertito/chasquid/pipelines)\
 [![Go Report Card](https://goreportcard.com/badge/github.com/albertito/chasquid)](https://goreportcard.com/report/github.com/albertito/chasquid)
 [![Coverage](https://img.shields.io/badge/coverage-next-brightgreen.svg)](https://blitiri.com.ar/p/chasquid/coverage.html)
 [![Docs](https://img.shields.io/badge/docs-reference-blue.svg)](https://blitiri.com.ar/p/chasquid/docs/)