master
yml 226 lines 7.84 KB
Raw
1 name: Gateway Conformance
2
3 on:
4 workflow_dispatch:
5 push:
6 branches:
7 - master
8 pull_request:
9 paths-ignore:
10 - '**/*.md'
11
12 concurrency:
13 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
14 cancel-in-progress: true
15
16 defaults:
17 run:
18 shell: bash
19
20 env:
21 # hostnames expected by https://github.com/ipfs/gateway-conformance
22 GATEWAY_PUBLIC_GATEWAYS: |
23 {
24 "example.com": {
25 "UseSubdomains": true,
26 "InlineDNSLink": true,
27 "Paths": ["/ipfs", "/ipns"]
28 },
29 "localhost": {
30 "UseSubdomains": true,
31 "InlineDNSLink": true,
32 "Paths": ["/ipfs", "/ipns"]
33 }
34 }
35
36 jobs:
37 # Testing all gateway features via TCP port specified in Addresses.Gateway
38 gateway-conformance:
39 runs-on: ubuntu-latest
40 timeout-minutes: 10
41 steps:
42 # 1. Download the gateway-conformance fixtures
43 - name: Download gateway-conformance fixtures
44 uses: ipfs/gateway-conformance/.github/actions/extract-fixtures@v0.13
45 with:
46 output: fixtures
47
48 # 2. Build the kubo-gateway
49 - name: Checkout kubo-gateway
50 uses: actions/checkout@v6
51 with:
52 path: kubo-gateway
53 - name: Setup Go
54 uses: actions/setup-go@v6
55 with:
56 go-version-file: 'kubo-gateway/go.mod'
57 cache: true
58 cache-dependency-path: kubo-gateway/go.sum
59 - name: Build kubo-gateway
60 run: make build
61 working-directory: kubo-gateway
62
63 # 3. Init the kubo-gateway
64 - name: Init kubo-gateway
65 run: |
66 ./ipfs init -e
67 ./ipfs config --json Gateway.PublicGateways "$GATEWAY_PUBLIC_GATEWAYS"
68 working-directory: kubo-gateway/cmd/ipfs
69
70 # 4. Populate the Kubo gateway with the gateway-conformance fixtures
71 - name: Import fixtures
72 run: |
73 # Import car files
74 find ./fixtures -name '*.car' -exec kubo-gateway/cmd/ipfs/ipfs dag import --pin-roots=false {} \;
75
76 # Import ipns records
77 records=$(find ./fixtures -name '*.ipns-record')
78 for record in $records
79 do
80 key=$(basename -s .ipns-record "$record" | cut -d'_' -f1)
81 kubo-gateway/cmd/ipfs/ipfs routing put --allow-offline "/ipns/$key" "$record"
82 done
83
84 # Import dnslink records
85 # the IPFS_NS_MAP env will be used by the daemon
86 echo "IPFS_NS_MAP=$(cat ./fixtures/dnslinks.IPFS_NS_MAP)" >> $GITHUB_ENV
87
88 # 5. Start the kubo-gateway
89 - name: Start kubo-gateway
90 run: |
91 ./ipfs daemon --offline &
92 working-directory: kubo-gateway/cmd/ipfs
93
94 # 6. Run the gateway-conformance tests
95 - name: Run gateway-conformance tests
96 uses: ipfs/gateway-conformance/.github/actions/test@v0.13
97 with:
98 gateway-url: http://127.0.0.1:8080
99 subdomain-url: http://localhost:8080
100 args: -skip 'TestGatewayCar/GET_response_for_application/vnd.ipld.car/Header_Content-Length'
101 json: output.json
102 xml: output.xml
103 html: output.html
104 markdown: output.md
105
106 # 7. Upload the results
107 - name: Upload MD summary
108 if: failure() || success()
109 run: cat output.md >> $GITHUB_STEP_SUMMARY
110 - name: Upload HTML report
111 if: failure() || success()
112 uses: actions/upload-artifact@v7
113 with:
114 name: gateway-conformance.html
115 path: output.html
116 - name: Upload JSON report
117 if: failure() || success()
118 uses: actions/upload-artifact@v7
119 with:
120 name: gateway-conformance.json
121 path: output.json
122
123 # Testing trustless gateway feature subset exposed as libp2p protocol
124 gateway-conformance-libp2p-experiment:
125 runs-on: ubuntu-latest
126 timeout-minutes: 10
127 steps:
128 # 1. Download the gateway-conformance fixtures
129 - name: Download gateway-conformance fixtures
130 uses: ipfs/gateway-conformance/.github/actions/extract-fixtures@v0.13
131 with:
132 output: fixtures
133
134 # 2. Build the kubo-gateway
135 - name: Checkout kubo-gateway
136 uses: actions/checkout@v6
137 with:
138 path: kubo-gateway
139 - name: Setup Go
140 uses: actions/setup-go@v6
141 with:
142 go-version-file: 'kubo-gateway/go.mod'
143 cache: true
144 cache-dependency-path: kubo-gateway/go.sum
145 - name: Build kubo-gateway
146 run: make build
147 working-directory: kubo-gateway
148
149 # 3. Init the kubo-gateway
150 - name: Init kubo-gateway
151 run: |
152 ./ipfs init --profile=test
153 ./ipfs config --json Gateway.PublicGateways "$GATEWAY_PUBLIC_GATEWAYS"
154 ./ipfs config --json Experimental.GatewayOverLibp2p true
155 ./ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/8080"
156 ./ipfs config Addresses.API "/ip4/127.0.0.1/tcp/5001"
157 working-directory: kubo-gateway/cmd/ipfs
158
159 # 4. Populate the Kubo gateway with the gateway-conformance fixtures
160 - name: Import fixtures
161 run: |
162 # Import car files
163 find ./fixtures -name '*.car' -exec kubo-gateway/cmd/ipfs/ipfs dag import --pin-roots=false {} \;
164
165 # 5. Start the kubo-gateway
166 - name: Start kubo-gateway
167 run: |
168 ( ./ipfs daemon & ) | sed '/Daemon is ready/q'
169 while [[ "$(./ipfs id | jq '.Addresses | length')" == '0' ]]; do sleep 1; done
170 working-directory: kubo-gateway/cmd/ipfs
171
172 # 6. Setup a kubo http-p2p-proxy to expose libp2p protocol as a regular HTTP port for gateway conformance tests
173 - name: Init p2p-proxy kubo node
174 env:
175 IPFS_PATH: "~/.kubo-p2p-proxy"
176 run: |
177 ./ipfs init --profile=test -e
178 ./ipfs config --json Experimental.Libp2pStreamMounting true
179 ./ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/8081"
180 ./ipfs config Addresses.API "/ip4/127.0.0.1/tcp/5002"
181 working-directory: kubo-gateway/cmd/ipfs
182
183 # 7. Start the kubo http-p2p-proxy
184 - name: Start kubo http-p2p-proxy
185 env:
186 IPFS_PATH: "~/.kubo-p2p-proxy"
187 run: |
188 ( ./ipfs daemon & ) | sed '/Daemon is ready/q'
189 while [[ "$(./ipfs id | jq '.Addresses | length')" == '0' ]]; do sleep 1; done
190 working-directory: kubo-gateway/cmd/ipfs
191
192 # 8. Start forwarding data from the http-p2p-proxy to the node serving the Gateway API over libp2p
193 - name: Start http-over-libp2p forwarding proxy
194 run: |
195 gatewayNodeId=$(./ipfs --api=/ip4/127.0.0.1/tcp/5001 id -f="<id>")
196 ./ipfs --api=/ip4/127.0.0.1/tcp/5002 swarm connect $(./ipfs --api=/ip4/127.0.0.1/tcp/5001 swarm addrs local --id | head -n 1)
197 ./ipfs --api=/ip4/127.0.0.1/tcp/5002 p2p forward --allow-custom-protocol /http/1.1 /ip4/127.0.0.1/tcp/8092 /p2p/$gatewayNodeId
198 working-directory: kubo-gateway/cmd/ipfs
199
200 # 9. Run the gateway-conformance tests over libp2p
201 - name: Run gateway-conformance tests over libp2p
202 uses: ipfs/gateway-conformance/.github/actions/test@v0.13
203 with:
204 gateway-url: http://127.0.0.1:8092
205 args: --specs "trustless-gateway,-trustless-ipns-gateway" -skip 'TestGatewayCar/GET_response_for_application/vnd.ipld.car/Header_Content-Length'
206 json: output.json
207 xml: output.xml
208 html: output.html
209 markdown: output.md
210
211 # 10. Upload the results
212 - name: Upload MD summary
213 if: failure() || success()
214 run: cat output.md >> $GITHUB_STEP_SUMMARY
215 - name: Upload HTML report
216 if: failure() || success()
217 uses: actions/upload-artifact@v7
218 with:
219 name: gateway-conformance-libp2p.html
220 path: output.html
221 - name: Upload JSON report
222 if: failure() || success()
223 uses: actions/upload-artifact@v7
224 with:
225 name: gateway-conformance-libp2p.json
226 path: output.json