Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 2c23c3e

Browse files
authored
sync: update CI config files (#125)
1 parent 4571136 commit 2c23c3e

File tree

15 files changed

+166
-164
lines changed

15 files changed

+166
-164
lines changed

.github/workflows/go-check.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
env:
1212
RUNGOGENERATE: false
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515
with:
1616
submodules: recursive
17-
- uses: actions/setup-go@v2
17+
- uses: actions/setup-go@v3
1818
with:
19-
go-version: "1.18.x"
19+
go-version: "1.19.x"
2020
- name: Run repo-specific setup
2121
uses: ./.github/actions/go-check-setup
2222
if: hashFiles('./.github/actions/go-check-setup') != ''
@@ -27,7 +27,7 @@ jobs:
2727
echo "RUNGOGENERATE=true" >> $GITHUB_ENV
2828
fi
2929
- name: Install staticcheck
30-
run: go install honnef.co/go/tools/cmd/staticcheck@d7e217c1ff411395475b2971c0824e1e7cc1af98 # 2022.1 (v0.3.0)
30+
run: go install honnef.co/go/tools/cmd/staticcheck@376210a89477dedbe6fdc4484b233998650d7b3c # 2022.1.3 (v0.3.3)
3131
- name: Check that go.mod is tidy
3232
uses: protocol/[email protected]
3333
with:

.github/workflows/go-test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
os: [ "ubuntu", "windows", "macos" ]
13-
go: [ "1.17.x", "1.18.x" ]
13+
go: [ "1.18.x", "1.19.x" ]
1414
env:
1515
COVERAGES: ""
1616
runs-on: ${{ format('{0}-latest', matrix.os) }}
1717
name: ${{ matrix.os }} (go ${{ matrix.go }})
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
with:
2121
submodules: recursive
22-
- uses: actions/setup-go@v2
22+
- uses: actions/setup-go@v3
2323
with:
2424
go-version: ${{ matrix.go }}
2525
- name: Go information
@@ -43,7 +43,7 @@ jobs:
4343
# Use -coverpkg=./..., so that we include cross-package coverage.
4444
# If package ./A imports ./B, and ./A's tests also cover ./B,
4545
# this means ./B's coverage will be significantly higher than 0%.
46-
run: go test -v -coverprofile=module-coverage.txt -coverpkg=./... ./...
46+
run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./...
4747
- name: Run tests (32 bit)
4848
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
4949
uses: protocol/[email protected]
@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
run: |
5454
export "PATH=${{ env.PATH_386 }}:$PATH"
55-
go test -v ./...
55+
go test -v -shuffle=on ./...
5656
- name: Run tests with race detector
5757
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
5858
uses: protocol/[email protected]
@@ -62,7 +62,7 @@ jobs:
6262
shell: bash
6363
run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
6464
- name: Upload coverage to Codecov
65-
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
65+
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
6666
with:
6767
files: '${{ env.COVERAGES }}'
6868
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ require (
6363
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
6464
)
6565

66-
go 1.17
66+
go 1.18

hamt/hamt.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
// wikipedia article is the collapsing of empty shards.
1010
// Given the following tree: ( '[' = shards, '{' = values )
1111
// [ 'A' ] -> [ 'B' ] -> { "ABC" }
12-
// | L-> { "ABD" }
13-
// L-> { "ASDF" }
12+
//
13+
// | L-> { "ABD" }
14+
// L-> { "ASDF" }
15+
//
1416
// If we simply removed "ABC", we would end up with a tree where shard 'B' only
1517
// has a single child. This causes two issues, the first, is that now we have
1618
// an extra lookup required to get to "ABD". The second issue is that now we
@@ -460,11 +462,11 @@ func (ds *Shard) walkChildren(processLinkValues func(formattedLink *ipld.Link) e
460462

461463
// parallelShardWalk is quite similar to the DAG walking algorithm from https://github.com/ipfs/go-merkledag/blob/594e515f162e764183243b72c2ba84f743424c8c/merkledag.go#L464
462464
// However, there are a few notable differences:
463-
// 1. Some children are actualized Shard structs and some are in the blockstore, this will leverage walking over the in memory Shards as well as the stored blocks
464-
// 2. Instead of just passing each child into the worker pool by itself we group them so that we can leverage optimizations from GetMany.
465-
// This optimization also makes the walk a little more biased towards depth (as opposed to BFS) in the earlier part of the DAG.
466-
// This is particularly helpful for operations like estimating the directory size which should complete quickly when possible.
467-
// 3. None of the extra options from that package are needed
465+
// 1. Some children are actualized Shard structs and some are in the blockstore, this will leverage walking over the in memory Shards as well as the stored blocks
466+
// 2. Instead of just passing each child into the worker pool by itself we group them so that we can leverage optimizations from GetMany.
467+
// This optimization also makes the walk a little more biased towards depth (as opposed to BFS) in the earlier part of the DAG.
468+
// This is particularly helpful for operations like estimating the directory size which should complete quickly when possible.
469+
// 3. None of the extra options from that package are needed
468470
func parallelShardWalk(ctx context.Context, root *Shard, dserv ipld.DAGService, processShardValues func(formattedLink *ipld.Link) error) error {
469471
const concurrency = 32
470472

importer/balanced/balanced_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
mrand "math/rand"
109
"testing"
1110

@@ -53,7 +52,7 @@ func getTestDag(t *testing.T, ds ipld.DAGService, size int64, blksize int64) (*d
5352
return nd, data
5453
}
5554

56-
//Test where calls to read are smaller than the chunk size
55+
// Test where calls to read are smaller than the chunk size
5756
func TestSizeBasedSplit(t *testing.T) {
5857
if testing.Short() {
5958
t.SkipNow()
@@ -119,7 +118,7 @@ func arrComp(a, b []byte) error {
119118
}
120119

121120
func dagrArrComp(t *testing.T, r io.Reader, should []byte) {
122-
out, err := ioutil.ReadAll(r)
121+
out, err := io.ReadAll(r)
123122
if err != nil {
124123
t.Fatal(err)
125124
}
@@ -138,7 +137,7 @@ func TestIndirectBlocks(t *testing.T) {
138137
t.Fatal(err)
139138
}
140139

141-
out, err := ioutil.ReadAll(reader)
140+
out, err := io.ReadAll(reader)
142141
if err != nil {
143142
t.Fatal(err)
144143
}
@@ -179,7 +178,7 @@ func TestSeekToBegin(t *testing.T) {
179178
t.Fatal(err)
180179
}
181180

182-
n, err := io.CopyN(ioutil.Discard, rs, 1024*4)
181+
n, err := io.CopyN(io.Discard, rs, 1024*4)
183182
if err != nil {
184183
t.Fatal(err)
185184
}
@@ -207,7 +206,7 @@ func TestSeekToAlmostBegin(t *testing.T) {
207206
t.Fatal(err)
208207
}
209208

210-
n, err := io.CopyN(ioutil.Discard, rs, 1024*4)
209+
n, err := io.CopyN(io.Discard, rs, 1024*4)
211210
if err != nil {
212211
t.Fatal(err)
213212
}

importer/balanced/builder.go

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,37 @@
1717
// that the UnixFS node.
1818
//
1919
// Notes:
20-
// 1. In the implementation. `FSNodeOverDag` structure is used for representing
21-
// the UnixFS node encoded inside the DAG node.
22-
// (see https://github.com/ipfs/go-ipfs/pull/5118.)
23-
// 2. `TFile` is used for backwards-compatibility. It was a bug causing the leaf
24-
// nodes to be generated with this type instead of `TRaw`. The former one
25-
// should be used (like the trickle builder does).
26-
// (See https://github.com/ipfs/go-ipfs/pull/5120.)
2720
//
28-
// +-------------+
29-
// | Root 4 |
30-
// +-------------+
31-
// |
32-
// +--------------------------+----------------------------+
33-
// | |
34-
// +-------------+ +-------------+
35-
// | Node 2 | | Node 5 |
36-
// +-------------+ +-------------+
37-
// | |
38-
// +-------------+-------------+ +-------------+
39-
// | | |
40-
// +-------------+ +-------------+ +-------------+
41-
// | Node 1 | | Node 3 | | Node 6 |
42-
// +-------------+ +-------------+ +-------------+
43-
// | | |
44-
// +------+------+ +------+------+ +------+
45-
// | | | | |
46-
// +=========+ +=========+ +=========+ +=========+ +=========+
47-
// | Chunk 1 | | Chunk 2 | | Chunk 3 | | Chunk 4 | | Chunk 5 |
48-
// +=========+ +=========+ +=========+ +=========+ +=========+
21+
// 1. In the implementation. `FSNodeOverDag` structure is used for representing
22+
// the UnixFS node encoded inside the DAG node.
23+
// (see https://github.com/ipfs/go-ipfs/pull/5118.)
4924
//
25+
// 2. `TFile` is used for backwards-compatibility. It was a bug causing the leaf
26+
// nodes to be generated with this type instead of `TRaw`. The former one
27+
// should be used (like the trickle builder does).
28+
// (See https://github.com/ipfs/go-ipfs/pull/5120.)
29+
//
30+
// +-------------+
31+
// | Root 4 |
32+
// +-------------+
33+
// |
34+
// +--------------------------+----------------------------+
35+
// | |
36+
// +-------------+ +-------------+
37+
// | Node 2 | | Node 5 |
38+
// +-------------+ +-------------+
39+
// | |
40+
// +-------------+-------------+ +-------------+
41+
// | | |
42+
// +-------------+ +-------------+ +-------------+
43+
// | Node 1 | | Node 3 | | Node 6 |
44+
// +-------------+ +-------------+ +-------------+
45+
// | | |
46+
// +------+------+ +------+------+ +------+
47+
// | | | | |
48+
// +=========+ +=========+ +=========+ +=========+ +=========+
49+
// | Chunk 1 | | Chunk 2 | | Chunk 3 | | Chunk 4 | | Chunk 5 |
50+
// +=========+ +=========+ +=========+ +=========+ +=========+
5051
package balanced
5152

5253
import (
@@ -80,55 +81,54 @@ import (
8081
// offset in the file the graph represents: each internal node uses the file size
8182
// of its children as an index when seeking.
8283
//
83-
// `Layout` creates a root and hands it off to be filled:
84-
//
85-
// +-------------+
86-
// | Root 1 |
87-
// +-------------+
88-
// |
89-
// ( fillNodeRec fills in the )
90-
// ( chunks on the root. )
91-
// |
92-
// +------+------+
93-
// | |
94-
// + - - - - + + - - - - +
95-
// | Chunk 1 | | Chunk 2 |
96-
// + - - - - + + - - - - +
84+
// `Layout` creates a root and hands it off to be filled:
9785
//
98-
// ↓
99-
// When the root is full but there's more data...
100-
// ↓
86+
// +-------------+
87+
// | Root 1 |
88+
// +-------------+
89+
// |
90+
// ( fillNodeRec fills in the )
91+
// ( chunks on the root. )
92+
// |
93+
// +------+------+
94+
// | |
95+
// + - - - - + + - - - - +
96+
// | Chunk 1 | | Chunk 2 |
97+
// + - - - - + + - - - - +
10198
//
102-
// +-------------+
103-
// | Root 1 |
104-
// +-------------+
105-
// |
106-
// +------+------+
107-
// | |
108-
// +=========+ +=========+ + - - - - +
109-
// | Chunk 1 | | Chunk 2 | | Chunk 3 |
110-
// +=========+ +=========+ + - - - - +
99+
// ↓
100+
// When the root is full but there's more data...
101+
// ↓
111102
//
112-
// ↓
113-
// ...Layout's job is to create a new root.
114-
// ↓
103+
// +-------------+
104+
// | Root 1 |
105+
// +-------------+
106+
// |
107+
// +------+------+
108+
// | |
109+
// +=========+ +=========+ + - - - - +
110+
// | Chunk 1 | | Chunk 2 | | Chunk 3 |
111+
// +=========+ +=========+ + - - - - +
115112
//
116-
// +-------------+
117-
// | Root 2 |
118-
// +-------------+
119-
// |
120-
// +-------------+ - - - - - - - - +
121-
// | |
122-
// +-------------+ ( fillNodeRec creates the )
123-
// | Node 1 | ( branch that connects )
124-
// +-------------+ ( "Root 2" to "Chunk 3." )
125-
// | |
126-
// +------+------+ + - - - - -+
127-
// | | |
128-
// +=========+ +=========+ + - - - - +
129-
// | Chunk 1 | | Chunk 2 | | Chunk 3 |
130-
// +=========+ +=========+ + - - - - +
113+
// ↓
114+
// ...Layout's job is to create a new root.
115+
// ↓
131116
//
117+
// +-------------+
118+
// | Root 2 |
119+
// +-------------+
120+
// |
121+
// +-------------+ - - - - - - - - +
122+
// | |
123+
// +-------------+ ( fillNodeRec creates the )
124+
// | Node 1 | ( branch that connects )
125+
// +-------------+ ( "Root 2" to "Chunk 3." )
126+
// | |
127+
// +------+------+ + - - - - -+
128+
// | | |
129+
// +=========+ +=========+ + - - - - +
130+
// | Chunk 1 | | Chunk 2 | | Chunk 3 |
131+
// +=========+ +=========+ + - - - - +
132132
func Layout(db *h.DagBuilderHelper) (ipld.Node, error) {
133133
if db.Done() {
134134
// No data, return just an empty node.
@@ -185,22 +185,22 @@ func Layout(db *h.DagBuilderHelper) (ipld.Node, error) {
185185
// root, and those children will in turn be filled (calling `fillNodeRec`
186186
// recursively).
187187
//
188-
// +-------------+
189-
// | `node` |
190-
// | (new root) |
191-
// +-------------+
192-
// |
193-
// +-------------+ - - - - - - + - - - - - - - - - - - +
194-
// | | |
195-
// +--------------+ + - - - - - + + - - - - - +
196-
// | (old root) | | new child | | |
197-
// +--------------+ + - - - - - + + - - - - - +
198-
// | | |
199-
// +------+------+ + - - + - - - +
200-
// | | | |
201-
// +=========+ +=========+ + - - - - + + - - - - +
202-
// | Chunk 1 | | Chunk 2 | | Chunk 3 | | Chunk 4 |
203-
// +=========+ +=========+ + - - - - + + - - - - +
188+
// +-------------+
189+
// | `node` |
190+
// | (new root) |
191+
// +-------------+
192+
// |
193+
// +-------------+ - - - - - - + - - - - - - - - - - - +
194+
// | | |
195+
// +--------------+ + - - - - - + + - - - - - +
196+
// | (old root) | | new child | | |
197+
// +--------------+ + - - - - - + + - - - - - +
198+
// | | |
199+
// +------+------+ + - - + - - - +
200+
// | | | |
201+
// +=========+ +=========+ + - - - - + + - - - - +
202+
// | Chunk 1 | | Chunk 2 | | Chunk 3 | | Chunk 4 |
203+
// +=========+ +=========+ + - - - - + + - - - - +
204204
//
205205
// The `node` to be filled uses the `FSNodeOverDag` abstraction that allows adding
206206
// child nodes without packing/unpacking the UnixFS layer node (having an internal

importer/helpers/helpers.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name + protobuf
1313

1414
// DefaultLinksPerBlock governs how the importer decides how many links there
1515
// will be per block. This calculation is based on expected distributions of:
16-
// * the expected distribution of block sizes
17-
// * the expected distribution of link sizes
18-
// * desired access speed
16+
// - the expected distribution of block sizes
17+
// - the expected distribution of link sizes
18+
// - desired access speed
19+
//
1920
// For now, we use:
2021
//
21-
// var roughLinkBlockSize = 1 << 13 // 8KB
22-
// var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name
23-
// // + protobuf framing
24-
// var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
25-
// = ( 8192 / 47 )
26-
// = (approximately) 174
22+
// var roughLinkBlockSize = 1 << 13 // 8KB
23+
// var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name
24+
// // + protobuf framing
25+
// var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
26+
// = ( 8192 / 47 )
27+
// = (approximately) 174
2728
var DefaultLinksPerBlock = roughLinkBlockSize / roughLinkSize
2829

2930
// ErrSizeLimitExceeded signals that a block is larger than BlockSizeLimit.

0 commit comments

Comments
 (0)