circleci: rework pipeline
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Mar 4, 2019 at 23:12 UTC
4e8cc7f0dfc99df2d42bee3ec8e3889f5c57174a
1 file changed
+41
-42
.circleci/config.yml
+41
-42
@@ -1,19 +1,36 @@
1
version: 2.0
2
3
+aliases:
4
+ make_out_dirs: &make_out_dirs
5
+ run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS/{unit,sharness}
6
+ restore_gomod: &restore_gomod
7
+ restore_cache:
8
+ keys:
9
+ - v3-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-{{ .Environment.CIRCLE_JOB }}
10
+ - v3-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-
11
+ - v3-dep-{{ .Branch }}-
12
+ - v3-dep-master-
13
+ store_gomod: &store_gomod
14
+ save_cache:
15
+ key: v3-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-{{ .Environment.CIRCLE_JOB }}
16
+ paths:
17
+ - ~/go/pkg/mod
18
+ - ~/.cache/go-build/
19
+
20
+
21
defaults: &defaults
22
working_directory: ~/ipfs/go-ipfs
23
environment:
24
GO111MODULE: "on"
25
TEST_NO_DOCKER: 1
26
TEST_NO_FUSE: 1
9
- GOPATH: /home/circleci/.go_workspace
27
+ GOPATH: /home/circleci/go
28
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
29
CIRCLE: 1
30
SERVICE: circle-ci
31
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
32
TEST_VERBOSE: 1
33
TRAVIS: 1
16
- IMPORT_PATH: github.com/ipfs/go-ipfs
34
35
docker:
36
- image: circleci/golang:1.11
@@ -23,32 +40,22 @@ jobs:
40
<<: *defaults
41
steps:
42
- checkout
26
- - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
27
- - restore_cache:
28
- keys:
29
- - v2-dep-{{ .Branch }}-
30
- - v2-dep-master-
43
+ - *make_out_dirs
44
+ - *restore_gomod
45
32
- - run: rm -rf "$HOME/.go_workspace/src/$IMPORT_PATH"
33
- - run: mkdir -p "$HOME/.go_workspace/src/$IMPORT_PATH"
34
- - run: cp -aT . "$HOME/.go_workspace/src/$IMPORT_PATH"
35
- - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && go mod download
36
-
37
- - save_cache:
38
- key: v2-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}
39
- paths:
40
- - ~/.go_workspace/pkg/mod
41
-
42
-
43
- - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && curl -s https://codecov.io/bash > codecov
46
- run: |
45
- cd "$HOME/.go_workspace/src/$IMPORT_PATH" \
46
- && make -j 1 test/unit/gotest.junit.xml \
47
+ make -j 1 test/unit/gotest.junit.xml \
48
&& [[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]]
48
- - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && bash codecov -cF unittests -X search -f coverage/unit_tests.coverprofile
49
+ - run:
50
+ when: always
51
+ command: bash <(curl -s https://codecov.io/bash) -cF unittests -X search -f coverage/unit_tests.coverprofile
52
+
53
- run:
54
when: always
51
- command: mv "$HOME/.go_workspace/src/${IMPORT_PATH}/test/unit/gotest.junit.xml" /tmp/circleci-test-results
55
+ command: mv "test/unit/gotest.junit.xml" /tmp/circleci-test-results/unit
56
+
57
+ - *store_gomod
58
+
59
- store_test_results:
60
path: /tmp/circleci-test-results
61
# Save artifacts
@@ -61,29 +68,21 @@ jobs:
68
steps:
69
- run: sudo apt install socat
70
- checkout
64
- - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
65
- - restore_cache:
66
- keys:
67
- - v2-dep-{{ .Branch }}-
68
- - v2-dep-master-
71
+ - *make_out_dirs
72
+ - *restore_gomod
73
70
- - run: rm -rf "$HOME/.go_workspace/src/$IMPORT_PATH"
71
- - run: mkdir -p "$HOME/.go_workspace/src/$IMPORT_PATH"
72
- - run: cp -aT . "$HOME/.go_workspace/src/$IMPORT_PATH"
73
- - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && go mod download
74
-
75
- - save_cache:
76
- key: v2-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}
77
- paths:
78
- - ~/.go_workspace/pkg/mod
74
+ - run: make -j 10 coverage/sharness_tests.coverprofile test/sharness/test-results/sharness.xml TEST_GENERATE_JUNIT=1 CONTINUE_ON_S_FAILURE=1
75
80
- - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && curl -s https://codecov.io/bash > codecov
81
- - 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
82
- - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && bash codecov -cF sharness -X search -f coverage/sharness_tests.coverprofile
83
- - run: mv "$HOME/.go_workspace/src/${IMPORT_PATH}/test/sharness/test-results/sharness.xml" /tmp/circleci-test-results
76
+ - run:
77
+ when: always
78
+ command: bash <(curl -s https://codecov.io/bash) -cF sharness -X search -f coverage/sharness_tests.coverprofile
79
80
+ - run: mv "test/sharness/test-results/sharness.xml" /tmp/circleci-test-results/sharness
81
# make sure we fail if there are test failures
86
- - 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'
82
+ - run: find test/sharness/test-results -name 't*-*.sh.*.counts' | test/sharness/lib/sharness/aggregate-results.sh | grep 'failed\s*0'
83
+
84
+ - *store_gomod
85
+
86
- store_test_results:
87
path: /tmp/circleci-test-results
88
# Save artifacts