From 561dc95eeadf7fc57c2fe6ce2253f0f3361c0f75 Mon Sep 17 00:00:00 2001
From: Brian Downs <brian.downs@gmail.com>
Date: Sat, 12 Feb 2022 19:57:34 -0700
Subject: [PATCH] Update ci (#132)

---
 .circleci/config.yml | 27 +++++++++++++++++++++++++++
 README.md            |  2 +-
 spinner_test.go      | 11 +++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 .circleci/config.yml

diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000..6dc18bc
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,27 @@
+version: 2
+jobs:
+  build:
+    docker:
+      - image: circleci/golang:1.17
+    parallelism: 2
+    steps:
+      - checkout
+      - restore_cache:
+          keys:
+            - go-mod-v4-{{ checksum "go.sum" }}
+      - run: make test
+      - save_cache:
+          key: go-mod-v4-{{ checksum "go.sum" }}
+          paths:
+            - "/go/pkg/mod"
+      - store_artifacts:
+          path: /tmp/test-results
+          destination: raw-test-output
+
+      - store_test_results:
+          path: /tmp/test-results
+workflows:
+  version: 2
+  build-workflow:
+    jobs:
+      - build
diff --git a/README.md b/README.md
index 20b315f..28b024d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # Spinner
 
-[![GoDoc](https://godoc.org/github.com/briandowns/spinner?status.svg)](https://godoc.org/github.com/briandowns/spinner) [![Build Status](https://travis-ci.org/briandowns/spinner.svg?branch=master)](https://travis-ci.org/briandowns/spinner)
+[![GoDoc](https://godoc.org/github.com/briandowns/spinner?status.svg)](https://godoc.org/github.com/briandowns/spinner) [![CircleCI](https://circleci.com/gh/briandowns/spinner.svg?style=svg)](https://circleci.com/gh/briandowns/spinner)
 
 spinner is a simple package to add a spinner / progress indicator to any terminal application. Examples can be found below as well as full examples in the examples directory.
 
diff --git a/spinner_test.go b/spinner_test.go
index cf3edfc..8ddf092 100644
--- a/spinner_test.go
+++ b/spinner_test.go
@@ -18,10 +18,13 @@ import (
 	"bytes"
 	"fmt"
 	"io/ioutil"
+	"os"
 	"reflect"
 	"sync"
 	"testing"
 	"time"
+
+	"github.com/mattn/go-isatty"
 )
 
 const baseWait = 3
@@ -69,6 +72,10 @@ func TestStart(t *testing.T) {
 
 // TestActive will verify we can tell when a spinner is running
 func TestActive(t *testing.T) {
+	if !isatty.IsTerminal(os.Stdout.Fd()) {
+		t.Log("not running in a terminal")
+		return
+	}
 	s := New(CharSets[1], 100*time.Millisecond)
 	if s.Active() {
 		t.Error("expected a new spinner to not be active")
@@ -127,6 +134,10 @@ func TestRestart(t *testing.T) {
 
 // TestHookFunctions will verify that hook functions works as expected
 func TestHookFunctions(t *testing.T) {
+	if !isatty.IsTerminal(os.Stdout.Fd()) {
+		t.Log("not running in a termian")
+		return
+	}
 	s := New(CharSets[4], 50*time.Millisecond)
 	var out syncBuffer
 	s.Writer = &out
-- 
2.35.1

