test: port CircleCI to GH Actions and improve sharness reporting (#9355)
Closes https://github.com/ipfs/kubo/issues/8991 Part of https://github.com/ipfs/kubo/issues/8804
Piotr Galar committed
Jan 14, 2023 at 00:49 UTC
d4cd414b5eaa3c6f1a1a27bdba323e27d19678d2
30 files changed
+708
-379
.circleci/config.yml
+1
-1
@@ -7,7 +7,7 @@ jobs:
7
executor: continuation/default
8
steps:
9
- checkout
10
- - run:
10
+ - run:
11
name: Generate params
12
# for builds on the ipfs/kubo repo, use 2xlarge for faster builds
13
# but since this is not available for many contributors, we otherwise use medium
.circleci/main.yml
+10
-7
@@ -143,14 +143,17 @@ jobs:
143
path: /tmp/circleci-test-results
144
sharness:
145
machine:
146
- image: ubuntu-2004:202010-01
146
+ image: ubuntu-2204:2022.10.1
147
resource_class: << pipeline.parameters.resource_class >>
148
working_directory: ~/ipfs/kubo
149
environment:
150
<<: *default_environment
151
TEST_NO_DOCKER: 0
152
+ TEST_NO_PLUGIN: 1
153
TEST_NO_FUSE: 1
154
TEST_VERBOSE: 1
155
+ TEST_JUNIT: 1
156
+ TEST_EXPENSIVE: 1
157
steps:
158
- run: sudo apt update
159
- run: |
@@ -159,7 +162,7 @@ jobs:
162
tar xfz go1.19.1.linux-amd64.tar.gz
163
echo "export PATH=$(pwd)/go/bin:\$PATH" >> ~/.bashrc
164
- run: go version
162
- - run: sudo apt install socat net-tools fish
165
+ - run: sudo apt install socat net-tools fish libxml2-utils
166
- checkout
167
168
- run:
@@ -183,7 +186,7 @@ jobs:
186
command: echo "export TEST_DOCKER_HOST=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')" >> $BASH_ENV
187
- run:
188
echo TEST_DOCKER_HOST=$TEST_DOCKER_HOST &&
186
- make -O -j << pipeline.parameters.make_jobs >> coverage/sharness_tests.coverprofile test/sharness/test-results/sharness.xml TEST_GENERATE_JUNIT=1 CONTINUE_ON_S_FAILURE=1 TEST_DOCKER_HOST=$TEST_DOCKER_HOST
189
+ make -O -j << pipeline.parameters.make_jobs >> test_sharness coverage/sharness_tests.coverprofile test/sharness/test-results/sharness.xml CONTINUE_ON_S_FAILURE=1 TEST_DOCKER_HOST=$TEST_DOCKER_HOST
190
- run:
191
when: always
192
command: bash <(curl -s https://codecov.io/bash) -cF sharness -X search -f coverage/sharness_tests.coverprofile
@@ -345,13 +348,13 @@ jobs:
348
npx playwright install
349
working_directory: ~/ipfs/kubo/ipfs-webui
350
- run:
348
- name: Running upstream tests (finish early if they fail)
351
+ name: Run ipfs-webui@main build and smoke-test to confirm the upstream repo is not broken
352
command: |
350
- npm test || circleci-agent step halt
353
+ npm test
354
working_directory: ~/ipfs/kubo/ipfs-webui
355
- run:
353
- name: Running tests with kubo built from current commit
354
- command: npm test
356
+ name: Test ipfs-webui@main E2E against the locally built Kubo binary
357
+ command: npm run test:e2e
358
working_directory: ~/ipfs/kubo/ipfs-webui
359
environment:
360
IPFS_GO_EXEC: /tmp/circleci-workspace/bin/ipfs
.github/workflows/build.yml
new
+200
@@ -0,0 +1,200 @@
1
+name: 'ci/gh-experiment: interop'
2
+
3
+on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - 'master'
9
+
10
+env:
11
+ GO_VERSION: 1.19.1
12
+
13
+jobs:
14
+ prepare:
15
+ if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
16
+ runs-on: ubuntu-latest
17
+ env:
18
+ TEST_NO_DOCKER: 1
19
+ TEST_NO_FUSE: 1
20
+ TEST_VERBOSE: 1
21
+ TRAVIS: 1
22
+ GIT_PAGER: cat
23
+ IPFS_CHECK_RCMGR_DEFAULTS: 1
24
+ defaults:
25
+ run:
26
+ shell: bash
27
+ steps:
28
+ - uses: actions/setup-go@v3
29
+ with:
30
+ go-version: ${{ env.GO_VERSION }}
31
+ - uses: actions/checkout@v3
32
+ - uses: protocol/cache-go-action@v1
33
+ with:
34
+ name: ${{ github.job }}
35
+ - run: make build
36
+ - uses: actions/upload-artifact@v3
37
+ with:
38
+ name: kubo
39
+ path: cmd/ipfs/ipfs
40
+ ipfs-interop:
41
+ needs: [prepare]
42
+ runs-on: ubuntu-latest
43
+ strategy:
44
+ matrix:
45
+ suites:
46
+ - 'exchange-files'
47
+ - 'files pin circuit ipns cid-version-agnostic ipns-pubsub pubsub'
48
+ fail-fast: false
49
+ defaults:
50
+ run:
51
+ shell: bash
52
+ steps:
53
+ - uses: actions/setup-node@v3
54
+ with:
55
+ node-version: 16.12.0
56
+ - uses: actions/download-artifact@v3
57
+ with:
58
+ name: kubo
59
+ path: cmd/ipfs
60
+ - run: chmod +x cmd/ipfs/ipfs
61
+ - run: |
62
+ echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
63
+ id: npm-cache-dir
64
+ - uses: actions/cache@v3
65
+ with:
66
+ path: ${{ steps.npm-cache-dir.outputs.dir }}
67
+ key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/package-lock.json') }}
68
+ restore-keys: |
69
+ ${{ runner.os }}-${{ github.job }}-
70
+ - run: mkdir interop
71
+ - run: |
72
+ npm init -y
73
+ npm install ipfs@^0.61.0
74
+ npm install ipfs-interop@^8.0.10
75
+ working-directory: interop
76
+ - run: npx ipfs-interop -- -t node $(sed -e 's#[^ ]*#-f test/&.js#g' <<< '${{ matrix.suites }}')
77
+ env:
78
+ LIBP2P_TCP_REUSEPORT: false
79
+ LIBP2P_ALLOW_WEAK_RSA_KEYS: 1
80
+ IPFS_GO_EXEC: ${{ github.workspace }}/cmd/ipfs/ipfs
81
+ working-directory: interop
82
+ go-ipfs-api:
83
+ needs: [prepare]
84
+ runs-on: ubuntu-latest
85
+ env:
86
+ TEST_NO_DOCKER: 1
87
+ TEST_NO_FUSE: 1
88
+ TEST_VERBOSE: 1
89
+ TRAVIS: 1
90
+ GIT_PAGER: cat
91
+ IPFS_CHECK_RCMGR_DEFAULTS: 1
92
+ defaults:
93
+ run:
94
+ shell: bash
95
+ steps:
96
+ - uses: actions/setup-go@v3
97
+ with:
98
+ go-version: ${{ env.GO_VERSION }}
99
+ - uses: actions/download-artifact@v3
100
+ with:
101
+ name: kubo
102
+ path: cmd/ipfs
103
+ - run: chmod +x cmd/ipfs/ipfs
104
+ - uses: actions/checkout@v3
105
+ with:
106
+ repository: ipfs/go-ipfs-api
107
+ path: go-ipfs-api
108
+ - run: cmd/ipfs/ipfs daemon --init --enable-namesys-pubsub &
109
+ - run: |
110
+ while ! cmd/ipfs/ipfs id --api=/ip4/127.0.0.1/tcp/5001 2>/dev/null; do
111
+ sleep 1
112
+ done
113
+ timeout-minutes: 5
114
+ - uses: protocol/cache-go-action@v1
115
+ with:
116
+ name: ${{ github.job }}
117
+ - run: go test -count=1 -v ./...
118
+ working-directory: go-ipfs-api
119
+ - run: cmd/ipfs/ipfs shutdown
120
+ if: always()
121
+ go-ipfs-http-client:
122
+ needs: [prepare]
123
+ runs-on: ubuntu-latest
124
+ env:
125
+ TEST_NO_DOCKER: 1
126
+ TEST_NO_FUSE: 1
127
+ TEST_VERBOSE: 1
128
+ TRAVIS: 1
129
+ GIT_PAGER: cat
130
+ IPFS_CHECK_RCMGR_DEFAULTS: 1
131
+ defaults:
132
+ run:
133
+ shell: bash
134
+ steps:
135
+ - uses: actions/setup-go@v3
136
+ with:
137
+ go-version: ${{ env.GO_VERSION }}
138
+ - uses: actions/download-artifact@v3
139
+ with:
140
+ name: kubo
141
+ path: cmd/ipfs
142
+ - run: chmod +x cmd/ipfs/ipfs
143
+ - uses: actions/checkout@v3
144
+ with:
145
+ repository: ipfs/go-ipfs-http-client
146
+ path: go-ipfs-http-client
147
+ - uses: protocol/cache-go-action@v1
148
+ with:
149
+ name: ${{ github.job }}
150
+ - run: echo '${{ github.workspace }}/cmd/ipfs' >> $GITHUB_PATH
151
+ - run: go test -count=1 -v ./...
152
+ working-directory: go-ipfs-http-client
153
+ ipfs-webui:
154
+ needs: [prepare]
155
+ runs-on: ubuntu-latest
156
+ env:
157
+ NO_SANDBOX: true
158
+ LIBP2P_TCP_REUSEPORT: false
159
+ LIBP2P_ALLOW_WEAK_RSA_KEYS: 1
160
+ E2E_IPFSD_TYPE: go
161
+ TRAVIS: 1
162
+ GIT_PAGER: cat
163
+ IPFS_CHECK_RCMGR_DEFAULTS: 1
164
+ defaults:
165
+ run:
166
+ shell: bash
167
+ steps:
168
+ - uses: actions/setup-node@v3
169
+ with:
170
+ node-version: 16.12.0
171
+ - uses: actions/download-artifact@v3
172
+ with:
173
+ name: kubo
174
+ path: cmd/ipfs
175
+ - run: chmod +x cmd/ipfs/ipfs
176
+ - uses: actions/checkout@v3
177
+ with:
178
+ repository: ipfs/ipfs-webui
179
+ path: ipfs-webui
180
+ - run: |
181
+ echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
182
+ id: npm-cache-dir
183
+ - uses: actions/cache@v3
184
+ with:
185
+ path: ${{ steps.npm-cache-dir.outputs.dir }}
186
+ key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/package-lock.json') }}
187
+ restore-keys: |
188
+ ${{ runner.os }}-${{ github.job }}-
189
+ - run: |
190
+ npm ci --prefer-offline --no-audit --progress=false
191
+ npx playwright install
192
+ working-directory: ipfs-webui
193
+ - name: Run ipfs-webui@main build and smoke-test to confirm the upstream repo is not broken
194
+ run: npm test
195
+ working-directory: ipfs-webui
196
+ - name: Test ipfs-webui@main E2E against the locally built Kubo binary
197
+ run: npm run test:e2e
198
+ env:
199
+ IPFS_GO_EXEC: ${{ github.workspace }}/cmd/ipfs/ipfs
200
+ working-directory: ipfs-webui
.github/workflows/codeql-analysis.yml
+1
-1
@@ -1,5 +1,5 @@
1
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
2
-name: "CodeQL"
2
+name: CodeQL
3
4
on:
5
workflow_dispatch:
.github/workflows/docker-build.yml
new
+25
@@ -0,0 +1,25 @@
1
+name: 'ci/gh-experiment: docker-build'
2
+
3
+on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - 'master'
9
+
10
+jobs:
11
+ docker-build:
12
+ if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
13
+ runs-on: ubuntu-latest
14
+ env:
15
+ IMAGE_NAME: ipfs/kubo
16
+ WIP_IMAGE_TAG: wip
17
+ defaults:
18
+ run:
19
+ shell: bash
20
+ steps:
21
+ - uses: actions/setup-go@v3
22
+ with:
23
+ go-version: 1.19.1
24
+ - uses: actions/checkout@v3
25
+ - run: docker build -t $IMAGE_NAME:$WIP_IMAGE_TAG .
.github/workflows/docker-image.yml
+1
-1
@@ -32,7 +32,7 @@ jobs:
32
run: |
33
TAGS="$(./bin/get-docker-tags.sh $(date -u +%F))"
34
TAGS="${TAGS//$'\n'/'%0A'}"
35
- echo "::set-output name=value::$(echo $TAGS)"
35
+ echo "value=$(echo $TAGS)" >> $GITHUB_OUTPUT
36
shell: bash
37
38
- name: Log in to Docker Hub
.github/workflows/gobuild.yml
new
+39
@@ -0,0 +1,39 @@
1
+name: 'ci/gh-experiment: go build'
2
+
3
+on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - 'master'
9
+
10
+jobs:
11
+ runner:
12
+ if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
13
+ uses: ipfs/kubo/.github/workflows/runner.yml@ci/move-to-github-actions # TODO: change to master
14
+ gobuild:
15
+ needs: [runner]
16
+ runs-on: ${{ fromJSON(needs.runner.outputs.config).labels }}
17
+ env:
18
+ TEST_NO_DOCKER: 1
19
+ TEST_VERBOSE: 1
20
+ TRAVIS: 1
21
+ GIT_PAGER: cat
22
+ IPFS_CHECK_RCMGR_DEFAULTS: 1
23
+ defaults:
24
+ run:
25
+ shell: bash
26
+ steps:
27
+ - uses: actions/setup-go@v3
28
+ with:
29
+ go-version: 1.19.1
30
+ - uses: actions/checkout@v3
31
+ - uses: protocol/cache-go-action@v1
32
+ with:
33
+ name: ${{ github.job }}
34
+ - run: make cmd/ipfs-try-build
35
+ env:
36
+ TEST_NO_FUSE: 0
37
+ - run: make cmd/ipfs-try-build
38
+ env:
39
+ TEST_NO_FUSE: 1
.github/workflows/golang-analysis.yml
+8
-1
@@ -1,8 +1,15 @@
1
-on: [push, pull_request]
1
name: Go Checks
2
3
+on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - 'master'
9
+
10
jobs:
11
unit:
12
+ if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
13
runs-on: ubuntu-latest
14
name: All
15
steps:
.github/workflows/golint.yml
new
+32
@@ -0,0 +1,32 @@
1
+name: 'ci/gh-experiment: go lint'
2
+
3
+on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - 'master'
9
+
10
+jobs:
11
+ golint:
12
+ if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
13
+ runs-on: ubuntu-latest
14
+ env:
15
+ TEST_NO_DOCKER: 1
16
+ TEST_NO_FUSE: 1
17
+ TEST_VERBOSE: 1
18
+ TRAVIS: 1
19
+ GIT_PAGER: cat
20
+ IPFS_CHECK_RCMGR_DEFAULTS: 1
21
+ defaults:
22
+ run:
23
+ shell: bash
24
+ steps:
25
+ - uses: actions/setup-go@v3
26
+ with:
27
+ go-version: 1.19.1
28
+ - uses: actions/checkout@v3
29
+ - uses: protocol/cache-go-action@v1
30
+ with:
31
+ name: ${{ github.job }}
32
+ - run: make -O test_go_lint
.github/workflows/gotest.yml
new
+65
@@ -0,0 +1,65 @@
1
+name: 'ci/gh-experiment: go test'
2
+
3
+on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - 'master'
9
+
10
+jobs:
11
+ gotest:
12
+ if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
13
+ runs-on: ubuntu-latest
14
+ env:
15
+ TEST_NO_DOCKER: 1
16
+ TEST_NO_FUSE: 1
17
+ TEST_VERBOSE: 1
18
+ TRAVIS: 1
19
+ GIT_PAGER: cat
20
+ IPFS_CHECK_RCMGR_DEFAULTS: 1
21
+ defaults:
22
+ run:
23
+ shell: bash
24
+ steps:
25
+ - uses: actions/setup-go@v3
26
+ with:
27
+ go-version: 1.19.1
28
+ - uses: actions/checkout@v3
29
+ - uses: protocol/cache-go-action@v1
30
+ with:
31
+ name: ${{ github.job }}
32
+ - run: |
33
+ make -j 1 test/unit/gotest.junit.xml &&
34
+ [[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]]
35
+ - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
36
+ if: always()
37
+ with:
38
+ name: unittests
39
+ files: coverage/unit_tests.coverprofile
40
+ - run: |
41
+ # we want to first test with the kubo version in the go.mod file
42
+ go test -v ./...
43
+
44
+ # we also want to test the examples against the current version of kubo
45
+ # however, that version might be in a fork so we need to replace the dependency
46
+
47
+ # backup the go.mod and go.sum files to restore them after we run the tests
48
+ cp go.mod go.mod.bak
49
+ cp go.sum go.sum.bak
50
+
51
+ # make sure the examples run against the current version of kubo
52
+ go mod edit -replace github.com/ipfs/kubo=./../../..
53
+ go mod tidy
54
+
55
+ go test -v ./...
56
+
57
+ # restore the go.mod and go.sum files to their original state
58
+ mv go.mod.bak go.mod
59
+ mv go.sum.bak go.sum
60
+ working-directory: docs/examples/kubo-as-a-library
61
+ - uses: actions/upload-artifact@v3
62
+ with:
63
+ name: unit
64
+ path: test/unit/gotest.junit.xml
65
+ if: always()
.github/workflows/runner.yml
new
+33
@@ -0,0 +1,33 @@
1
+name: 'ci/gh-experiment: choose runner'
2
+
3
+on:
4
+ workflow_call:
5
+ outputs:
6
+ config:
7
+ description: "The runner's configuration"
8
+ value: ${{ jobs.choose.outputs.config }}
9
+
10
+jobs:
11
+ choose:
12
+ runs-on: ubuntu-latest
13
+ outputs:
14
+ config: ${{ steps.config.outputs.result }}
15
+ steps:
16
+ - uses: actions/github-script@v6
17
+ id: config
18
+ with:
19
+ script: |
20
+ if (`${context.repo.owner}/${context.repo.repo}` === 'ipfs/kubo') {
21
+ return {
22
+ labels: ['self-hosted', 'linux', 'x64', 'kubo'],
23
+ parallel: 10,
24
+ aws: true
25
+ }
26
+ } else {
27
+ return {
28
+ labels: ['ubuntu-latest'],
29
+ parallel: 3,
30
+ aws: false
31
+ }
32
+ }
33
+ - run: echo ${{ steps.config.outputs.result }}
.github/workflows/sharness.yml
new
+124
@@ -0,0 +1,124 @@
1
+name: 'ci/gh-experiment: sharness'
2
+
3
+on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - 'master'
9
+
10
+jobs:
11
+ runner:
12
+ if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
13
+ uses: ipfs/kubo/.github/workflows/runner.yml@ci/move-to-github-actions # TODO: change to master
14
+ sharness:
15
+ needs: [runner]
16
+ runs-on: ${{ fromJSON(needs.runner.outputs.config).labels }}
17
+ defaults:
18
+ run:
19
+ shell: bash
20
+ steps:
21
+ - name: Setup Go
22
+ uses: actions/setup-go@v3
23
+ with:
24
+ go-version: 1.19.1
25
+ - name: Checkout Kubo
26
+ uses: actions/checkout@v3
27
+ with:
28
+ path: kubo
29
+ - name: Install missing tools
30
+ run: sudo apt install -y socat net-tools fish libxml2-utils
31
+ - name: Checkout IPFS Pinning Service API
32
+ uses: actions/checkout@v3
33
+ with:
34
+ repository: ipfs-shipyard/rb-pinning-service-api
35
+ ref: 773c3adbb421c551d2d89288abac3e01e1f7c3a8
36
+ path: rb-pinning-service-api
37
+ # TODO: check if docker compose (not docker-compose) is available on default gh runners
38
+ - name: Start IPFS Pinning Service API
39
+ run: |
40
+ (for i in {1..3}; do docker compose pull && break || sleep 5; done) &&
41
+ docker compose up -d
42
+ working-directory: rb-pinning-service-api
43
+ - name: Restore Go Cache
44
+ uses: protocol/cache-go-action@v1
45
+ with:
46
+ name: ${{ github.job }}
47
+ - name: Find IPFS Pinning Service API address
48
+ run: echo "TEST_DOCKER_HOST=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')" >> $GITHUB_ENV
49
+ - uses: actions/cache@v3
50
+ with:
51
+ path: test/sharness/lib/dependencies
52
+ key: ${{ runner.os }}-test-generate-junit-html-${{ hashFiles('test/sharness/lib/test-generate-junit-html.sh') }}
53
+ - name: Run Sharness tests
54
+ run: |
55
+ make -O -j "$PARALLEL" \
56
+ test_sharness \
57
+ coverage/sharness_tests.coverprofile \
58
+ test/sharness/test-results/sharness.xml \
59
+ test/sharness/test-results/sharness.html \
60
+ test/sharness/test-results/sharness-html
61
+ working-directory: kubo
62
+ env:
63
+ TEST_NO_DOCKER: 0
64
+ TEST_NO_PLUGIN: 1
65
+ TEST_NO_FUSE: 1
66
+ TEST_VERBOSE: 1
67
+ TEST_JUNIT: 1
68
+ TEST_EXPENSIVE: 1
69
+ IPFS_CHECK_RCMGR_DEFAULTS: 1
70
+ CONTINUE_ON_S_FAILURE: 1
71
+ PARALLEL: ${{ fromJSON(needs.runner.outputs.config).parallel }}
72
+ - name: Upload coverage report
73
+ uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
74
+ if: failure() || success()
75
+ with:
76
+ name: sharness
77
+ files: kubo/coverage/sharness_tests.coverprofile
78
+ - name: Aggregate results
79
+ run: find kubo/test/sharness/test-results -name 't*-*.sh.*.counts' | kubo/test/sharness/lib/sharness/aggregate-results.sh > kubo/test/sharness/test-results/summary.txt
80
+ - name: 👉️ If this step failed, go to «Summary» (top left) → «HTML Report» → inspect the «Failures» column
81
+ run: |
82
+ cat kubo/test/sharness/test-results/summary.txt &&
83
+ grep 'failed\s*0' kubo/test/sharness/test-results/summary.txt
84
+ - name: Add aggregate results to the summary
85
+ if: failure() || success()
86
+ run: |
87
+ echo "# Summary" >> $GITHUB_STEP_SUMMARY
88
+ echo >> $GITHUB_STEP_SUMMARY
89
+ cat kubo/test/sharness/test-results/summary.txt >> $GITHUB_STEP_SUMMARY
90
+ - name: Upload one-page HTML report to S3
91
+ id: one-page
92
+ uses: pl-strflt/tf-aws-gh-runner/.github/actions/upload-artifact@main
93
+ if: fromJSON(needs.runner.outputs.config).aws && (failure() || success())
94
+ with:
95
+ source: kubo/test/sharness/test-results/sharness.html
96
+ destination: sharness.html
97
+ - name: Upload one-page HTML report
98
+ if: (! fromJSON(needs.runner.outputs.config).aws) && (failure() || success())
99
+ uses: actions/upload-artifact@v3
100
+ with:
101
+ name: sharness.html
102
+ path: kubo/test/sharness/test-results/sharness.html
103
+ - name: Upload full HTML report to S3
104
+ id: full
105
+ uses: pl-strflt/tf-aws-gh-runner/.github/actions/upload-artifact@main
106
+ if: fromJSON(needs.runner.outputs.config).aws && (failure() || success())
107
+ with:
108
+ source: kubo/test/sharness/test-results/sharness-html
109
+ destination: sharness-html/
110
+ - name: Upload full HTML report
111
+ if: (! fromJSON(needs.runner.outputs.config).aws) && (failure() || success())
112
+ uses: actions/upload-artifact@v3
113
+ with:
114
+ name: sharness-html
115
+ path: kubo/test/sharness/test-results/sharness-html
116
+ - name: Add S3 links to the summary
117
+ if: fromJSON(needs.runner.outputs.config).aws && (failure() || success())
118
+ run: echo "$MD" >> $GITHUB_STEP_SUMMARY
119
+ env:
120
+ MD: |
121
+ # HTML Reports
122
+
123
+ - View the [one page HTML report](${{ steps.one-page.outputs.url }})
124
+ - View the [full HTML report](${{ steps.full.outputs.url }}index.html)
Rules.mk
+1
-2
@@ -136,8 +136,7 @@ help:
136
@echo ' test_go_expensive - Run all go tests and compile on all platforms'
137
@echo ' test_go_race - Run go tests with the race detector enabled'
138
@echo ' test_go_lint - Run the `golangci-lint` vetting tool'
139
- @echo ' test_sharness_short - Run short sharness tests'
140
- @echo ' test_sharness_expensive - Run all sharness tests'
139
+ @echo ' test_sharness - Run sharness tests'
140
@echo ' coverage - Collects coverage info from unit tests and sharness'
141
@echo
142
.PHONY: help
appveyor.yml
+9
-9
@@ -14,8 +14,8 @@ environment:
14
GOPATH: c:\gopath
15
TEST_VERBOSE: 1
16
#TEST_NO_FUSE: 1
17
- #TEST_SUITE: test_sharness_expensive
18
- #GOFLAGS: -tags nofuse
17
+ #TEST_SUITE: test_sharness
18
+ #GOFLAGS: -tags nofuse
19
global:
20
BASH: C:\cygwin\bin\bash
21
matrix:
@@ -23,27 +23,27 @@ environment:
23
GOVERSION: 1.5.1
24
GOROOT: c:\go
25
DOWNLOADPLATFORM: "x64"
26
-
26
+
27
install:
28
# Enable make
29
#- SET PATH=c:\MinGW\bin;%PATH%
30
#- copy c:\MinGW\bin\mingw32-make.exe c:\MinGW\bin\make.exe
31
- go version
32
- go env
33
-
33
+
34
# Cygwin build script
35
#
36
# NOTES:
37
#
38
# The stdin/stdout file descriptor appears not to be valid for the Appveyor
39
-# build which causes failures as certain functions attempt to redirect
39
+# build which causes failures as certain functions attempt to redirect
40
# default file handles. Ensure a dummy file descriptor is opened with 'exec'.
41
-#
41
+#
42
build_script:
43
- '%BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0</dev/null; export PATH=$GOPATH/bin:$PATH; make nofuse"'
44
-
44
+
45
test_script:
46
- - '%BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0</dev/null; export PATH=$GOPATH/bin:$PATH; export GOFLAGS=''-tags nofuse''; export TEST_NO_FUSE=1; export TEST_VERBOSE=1; export TEST_SUITE=test_sharness_expensive; make $TEST_SUITE"'
47
-
46
+ - '%BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0</dev/null; export PATH=$GOPATH/bin:$PATH; export GOFLAGS=''-tags nofuse''; export TEST_NO_FUSE=1; export TEST_VERBOSE=1; export TEST_EXPENSIVE=1; export TEST_SUITE=test_sharness; make $TEST_SUITE"'
47
+
48
#build:
49
# parallel: true
codecov.yml
+1
@@ -4,6 +4,7 @@ codecov:
4
- "!travis-ci.org"
5
- "!ci.ipfs.team:8111"
6
- "!ci.ipfs.team"
7
+ - "!github.com"
8
notify:
9
require_ci_to_pass: no
10
after_n_builds: 2
coverage/Rules.mk
+1
-1
@@ -46,7 +46,7 @@ endif
46
export IPFS_COVER_DIR:= $(realpath $(d))/sharnesscover/
47
48
$(d)/sharness_tests.coverprofile: export TEST_NO_PLUGIN=1
49
-$(d)/sharness_tests.coverprofile: $(d)/ipfs cmd/ipfs/ipfs-test-cover $(d)/coverage_deps test_sharness_short
49
+$(d)/sharness_tests.coverprofile: $(d)/ipfs cmd/ipfs/ipfs-test-cover $(d)/coverage_deps test_sharness
50
(cd $(@D)/sharnesscover && find . -type f | gocovmerge -list -) > $@
51
52
test/sharness/.gitignore
+9
@@ -1,5 +1,14 @@
1
+# symlinks to lib/sharness
2
+/sharness.sh
3
+/lib-sharness
4
+# clone of sharness
5
lib/sharness/
6
+# deps downloaded by lib/*.sh scripts
7
+lib/dependencies/
8
+# sharness files
9
test-results/
10
trash directory.*.sh/
11
+# makefile files
12
plugins
13
+# macos files
14
*.DS_Store
test/sharness/README.md
+1
-1
@@ -1,4 +1,4 @@
1
-# ipfs whole tests using the [sharness framework](https://github.com/mlafeldt/sharness/)
1
+# ipfs whole tests using the [sharness framework](https://github.com/pl-strflt/sharness/tree/feat/junit)
2
3
## Running all the tests
4
test/sharness/Rules.mk
+16
-12
@@ -42,10 +42,20 @@ $(d)/aggregate: $(T_$(d))
42
@(cd $(@D) && ./lib/test-aggregate-results.sh)
43
.PHONY: $(d)/aggregate
44
45
-$(d)/test-results/sharness.xml: export TEST_GENERATE_JUNIT=1
46
-$(d)/test-results/sharness.xml: test_sharness_expensive
45
+$(d)/test-results/sharness.xml: $(T_$(d))
46
@echo "*** $@ ***"
48
- @(cd $(@D)/.. && ./lib/gen-junit-report.sh)
47
+ @(cd $(@D)/.. && ./lib/test-aggregate-junit-reports.sh)
48
+.PHONY: $(d)/test-results/sharness.xml
49
+
50
+$(d)/test-results/sharness-html: $(d)/test-results/sharness.xml
51
+ @echo "*** $@ ***"
52
+ @(cd $(@D)/.. && ./lib/test-generate-junit-html.sh frames)
53
+.PHONY: $(d)/test-results/sharness-html
54
+
55
+$(d)/test-results/sharness.html: $(d)/test-results/sharness.xml
56
+ @echo "*** $@ ***"
57
+ @(cd $(@D)/.. && ./lib/test-generate-junit-html.sh no-frames)
58
+.PHONY: $(d)/test-results/sharness.html
59
60
$(d)/clean-test-results:
61
rm -rf $(@D)/test-results
@@ -62,16 +72,10 @@ $(d)/deps: $(SHARNESS_$(d)) $$(DEPS_$(d)) # use second expansion so coverage can
72
test_sharness_deps: $(d)/deps
73
.PHONY: test_sharness_deps
74
65
-test_sharness_short: $(d)/aggregate
66
-.PHONY: test_sharness_short
67
-
68
-
69
-test_sharness_expensive: export TEST_EXPENSIVE=1
70
-test_sharness_expensive: test_sharness_short
71
-.PHONY: test_sharness_expensive
75
+test_sharness: $(d)/aggregate
76
+.PHONY: test_sharness
77
73
-TEST += test_sharness_expensive
74
-TEST_SHORT += test_sharness_short
78
+TEST += test_sharness
79
80
81
include mk/footer.mk
test/sharness/lib/0001-Generate-partial-JUnit-reports.patch
deleted
-249
@@ -1,250 +0,0 @@
1
-From bc6bf844ef4e4cd468bc1ec96f2d6af738eb8d2f Mon Sep 17 00:00:00 2001
2
-From: =?UTF-8?q?=C5=81ukasz=20Magiera?= <magik6k@gmail.com>
3
-Date: Sat, 21 Apr 2018 22:01:45 +0200
4
-Subject: [PATCH] Generate partial JUnit reports
5
-
6
----
7
- sharness.sh | 114 +++++++++++++++++++++++++++++++++++++++++++++++++---
8
- 1 file changed, 108 insertions(+), 6 deletions(-)
9
-
10
-diff --git a/sharness.sh b/sharness.sh
11
-index 6750ff7..336e426 100644
12
---- a/sharness.sh
13
-+++ b/sharness.sh
14
-@@ -1,4 +1,4 @@
15
--#!/bin/sh
16
-+#!/usr/bin/env bash
17
- #
18
- # Copyright (c) 2011-2012 Mathias Lafeldt
19
- # Copyright (c) 2005-2012 Git project
20
-@@ -106,6 +106,10 @@ if test -n "$color"; then
21
- test -n "$quiet" && return;;
22
- esac
23
- shift
24
-+
25
-+ if test -n "$TEST_GENERATE_JUNIT"; then
26
-+ echo "$*" >> .junit/tout
27
-+ fi
28
- printf "%s" "$*"
29
- tput sgr0
30
- echo
31
-@@ -115,6 +119,10 @@ else
32
- say_color() {
33
- test -z "$1" && test -n "$quiet" && return
34
- shift
35
-+
36
-+ if test -n "$TEST_GENERATE_JUNIT"; then
37
-+ echo "$*" >> .junit/tout
38
-+ fi
39
- printf "%s\n" "$*"
40
- }
41
- fi
42
-@@ -129,6 +137,12 @@ say() {
43
- say_color info "$*"
44
- }
45
-
46
-+esc=$(printf '\033')
47
-+
48
-+esc_xml() {
49
-+ sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"$esc"'//g; s///g;'
50
-+}
51
-+
52
- test -n "$test_description" || error "Test script did not set test_description."
53
-
54
- if test "$help" = "t"; then
55
-@@ -251,30 +265,78 @@ test_have_prereq() {
56
- test $total_prereq = $ok_prereq
57
- }
58
-
59
-+# junit_testcase generates a testcase xml file after each test
60
-+
61
-+junit_testcase() {
62
-+ if test -z "$TEST_GENERATE_JUNIT"; then
63
-+ return
64
-+ fi
65
-+
66
-+ test_name=$1
67
-+ tc_file=".junit/case-$(printf "%04d" $test_count)"
68
-+ time_sec="$(cat .junit/time | xargs printf '%04d' | sed -e 's/\(...\)$/.\1/g')"
69
-+
70
-+ echo "$(expr $(cat .junit/time_total) + $(cat .junit/time) )" > .junit/time_total
71
-+
72
-+ shift
73
-+ cat > "$tc_file" <<-EOF
74
-+ <testcase name="$test_count - $(echo $test_name | esc_xml)" classname="sharness$(uname -s).${SHARNESS_TEST_NAME}" time="${time_sec}">
75
-+ $@
76
-+ EOF
77
-+
78
-+ if test -f .junit/tout; then
79
-+ cat >> "$tc_file" <<-EOF
80
-+ <system-out>
81
-+ $(cat .junit/tout | esc_xml)
82
-+ </system-out>
83
-+ EOF
84
-+ fi
85
-+
86
-+ if test -f .junit/terr; then
87
-+ cat >> "$tc_file" <<-EOF
88
-+ <system-err>
89
-+ $(cat .junit/terr | esc_xml)
90
-+ </system-err>
91
-+ EOF
92
-+ fi
93
-+
94
-+ echo "</testcase>" >> "$tc_file"
95
-+ rm -f .junit/tout .junit/terr .junit/time
96
-+}
97
-+
98
- # You are not expected to call test_ok_ and test_failure_ directly, use
99
- # the text_expect_* functions instead.
100
-
101
- test_ok_() {
102
- test_success=$(($test_success + 1))
103
- say_color "" "ok $test_count - $@"
104
-+
105
-+ junit_testcase "$@"
106
- }
107
-
108
- test_failure_() {
109
- test_failure=$(($test_failure + 1))
110
- say_color error "not ok $test_count - $1"
111
-+ test_name=$1
112
- shift
113
- echo "$@" | sed -e 's/^/# /'
114
-+ junit_testcase "$test_name" '<failure type="">'$(echo $@ | esc_xml)'</failure>'
115
-+
116
- test "$immediate" = "" || { EXIT_OK=t; exit 1; }
117
- }
118
-
119
- test_known_broken_ok_() {
120
- test_fixed=$(($test_fixed + 1))
121
- say_color error "ok $test_count - $@ # TODO known breakage vanished"
122
-+
123
-+ junit_testcase "$@" '<failure type="known breakage vanished"/>'
124
- }
125
-
126
- test_known_broken_failure_() {
127
- test_broken=$(($test_broken + 1))
128
- say_color warn "not ok $test_count - $@ # TODO known breakage"
129
-+
130
-+ junit_testcase "$@"
131
- }
132
-
133
- # Public: Execute commands in debug mode.
134
-@@ -310,15 +372,25 @@ test_pause() {
135
- test_eval_() {
136
- # This is a separate function because some tests use
137
- # "return" to end a test_expect_success block early.
138
-- eval </dev/null >&3 2>&4 "$*"
139
-+ if test -n "$TEST_GENERATE_JUNIT"; then
140
-+ eval </dev/null > >(tee -a .junit/tout >&3) 2> >(tee -a .junit/terr >&4) "$*"
141
-+ else
142
-+ eval </dev/null >&3 2>&4 "$*"
143
-+ fi
144
- }
145
-
146
- test_run_() {
147
- test_cleanup=:
148
- expecting_failure=$2
149
-+
150
-+ start_time_ms=$(date "+%s%3N");
151
- test_eval_ "$1"
152
- eval_ret=$?
153
-
154
-+ if test -n "$TEST_GENERATE_JUNIT"; then
155
-+ echo $(expr $(date "+%s%3N") - ${start_time_ms} ) > .junit/time;
156
-+ fi
157
-+
158
- if test "$chain_lint" = "t"; then
159
- test_eval_ "(exit 117) && $1"
160
- if test "$?" != 117; then
161
-@@ -355,8 +427,18 @@ test_skip_() {
162
- of_prereq=" of $test_prereq"
163
- fi
164
-
165
-- say_color skip >&3 "skipping test: $@"
166
-- say_color skip "ok $test_count # skip $1 (missing $missing_prereq${of_prereq})"
167
-+ say_color skip >&3 "skipping test: $1"
168
-+ say_color skip "ok $test_count # skip $1 (missing $missing_prereqm${of_prereq})"
169
-+
170
-+ if test -n "$TEST_GENERATE_JUNIT"; then
171
-+ cat > ".junit/case-$(printf "%04d" $test_count)" <<-EOF
172
-+ <testcase name="$test_count - $(echo $2 | esc_xml)" classname="sharness$(uname -s).${SHARNESS_TEST_NAME}" time="0">
173
-+ <skipped>
174
-+ skip $(echo $1 | esc_xml) (missing $missing_prereq${of_prereq})
175
-+ </skipped>
176
-+ </testcase>
177
-+ EOF
178
-+ fi
179
- : true
180
- ;;
181
- *)
182
-@@ -403,7 +485,7 @@ test_expect_success() {
183
- test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
184
- test "$#" = 2 || error "bug in the test script: not 2 or 3 parameters to test_expect_success"
185
- export test_prereq
186
-- if ! test_skip_ "$@"; then
187
-+ if ! test_skip_ "$@" "$1"; then
188
- say >&3 "expecting success: $2"
189
- if test_run_ "$2"; then
190
- test_ok_ "$1"
191
-@@ -442,7 +524,7 @@ test_expect_failure() {
192
- test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
193
- test "$#" = 2 || error "bug in the test script: not 2 or 3 parameters to test_expect_failure"
194
- export test_prereq
195
-- if ! test_skip_ "$@"; then
196
-+ if ! test_skip_ "$@" "$1"; then
197
- say >&3 "checking known breakage: $2"
198
- if test_run_ "$2" expecting_failure; then
199
- test_known_broken_ok_ "$1"
200
-@@ -675,6 +757,7 @@ test_done() {
201
- test_results_dir="$SHARNESS_TEST_DIRECTORY/test-results"
202
- mkdir -p "$test_results_dir"
203
- test_results_path="$test_results_dir/${SHARNESS_TEST_FILE%.$SHARNESS_TEST_EXTENSION}.$$.counts"
204
-+ junit_results_path="$test_results_dir/${SHARNESS_TEST_FILE%.$SHARNESS_TEST_EXTENSION}.$$.xml.part"
205
-
206
- cat >>"$test_results_path" <<-EOF
207
- total $test_count
208
-@@ -684,6 +767,16 @@ test_done() {
209
- failed $test_failure
210
-
211
- EOF
212
-+
213
-+ if test -n "$TEST_GENERATE_JUNIT"; then
214
-+ time_sec="$(cat .junit/time_total | xargs printf "%04d" | sed -e 's/\(...\)$/.\1/g')"
215
-+
216
-+ cat >>"$junit_results_path" <<-EOF
217
-+ <testsuite errors="$test_broken" failures="$((test_failure+test_fixed))" tests="$test_count" package="sharness$(uname -s).${SHARNESS_TEST_NAME}" time="${time_sec}">
218
-+ $(find .junit -name 'case-*' | sort | xargs cat)
219
-+ </testsuite>
220
-+ EOF
221
-+ fi
222
- fi
223
-
224
- if test "$test_fixed" != 0; then
225
-@@ -745,6 +838,9 @@ export PATH SHARNESS_BUILD_DIRECTORY
226
- SHARNESS_TEST_FILE="$0"
227
- export SHARNESS_TEST_FILE
228
-
229
-+SHARNESS_TEST_NAME=$(basename ${SHARNESS_TEST_FILE} ".sh")
230
-+export SHARNESS_TEST_NAME
231
-+
232
- # Prepare test area.
233
- test_dir="trash directory.$(basename "$SHARNESS_TEST_FILE" ".$SHARNESS_TEST_EXTENSION")"
234
- test -n "$root" && test_dir="$root/$test_dir"
235
-@@ -771,6 +867,12 @@ mkdir -p "$test_dir" || exit 1
236
- # in subprocesses like git equals our $PWD (for pathname comparisons).
237
- cd -P "$test_dir" || exit 1
238
-
239
-+# Prepare JUnit report dir
240
-+if test -n "$TEST_GENERATE_JUNIT"; then
241
-+ mkdir -p .junit
242
-+ echo 0 > .junit/time_total
243
-+fi
244
-+
245
- this_test=${SHARNESS_TEST_FILE##*/}
246
- this_test=${this_test%.$SHARNESS_TEST_EXTENSION}
247
- for skp in $SKIP_TESTS; do
248
-2.17.0
249
-
test/sharness/lib/gen-junit-report.sh
deleted
-8
@@ -1,8 +0,0 @@
1
-#!/usr/bin/env bash
2
-
3
-cat > test-results/sharness.xml <<-EOF
4
-<?xml version="1.1" encoding="UTF-8"?>
5
-<testsuites name="sharness">
6
- $(find test-results -name '*.xml.part' | sort | xargs cat)
7
-</testsuites>
8
-EOF
test/sharness/lib/install-sharness.sh
+27
-37
@@ -1,60 +1,50 @@
1
#!/bin/sh
2
# install sharness.sh
3
#
4
-# Copyright (c) 2014 Juan Batiz-Benet
4
+# Copyright (c) 2014, 2022 Juan Batiz-Benet, Piotr Galar
5
# MIT Licensed; see the LICENSE file in this repository.
6
#
7
8
-# settings
9
-version=5eee9b51b5621cec95a64018f0cc779963b230d2
10
-patch_version=17
8
+gitrepo=pl-strflt/sharness
9
+githash=803df39d3cba16bb7d493dd6cd8bc5e29826da61
10
12
-urlprefix=https://github.com/mlafeldt/sharness.git
11
if test ! -n "$clonedir" ; then
12
clonedir=lib
13
fi
14
sharnessdir=sharness
17
-
18
-if test -f "$clonedir/$sharnessdir/SHARNESS_VERSION_${version}_p${patch_version}"
19
-then
20
- # There is the right version file. Great, we are done!
21
- exit 0
22
-fi
15
+gitdir="$clonedir/$sharnessdir/.git"
16
17
die() {
18
echo >&2 "$@"
19
exit 1
20
}
21
29
-apply_patches() {
30
- git config --local user.email "noone@nowhere"
31
- git config --local user.name "No One"
32
- git am ../0001-Generate-partial-JUnit-reports.patch
22
+if test -d "$clonedir/$sharnessdir"; then
23
+ giturl="git@github.com:${gitrepo}.git"
24
+ echo "Checking if $giturl is already cloned (and if its origin is correct)"
25
+ if ! test -d "$gitdir" || test "$(git --git-dir "$gitdir" remote get-url origin)" != "$giturl"; then
26
+ echo "Removing $clonedir/$sharnessdir"
27
+ rm -rf "$clonedir/$sharnessdir" || die "Could not remove $clonedir/$sharnessdir"
28
+ fi
29
+fi
30
34
- touch "SHARNESS_VERSION_${version}_p${patch_version}" || die "Could not create 'SHARNESS_VERSION_${version}_p${patch_version}'"
35
-}
31
+if ! test -d "$clonedir/$sharnessdir"; then
32
+ giturl="https://github.com/${gitrepo}.git"
33
+ echo "Cloning $giturl into $clonedir/$sharnessdir"
34
+ git clone "$giturl" "$clonedir/$sharnessdir" || die "Could not clone $giturl into $clonedir/$sharnessdir"
35
+fi
36
37
-checkout_version() {
38
- git checkout "$version" || die "Could not checkout '$version'"
39
- rm -f SHARNESS_VERSION_* || die "Could not remove 'SHARNESS_VERSION_*'"
40
- echo "Sharness version $version is checked out!"
37
42
- apply_patches
43
-}
38
+echo "Changing directory to $clonedir/$sharnessdir"
39
+cd "$clonedir/$sharnessdir" || die "Could not cd into '$clonedir/$sharnessdir' directory"
40
45
-if test -d "$clonedir/$sharnessdir/.git"
46
-then
47
- # We need to update sharness!
48
- cd "$clonedir/$sharnessdir" || die "Could not cd into '$clonedir/$sharnessdir' directory"
49
- git fetch || die "Could not fetch to update sharness"
50
- checkout_version
51
-else
52
- # We need to clone sharness!
53
- mkdir -p "$clonedir" || die "Could not create '$clonedir' directory"
54
- cd "$clonedir" || die "Could not cd into '$clonedir' directory"
55
-
56
- git clone "$urlprefix" || die "Could not clone '$urlprefix'"
57
- cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory"
58
- checkout_version
41
+echo "Checking if $githash is already fetched"
42
+if ! git show "$githash" >/dev/null 2>&1; then
43
+ echo "Fetching $githash"
44
+ git fetch origin "$githash" || die "Could not fetch $githash"
45
fi
46
+
47
+echo "Resetting to $githash"
48
+git reset --hard "$githash" || die "Could not reset to $githash"
49
+
50
exit 0
test/sharness/lib/test-aggregate-junit-reports.sh
new
+17
@@ -0,0 +1,17 @@
1
+#!/bin/sh
2
+#
3
+# Script to aggregate results using Sharness
4
+#
5
+# Copyright (c) 2014, 2022 Christian Couder, Piotr Galar
6
+# MIT Licensed; see the LICENSE file in this repository.
7
+#
8
+
9
+SHARNESS_AGGREGATE_JUNIT="lib/sharness/aggregate-junit-reports.sh"
10
+
11
+test -f "$SHARNESS_AGGREGATE_JUNIT" || {
12
+ echo >&2 "Cannot find: $SHARNESS_AGGREGATE_JUNIT"
13
+ echo >&2 "Please check Sharness installation."
14
+ exit 1
15
+}
16
+
17
+ls test-results/t*-*.sh.*.xml.part | "$SHARNESS_AGGREGATE_JUNIT" > test-results/sharness.xml
test/sharness/lib/test-generate-junit-html.sh
new
+58
@@ -0,0 +1,58 @@
1
+#!/bin/bash
2
+
3
+dependencies=(
4
+ "url=https://sourceforge.net/projects/saxon/files/Saxon-HE/11/Java/SaxonHE11-4J.zip;md5=8a4783d307c32c898f8995b8f337fd6b"
5
+ "url=https://raw.githubusercontent.com/pl-strflt/ant/c781f7d79b92cc55530245d9554682a47f46851e/src/etc/junit-frames-saxon.xsl;md5=6eb013566903a91e4959413f6ff144d0"
6
+ "url=https://raw.githubusercontent.com/pl-strflt/ant/c781f7d79b92cc55530245d9554682a47f46851e/src/etc/junit-noframes-saxon.xsl;md5=8d54882d5f9d32a7743ec675cc2e30ac"
7
+)
8
+
9
+dependenciesdir="lib/dependencies"
10
+mkdir -p "$dependenciesdir"
11
+
12
+get_md5() {
13
+ md5sum "$1" | cut -d ' ' -f 1
14
+}
15
+
16
+for dependency in "${dependencies[@]}"; do
17
+ url="$(echo "$dependency" | cut -d ';' -f 1 | cut -d '=' -f 2)"
18
+ md5="$(echo "$dependency" | cut -d ';' -f 2 | cut -d '=' -f 2)"
19
+ filename="$(basename "$url")"
20
+ if test -f "$dependenciesdir/$filename" && test "$(get_md5 "$dependenciesdir/$filename")" = "$md5"; then
21
+ echo "Using cached $filename"
22
+ else
23
+ echo "Downloading $filename"
24
+ curl -L --max-redirs 5 --retry 5 --no-progress-meter --output "$dependenciesdir/$filename" "$url"
25
+ actual_md5="$(get_md5 "$dependenciesdir/$filename")"
26
+ if test "$actual_md5" != "$md5"; then
27
+ echo "Downloaded $filename has wrong md5sum ('$actual_md5' != '$md5')"
28
+ exit 1
29
+ fi
30
+ dirname=${filename%.*}
31
+ extension=${filename#$dirname.}
32
+ if test "$extension" = "zip"; then
33
+ echo "Removing old $dependenciesdir/$dirname"
34
+ rm -rf "$dependenciesdir/$dirname"
35
+ echo "Unzipping $dependenciesdir/$filename"
36
+ unzip "$dependenciesdir/$filename" -d "$dependenciesdir/$dirname"
37
+ fi
38
+ fi
39
+done
40
+
41
+case "$1" in
42
+ "frames")
43
+ java -jar lib/dependencies/SaxonHE11-4J/saxon-he-11.4.jar \
44
+ -s:test-results/sharness.xml \
45
+ -xsl:lib/dependencies/junit-frames-saxon.xsl \
46
+ output.dir=$(pwd)/test-results/sharness-html
47
+ ;;
48
+ "no-frames")
49
+ java -jar lib/dependencies/SaxonHE11-4J/saxon-he-11.4.jar \
50
+ -s:test-results/sharness.xml \
51
+ -xsl:lib/dependencies/junit-noframes-saxon.xsl \
52
+ -o:test-results/sharness.html
53
+ ;;
54
+ *)
55
+ echo "Usage: $0 [frames|no-frames]"
56
+ exit 1
57
+ ;;
58
+esac
test/sharness/lib/test-lib.sh
+12
-5
@@ -3,7 +3,7 @@
3
# Copyright (c) 2014 Christian Couder
4
# MIT Licensed; see the LICENSE file in this repository.
5
#
6
-# We are using sharness (https://github.com/mlafeldt/sharness)
6
+# We are using sharness (https://github.com/pl-strflt/sharness/tree/feat/junit)
7
# which was extracted from the Git test framework.
8
9
# use the ipfs tool to test against
@@ -27,14 +27,17 @@ fi
27
# to pass through in some cases.
28
test "$TEST_VERBOSE" = 1 && verbose=t
29
test "$TEST_IMMEDIATE" = 1 && immediate=t
30
+test "$TEST_JUNIT" = 1 && junit=t
31
+test "$TEST_NO_COLOR" = 1 && no_color=t
32
# source the common hashes first.
33
. lib/test-lib-hashes.sh
34
35
34
-SHARNESS_LIB="lib/sharness/sharness.sh"
36
+ln -sf lib/sharness/sharness.sh .
37
+ln -sf lib/sharness/lib-sharness .
38
36
-. "$SHARNESS_LIB" || {
37
- echo >&2 "Cannot source: $SHARNESS_LIB"
39
+. "sharness.sh" || {
40
+ echo >&2 "Cannot source: sharness.sh"
41
echo >&2 "Please check Sharness installation."
42
exit 1
43
}
@@ -106,10 +109,15 @@ expr "$TEST_OS" : "CYGWIN_NT" >/dev/null || test_set_prereq STD_ERR_MSG
109
110
if test "$TEST_VERBOSE" = 1; then
111
echo '# TEST_VERBOSE='"$TEST_VERBOSE"
112
+ echo '# TEST_IMMEDIATE='"$TEST_IMMEDIATE"
113
echo '# TEST_NO_FUSE='"$TEST_NO_FUSE"
114
+ echo '# TEST_NO_DOCKER='"$TEST_NO_DOCKER"
115
echo '# TEST_NO_PLUGIN='"$TEST_NO_PLUGIN"
116
echo '# TEST_EXPENSIVE='"$TEST_EXPENSIVE"
117
echo '# TEST_OS='"$TEST_OS"
118
+ echo '# TEST_JUNIT='"$TEST_JUNIT"
119
+ echo '# TEST_NO_COLOR='"$TEST_NO_COLOR"
120
+ echo '# TEST_ULIMIT_PRESET='"$TEST_ULIMIT_PRESET"
121
fi
122
123
# source our generic test lib
@@ -541,4 +549,3 @@ purge_blockstore() {
549
[[ -z "$( ipfs repo gc )" ]]
550
'
551
}
544
-
test/sharness/t0110-gateway.sh
+2
-2
@@ -121,14 +121,14 @@ test_expect_success "GET invalid IPNS root returns 400 (Bad Request)" '
121
test_curl_resp_http_code "http://127.0.0.1:$port/ipns/QmInvalid/pleaseDontAddMe" "HTTP/1.1 400 Bad Request"
122
'
123
124
-test_expect_failure "GET IPNS path succeeds" '
124
+test_expect_success "GET IPNS path succeeds" '
125
ipfs name publish --allow-offline "$HASH" &&
126
PEERID=$(ipfs config Identity.PeerID) &&
127
test_check_peerid "$PEERID" &&
128
curl -sfo actual "http://127.0.0.1:$port/ipns/$PEERID"
129
'
130
131
-test_expect_failure "GET IPNS path output looks good" '
131
+test_expect_success "GET IPNS path output looks good" '
132
test_cmp expected actual
133
'
134
test/sharness/t0118-gateway-car.sh
+1
-1
@@ -111,7 +111,7 @@ test_launch_ipfs_daemon_without_network
111
'
112
113
test_expect_success "GET for application/vnd.ipld.car with query filename includes Content-Disposition with custom filename" '
114
- curl -svX GET -H "Accept: application/vnd.ipld.car" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT_DIR_CID/subdir/ascii.txt?filename=foobar.car" > curl_output_filename 2>&1 &&
114
+ curl -svX GET -H "Accept: application/vnd.ipld.car" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT_DIR_CID/subdir/ascii.txt?filename=foobar.car" >/dev/null 2>curl_output_filename &&
115
cat curl_output_filename &&
116
grep "< Content-Disposition: attachment\; filename=\"foobar.car\"" curl_output_filename
117
'
test/sharness/t0125-twonode.sh
+6
@@ -72,6 +72,12 @@ flaky_advanced_test() {
72
test_expect_success "shut down nodes" '
73
iptb stop && iptb_wait_stop
74
'
75
+
76
+ # NOTE: data transferred stats checks are flaky
77
+ # trying to debug them by printing out the stats hides the flakiness
78
+ # my theory is that the extra time cat calls take to print out the stats
79
+ # allow for proper cleanup to happen
80
+ go-sleep 1s
81
}
82
83
run_advanced_test() {
test/sharness/t0160-resolve.sh
+5
-37
@@ -35,15 +35,6 @@ test_resolve_setup_name() {
35
'
36
}
37
38
-test_resolve_setup_name_fail() {
39
- local key="$1"
40
- local ref="$2"
41
-
42
- test_expect_failure "resolve: prepare $key" '
43
- ipfs name publish --key="$key" --allow-offline "$ref"
44
- '
45
-}
46
-
38
test_resolve() {
39
src=$1
40
dst=$2
@@ -129,23 +120,7 @@ test_resolve_cmd_b32() {
120
'
121
}
122
132
-
133
-#todo remove this once the online resolve is fixed
134
-test_resolve_fail() {
135
- src=$1
136
- dst=$2
137
-
138
- test_expect_failure "resolve succeeds: $src" '
139
- ipfs resolve "$src" >actual
140
- '
141
-
142
- test_expect_failure "resolved correctly: $src -> $dst" '
143
- printf "$dst" >expected &&
144
- test_cmp expected actual
145
- '
146
-}
147
-
148
-test_resolve_cmd_fail() {
123
+test_resolve_cmd_success() {
124
test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash"
125
test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash"
126
test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash"
@@ -155,23 +130,16 @@ test_resolve_cmd_fail() {
130
test_resolve "/ipld/$dag_hash/i/j" "/ipld/$dag_hash/i/j"
131
test_resolve "/ipld/$dag_hash/i" "/ipld/$dag_hash/i"
132
158
- # At the moment, publishing _fails_ because we fail to put to the DHT.
159
- # However, resolving succeeds because we resolve the record we put to our own
160
- # node.
161
- #
162
- # We should find a nice way to truly support offline publishing. But this
163
- # behavior isn't terrible.
164
-
165
- test_resolve_setup_name_fail "self" "/ipfs/$a_hash"
133
+ test_resolve_setup_name "self" "/ipfs/$a_hash"
134
test_resolve "/ipns/$self_hash" "/ipfs/$a_hash"
135
test_resolve "/ipns/$self_hash/b" "/ipfs/$b_hash"
136
test_resolve "/ipns/$self_hash/b/c" "/ipfs/$c_hash"
137
170
- test_resolve_setup_name_fail "self" "/ipfs/$b_hash"
138
+ test_resolve_setup_name "self" "/ipfs/$b_hash"
139
test_resolve "/ipns/$self_hash" "/ipfs/$b_hash"
140
test_resolve "/ipns/$self_hash/c" "/ipfs/$c_hash"
141
174
- test_resolve_setup_name_fail "self" "/ipfs/$c_hash"
142
+ test_resolve_setup_name "self" "/ipfs/$c_hash"
143
test_resolve "/ipns/$self_hash" "/ipfs/$c_hash"
144
}
145
@@ -181,7 +149,7 @@ test_resolve_cmd_b32
149
150
# should work online
151
test_launch_ipfs_daemon
184
-test_resolve_cmd_fail
152
+test_resolve_cmd_success
153
test_kill_ipfs_daemon
154
155
test_done
test/sharness/t0300-docker-image.sh
+3
-4
@@ -79,9 +79,9 @@ test_expect_success "check that init script configs were applied" '
79
'
80
81
test_expect_success "simple ipfs add/cat can be run in docker container" '
82
- expected="Hello Worlds" &&
83
- HASH=$(docker_exec "$DOC_ID" "echo $(cat expected) | ipfs add | cut -d' ' -f2") &&
84
- docker_exec "$DOC_ID" "ipfs cat $HASH" >actual &&
82
+ echo "Hello Worlds" | tr -d "[:cntrl:]" > expected &&
83
+ HASH=$(docker_exec "$DOC_ID" "echo $(cat expected) | ipfs add -q" | tr -d "[:cntrl:]") &&
84
+ docker_exec "$DOC_ID" "ipfs cat $HASH" | tr -d "[:cntrl:]" > actual &&
85
test_cmp expected actual
86
'
87
@@ -102,4 +102,3 @@ test_expect_success "stop docker container" '
102
docker_rm "$DOC_ID"
103
docker_rmi "$IMAGE_ID"
104
test_done
105
-