-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5691 from ipfs/ci/circle2
Use CircleCI 2.0
- Loading branch information
Showing
10 changed files
with
269 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
version: 2 | ||
|
||
defaults: &defaults | ||
working_directory: ~/ipfs/go-ipfs | ||
shell: /bin/bash --login | ||
environment: | ||
TEST_NO_FUSE: 1 | ||
GOPATH: $HOME/.go_workspace | ||
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results | ||
CIRCLE: 1 | ||
SERVICE: circle-ci | ||
TEST_NO_DOCKER: 1 | ||
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts | ||
TEST_VERBOSE: 1 | ||
TRAVIS: 1 | ||
IMPORT_PATH: github.com/ipfs/go-ipfs | ||
|
||
docker: | ||
- image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37 | ||
command: /sbin/init | ||
|
||
jobs: | ||
gotest: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS | ||
- run: 'sudo docker info >/dev/null 2>&1 || sudo service docker start; ' | ||
- run: sudo rm -rf /usr/local/go | ||
- run: if [ ! -e go1.11.linux-amd64.tar.gz ]; then curl -o go1.11.linux-amd64.tar.gz https://storage.googleapis.com/golang/go1.11.linux-amd64.tar.gz; fi | ||
- run: sudo tar -C /usr/local -xzf go1.11.linux-amd64.tar.gz | ||
|
||
- restore_cache: | ||
keys: | ||
- v1-dep-{{ .Branch }}- | ||
- v1-dep-master- | ||
|
||
- run: sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0 net.ipv6.conf.default.disable_ipv6=0 net.ipv6.conf.all.disable_ipv6=0 | ||
- run: rm -rf "$HOME/.go_workspace/src/$IMPORT_PATH" | ||
- run: mkdir -p "$HOME/.go_workspace/src/$IMPORT_PATH" | ||
- run: cp -aT . "$HOME/.go_workspace/src/$IMPORT_PATH" | ||
- run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && make deps | ||
|
||
- save_cache: | ||
key: v1-dep-{{ .Branch }}-{{ epoch }} | ||
paths: | ||
- ~/.go_workspace | ||
- ~/go1.11.linux-amd64.tar.gz | ||
- ~/.go_workspace/src/gx/ipfs | ||
- ./node_modules | ||
|
||
|
||
- run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && curl -s https://codecov.io/bash > codecov | ||
- run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && make -j 1 test/unit/gotest.junit.xml | ||
- run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && bash codecov -cF unittests -X search -f coverage/unit_tests.coverprofile | ||
- run: mv "$HOME/.go_workspace/src/${IMPORT_PATH}/test/unit/gotest.junit.xml" /tmp/circleci-test-results | ||
- store_test_results: | ||
path: /tmp/circleci-test-results | ||
# Save artifacts | ||
- store_artifacts: | ||
path: /tmp/circleci-artifacts | ||
- store_artifacts: | ||
path: /tmp/circleci-test-results | ||
sharness: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS | ||
- run: 'sudo docker info >/dev/null 2>&1 || sudo service docker start; ' | ||
- run: sudo rm -rf /usr/local/go | ||
- run: if [ ! -e go1.11.linux-amd64.tar.gz ]; then curl -o go1.11.linux-amd64.tar.gz https://storage.googleapis.com/golang/go1.11.linux-amd64.tar.gz; fi | ||
- run: sudo tar -C /usr/local -xzf go1.11.linux-amd64.tar.gz | ||
|
||
- restore_cache: | ||
keys: | ||
- v1-dep-{{ .Branch }}- | ||
- v1-dep-master- | ||
|
||
- run: sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0 net.ipv6.conf.default.disable_ipv6=0 net.ipv6.conf.all.disable_ipv6=0 | ||
- run: rm -rf "$HOME/.go_workspace/src/$IMPORT_PATH" | ||
- run: mkdir -p "$HOME/.go_workspace/src/$IMPORT_PATH" | ||
- run: cp -aT . "$HOME/.go_workspace/src/$IMPORT_PATH" | ||
- run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && make deps | ||
|
||
- save_cache: | ||
key: v1-dep-{{ .Branch }}-{{ epoch }} | ||
paths: | ||
- ~/.go_workspace | ||
- ~/go1.11.linux-amd64.tar.gz | ||
- ~/.go_workspace/src/gx/ipfs | ||
- ./node_modules | ||
|
||
- run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && curl -s https://codecov.io/bash > codecov | ||
- run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && make -j 10 coverage/sharness_tests.coverprofile test/sharness/test-results/sharness.xml TEST_GENERATE_JUNIT=1 CONTINUE_ON_S_FAILURE=1 | ||
- run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && bash codecov -cF sharness -X search -f coverage/sharness_tests.coverprofile | ||
- run: mv "$HOME/.go_workspace/src/${IMPORT_PATH}/test/sharness/test-results/sharness.xml" /tmp/circleci-test-results | ||
|
||
# make sure we fail if there are test failures | ||
- run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && ls test/sharness/test-results/t*-*.sh.*.counts | test/sharness/lib/sharness/aggregate-results.sh | grep 'failed\s*0' | ||
- store_test_results: | ||
path: /tmp/circleci-test-results | ||
# Save artifacts | ||
- store_artifacts: | ||
path: /tmp/circleci-artifacts | ||
- store_artifacts: | ||
path: /tmp/circleci-test-results | ||
|
||
workflows: | ||
version: 2 | ||
test: | ||
jobs: | ||
- gotest | ||
- sharness |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"encoding/json" | ||
"encoding/xml" | ||
"log" | ||
"os" | ||
) | ||
|
||
type testMsg struct { | ||
Time string | ||
Action string | ||
Package string | ||
Test string | ||
Output string | ||
Elapsed float64 | ||
} | ||
|
||
type testsuites struct { | ||
XMLName xml.Name `xml:"testsuites"` | ||
Name string `xml:"name,attr"` | ||
Testsuites []testsuite | ||
} | ||
|
||
type testsuite struct { | ||
XMLName xml.Name `xml:"testsuite"` | ||
Package string `xml:"package,attr"` | ||
Errors int `xml:"errors,attr"` | ||
Failures int `xml:"failures,attr"` | ||
Tests int `xml:"tests,attr"` | ||
Time float64 `xml:"time,attr"` | ||
Testcases []testcase | ||
} | ||
|
||
type testcase struct { | ||
XMLName xml.Name `xml:"testcase"` | ||
Name string `xml:"name,attr"` | ||
Classname string `xml:"classname,attr"` | ||
Time float64 `xml:"time,attr"` | ||
Sout string `xml:"system-out"` | ||
Serr string `xml:"system-err"` | ||
Skipped string `xml:"skipped,omitempty"` | ||
Failure string `xml:"failure,omitempty"` | ||
} | ||
|
||
func main() { | ||
scanner := bufio.NewScanner(os.Stdin) | ||
tests := make(map[string]map[string]testcase) | ||
var fails int | ||
var packages []testsuite | ||
for scanner.Scan() { | ||
msg := testMsg{} | ||
if err := json.Unmarshal(scanner.Bytes(), &msg); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
switch { | ||
case msg.Action == "run": | ||
if tests[msg.Package] == nil { | ||
tests[msg.Package] = make(map[string]testcase) | ||
} | ||
|
||
tests[msg.Package][msg.Test] = testcase{ | ||
Name: msg.Test, | ||
Classname: msg.Package, | ||
} | ||
case msg.Action == "output": | ||
if msg.Test == "" { | ||
continue | ||
} | ||
|
||
test := tests[msg.Package][msg.Test] | ||
test.Sout = test.Sout + msg.Output + "\n" | ||
tests[msg.Package][msg.Test] = test | ||
case msg.Action == "skip": | ||
fallthrough | ||
case msg.Action == "fail": | ||
fallthrough | ||
case msg.Action == "pass": | ||
if msg.Test != "" { | ||
test := tests[msg.Package][msg.Test] | ||
test.Time = msg.Elapsed | ||
|
||
if msg.Action == "skip" { | ||
test.Skipped = "skipped" | ||
} | ||
|
||
if msg.Action == "fail" { | ||
fails++ | ||
test.Failure = "failed" | ||
} | ||
|
||
tests[msg.Package][msg.Test] = test | ||
continue | ||
} | ||
|
||
ts := testsuite{ | ||
Package: msg.Package, | ||
Time: msg.Elapsed, | ||
} | ||
|
||
for _, test := range tests[msg.Package] { | ||
ts.Testcases = append(ts.Testcases, test) | ||
ts.Tests++ | ||
if test.Failure != "" { | ||
ts.Failures++ | ||
} | ||
} | ||
packages = append(packages, ts) | ||
case msg.Action == "cont": | ||
case msg.Action == "pause": | ||
// ?? | ||
default: | ||
log.Fatalf("unknown action %s", msg.Action) | ||
} | ||
} | ||
|
||
if err := scanner.Err(); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
out := testsuites{ | ||
Name: "go test", | ||
Testsuites: packages, | ||
} | ||
|
||
output, err := xml.MarshalIndent(&out, " ", " ") | ||
if err != nil { | ||
log.Fatalf("error: %v\n", err) | ||
} | ||
|
||
os.Stdout.Write(output) | ||
os.Exit(fails) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
gotest.json | ||
gotest.junit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
include mk/header.mk | ||
|
||
CLEAN += $(d)/gotest.json $(d)/gotest.junit.xml | ||
|
||
$(d)/gotest.junit.xml: clean test/bin/json-to-junit coverage/unit_tests.coverprofile | ||
cat $(@D)/gotest.json | json-to-junit > $(@D)/gotest.junit.xml | ||
|
||
include mk/footer.mk |