From 98305203e0cdf4d2223331d4bd9e23b4105c488e Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 15 Mar 2024 23:03:38 +0100 Subject: [PATCH] refactor: move smoke-tests to new workflow --- .github/workflows/dnslink-smoke-tests.yml | 93 +++++++++++++++++++++++ .github/workflows/main.yml | 48 +----------- .github/workflows/pin-to-cluster.yml | 71 ----------------- 3 files changed, 95 insertions(+), 117 deletions(-) create mode 100644 .github/workflows/dnslink-smoke-tests.yml delete mode 100644 .github/workflows/pin-to-cluster.yml diff --git a/.github/workflows/dnslink-smoke-tests.yml b/.github/workflows/dnslink-smoke-tests.yml new file mode 100644 index 00000000..03dae35e --- /dev/null +++ b/.github/workflows/dnslink-smoke-tests.yml @@ -0,0 +1,93 @@ +name: DNSLink Smoke-tests + +on: + schedule: + - cron: '0 * * * *' + workflow_dispatch: + pull_request: + branches: + - '**' + +env: + KUBO_VER: 'v0.27.0' # kubo daemon used for publishing to IPFS + CLUSTER_CTL_VER: 'v1.0.8' # ipfs-cluster-ctl used by publish-to-ipfs + +jobs: + dnslink: + runs-on: ubuntu-latest + outputs: + link: ${{ steps.dnslink.link }} + dev: ${{ steps.dnslink.dev }} + steps: + - uses: ipfs/download-ipfs-distribution-action@v1 + with: + name: kubo + version: "${{ env.KUBO_VER }}" + - uses: ipfs/start-ipfs-daemon-action@v1 + - name: Read CID from DNSLink at inbrowser.link|dev + id: dnslink + run: | + echo "link=$(ipfs resolve /ipns/inbrowser.link | sed 's|^/ipfs/||')" >> $GITHUB_OUTPUT + echo "dev=$(ipfs resolve /ipns/inbrowser.dev | sed 's|^/ipfs/||')" >> $GITHUB_OUTPUT + + smoke-test-cached-http: # basic smoke test that lets us know when stale-while-revalidate caching does not work on either env + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dnslink: + - inbrowser.link + - inbrowser.dev + steps: + - name: Smoke-test instant (cached, stale-while-revalidate) /ipfs-sw-main.js at ${{ matrix.dnslink }} + run: curl --retry 3 --retry-delay 61 --retry-all-errors -v -L "https://${{ matrix.dnslink }}/ipfs-sw-main.js" > /dev/null + + smoke-test-fresh-http: # basic smoke test for getting latest DNSLink DAG over HTTP gateways + needs: dnslink + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + gateway: + - trustless-gateway.link + - cloudflare-ipfs.com + dnslink: + - inbrowser.link + - inbrowser.dev + steps: + - uses: ipfs/download-ipfs-distribution-action@v1 + with: + name: kubo + version: "${{ env.KUBO_VER }}" + - uses: ipfs/start-ipfs-daemon-action@v1 + - name: Try fetching the new CID as CAR from ${{ matrix.gateway }} + run: | + CID=$(ipfs resolve /ipns/${{ matrix.dnslink }} | sed 's|^/ipfs/||') + curl --retry 6 --retry-delay 61 --retry-all-errors -v -L --http1.1 "https://${{ matrix.gateway }}/ipfs/${CID}?format=car" -o dag.car + - name: Confirm the CAR contains the entire DAG + run: ipfs dag import --offline --pin-roots=true dag.car + + smoke-test-fresh-p2p: # basic smoke test for getting latest DNSLink DAG over P2P with Kubo + needs: dnslink + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + routing-type: + - dhtclient + - autoclient + dnslink: + - inbrowser.link + - inbrowser.dev + steps: + - uses: ipfs/download-ipfs-distribution-action@v1 + with: + name: kubo + version: "${{ env.KUBO_VER }}" + - name: Init IPFS daemon + run: | + ipfs init --profile server + ipfs config Routing.Type ${{ matrix.routing-type }} + - uses: ipfs/start-ipfs-daemon-action@v1 + - name: Confirm Kubo can fetch with Routing.Type=${{ matrix.routing-type }} + run: ipfs dag stat /ipns/${{ matrix.dnslink }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5459a1c7..e95b2e35 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -349,61 +349,17 @@ jobs: env: CID: ${{ needs.publish-to-ipfs.outputs.cid }} - smoke-test-cached-http: # basic smoke test that lets us know when stale-while-revalidate caching does not work on either env + smoke-test-fresh-p2p: # basic smoke test for getting DAG with Kubo if: needs.publish-to-ipfs.outputs.cid needs: publish-to-ipfs runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - dnslink: - - inbrowser.link - - inbrowser.dev - steps: - - name: Smoke-test instant (cached, stale-while-revalidate) /ipfs-sw-main.js at ${{ matrix.dnslink }} - run: curl --retry 3 --retry-delay 61 --retry-all-errors -v -L https://${{ matrix.dnslink }}/ipfs-sw-main.js > /dev/null - - smoke-test-fresh-http: # basic smoke test for getting new DAG over HTTP gateways - if: needs.publish-to-ipfs.outputs.cid - needs: publish-to-ipfs - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - gateway: - - trustless-gateway.link - - cloudflare-ipfs.com - steps: - - name: Try fetching the new CID as CAR from ${{ matrix.gateway }} - run: curl --retry 6 --retry-delay 61 --retry-all-errors -v -L --http1.1 "https://${{ matrix.gateway }}/ipfs/${{ needs.publish-to-ipfs.outputs.cid }}?format=car" -o dag.car - - uses: ipfs/download-ipfs-distribution-action@v1 - with: - name: kubo - version: "${{ env.KUBO_VER }}" - - name: Confirm the CAR contains the entire DAG - run: ipfs init && ipfs dag import --offline --pin-roots=true dag.car - - smoke-test-fresh-p2p: # basic smoke test for getting new DAG over P2P with Kubo - if: needs.publish-to-ipfs.outputs.cid - needs: publish-to-ipfs - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - routing-type: - - dhtclient - - autoclient steps: - uses: ipfs/download-ipfs-distribution-action@v1 with: name: kubo version: "${{ env.KUBO_VER }}" - - name: Init IPFS daemon - run: | - ipfs init --profile server - ipfs config Routing.Type ${{ matrix.routing-type }} - uses: ipfs/start-ipfs-daemon-action@v1 - - name: Confirm Kubo can fetch with Routing.Type=${{ matrix.routing-type }} + - name: Confirm Kubo can fetch published DAG run: ipfs dag stat ${{ needs.publish-to-ipfs.outputs.cid }} release-please: diff --git a/.github/workflows/pin-to-cluster.yml b/.github/workflows/pin-to-cluster.yml deleted file mode 100644 index 9434cd93..00000000 --- a/.github/workflows/pin-to-cluster.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Pin Latest DNSLink to Cluster - -on: - schedule: - - cron: '6 0 * * *' - workflow_dispatch: - -env: - KUBO_VER: 'v0.26.0' # kubo daemon used for chunking and applying diff - CLUSTER_CTL_VER: 'v1.0.8' # ipfs-cluster-ctl used for pinning - -jobs: - persist: - runs-on: ${{ fromJSON(vars.CI_BUILD_RUNS_ON || '"ubuntu-latest"') }} - environment: Deploy - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.branch }} - - uses: ipfs/download-ipfs-distribution-action@v1 - with: - name: kubo - version: "${{ env.KUBO_VER }}" - - uses: ipfs/download-ipfs-distribution-action@v1 - with: - name: ipfs-cluster-ctl - version: "${{ env.CLUSTER_CTL_VER }}" - - name: Init IPFS daemon - run: | - # fix resolv - DNS provided by Github is unreliable for DNSLik/dnsaddr - sudo sed -i -e 's/nameserver 127.0.0.*/nameserver 1.1.1.1/g' /etc/resolv.conf - ipfs init --profile flatfs,server,randomports,lowpower - # make flatfs async for faster ci - ipfs config --json 'Datastore.Spec.mounts' "$(ipfs config 'Datastore.Spec.mounts' | jq -c '.[0].child.sync=false')" - shell: bash - - uses: ipfs/start-ipfs-daemon-action@v1 - with: - args: --enable-gc=false - - name: Preconnect to cluster peers - run: | - ipfs-cluster-ctl --enc=json \ - --host "/dnsaddr/ipfs-websites.collab.ipfscluster.io" \ - --basic-auth "$CLUSTER_USER:$CLUSTER_PASSWORD" \ - peers ls | tee cluster-peers-ls - for maddr in $(jq -r '.ipfs.addresses[]?' cluster-peers-ls); do - ipfs swarm peering add $maddr - ipfs swarm connect $maddr || true & - done - shell: bash - env: - CLUSTER_USER: ${{ secrets.CLUSTER_USER }} - CLUSTER_PASSWORD: ${{ secrets.CLUSTER_PASSWORD }} - - name: Read CID from DNSLink at inbrowser.link - id: cid-reader - run: echo "CID=$(ipfs resolve /ipns/inbrowser.link | sed 's|^/ipfs/||')" >> $GITHUB_OUTPUT - - name: Pin latest CID to ipfs-websites.collab.ipfscluster.io - run: | - ipfs-cluster-ctl --enc=json \ - --host "/dnsaddr/ipfs-websites.collab.ipfscluster.io" \ - --basic-auth "${CLUSTER_USER}:${CLUSTER_PASSWORD}" \ - pin add \ - --name "inbrowser.link_$(date +"%Y-%m-%d_%H:%M:%S")" \ - --replication-min 2 \ - --replication-max 6 \ - --wait \ - "$PIN_CID" - env: - PIN_CID: ${{ steps.cid-reader.outputs.CID }} - CLUSTER_USER: ${{ secrets.CLUSTER_USER }} - CLUSTER_PASSWORD: ${{ secrets.CLUSTER_PASSWORD }} - timeout-minutes: 60