|
| 1 | +name: Gateway Conformance |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +env: |
| 10 | + LASSIE_ADDRESS: 127.0.0.1 |
| 11 | + LASSIE_PORT: 8888 |
| 12 | + |
| 13 | +jobs: |
| 14 | + gateway-conformance: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + # 1. Start the Kubo gateway |
| 18 | + - name: Download Kubo gateway |
| 19 | + uses: ipfs/download-ipfs-distribution-action@v1 |
| 20 | + - name: Start Kubo gateway |
| 21 | + uses: ipfs/start-ipfs-daemon-action@v1 |
| 22 | + |
| 23 | + # 2. Download the gateway-conformance fixtures |
| 24 | + - name: Download gateway-conformance fixtures |
| 25 | + uses: ipfs/gateway-conformance/.github/actions/[email protected] |
| 26 | + with: |
| 27 | + output: fixtures |
| 28 | + |
| 29 | + # 3. Populate the Kubo gateway with the gateway-conformance fixtures |
| 30 | + - name: Import fixtures |
| 31 | + run: | |
| 32 | + find fixtures -name '*.car' -exec ipfs dag import --pin-roots=false {} \; |
| 33 | + sudo rm -rf fixtures |
| 34 | +
|
| 35 | + # 4. Build the L1 |
| 36 | + - name: Checkout repository |
| 37 | + uses: actions/checkout@v3 |
| 38 | + |
| 39 | + - name: Set up Docker Buildx |
| 40 | + uses: docker/setup-buildx-action@v2 |
| 41 | + |
| 42 | + - name: Build local Docker image |
| 43 | + uses: docker/build-push-action@v3 |
| 44 | + with: |
| 45 | + context: . |
| 46 | + tags: lassie |
| 47 | + cache-from: type=gha |
| 48 | + cache-to: type=gha,mode=max |
| 49 | + load: true |
| 50 | + |
| 51 | + # 5. Start the L1 |
| 52 | + - name: Start L1 |
| 53 | + run: | |
| 54 | +
|
| 55 | + # Configure lassie to fetch only from the localhost kubo |
| 56 | + export LASSIE_ALLOW_PROVIDERS=$(ipfs id | jq --raw-output '.Addresses | @csv | sub("\"";"";"g") ') |
| 57 | + export DOCKER_NETWORK=host |
| 58 | + export LASSIE_PORT=${{ env.LASSIE_PORT }} |
| 59 | + export LASSIE_ADDRESS=${{ env.LASSIE_ADDRESS}} |
| 60 | + docker run --name lassie --rm \ |
| 61 | + --network=$DOCKER_NETWORK \ |
| 62 | + -e "LASSIE_ALLOW_PPROVIDERS=$LASSIE_ALLOW_PROVIDERS" lassie daemon \ |
| 63 | + -e "LASSIE_PORT=$LASSIE_PORT" \ |
| 64 | + -e "LASSIE_ADDRESS=$LASSIE_ADDRESS" & |
| 65 | +
|
| 66 | + num_attempts=0 |
| 67 | + max_attempts=5 |
| 68 | + url=http://${{ env.LASSIE_ADDRESS }}:${{ env.LASSIE_PORT }} |
| 69 | +
|
| 70 | + # wait for the container to be up |
| 71 | + until curl -s "$url" -o /dev/null; do |
| 72 | + if [ ${num_attempts} -eq ${max_attempts} ];then |
| 73 | + echo "Max attempts reached" |
| 74 | + exit 1 |
| 75 | + fi |
| 76 | +
|
| 77 | + num_attempts=$(($num_attempts+1)) |
| 78 | + sleep 5; |
| 79 | + done |
| 80 | +
|
| 81 | + # 6. Run the gateway-conformance tests |
| 82 | + - name: Run gateway-conformance tests |
| 83 | + # Wait for release that contains "trustless-block-gateway,trustless-car-gateway" specs |
| 84 | + uses: ipfs/gateway-conformance/.github/actions/[email protected] |
| 85 | + with: |
| 86 | + gateway-url: http://${{ env.LASSIE_ADDRESS }}:${{ env.LASSIE_PORT }} |
| 87 | + specs: trustless-block-gateway,trustless-car-gateway |
| 88 | + json: output.json |
| 89 | + xml: output.xml |
| 90 | + html: output.html |
| 91 | + markdown: output.md |
| 92 | + args: -skip 'TestGatewayCar/GET_response_for_application/vnd.ipld.car/Header_Content-Length' |
| 93 | + |
| 94 | + # 7. Upload the results |
| 95 | + - name: Upload Markdown summary |
| 96 | + if: "!cancelled()" |
| 97 | + run: cat output.md >> $GITHUB_STEP_SUMMARY |
| 98 | + - name: Upload HTML report |
| 99 | + if: "!cancelled()" |
| 100 | + uses: actions/upload-artifact@v3 |
| 101 | + with: |
| 102 | + name: gateway-conformance.html |
| 103 | + path: output.html |
0 commit comments