From fd69c0cc753fd9c424599a27e4dc259b6cc665dc Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 14 Mar 2024 23:42:20 +0100 Subject: [PATCH] feat(ci): update inbrowser.link on release publish --- .github/workflows/main.yml | 73 ++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1f8ebd32..584aeef7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,8 @@ on: pull_request: branches: - '**' + release: + types: [ published ] workflow_dispatch: env: @@ -167,11 +169,11 @@ jobs: files: .coverage/*,packages/*/.coverage/* publish-to-ipfs: - # TODO: make this run also on release - if: github.ref == 'refs/heads/main' + # NOTE: workflow_dispatch here allows maintainer to manually run against any branch, and it will produce a CAR with CID that is pinned + # TODO: if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'release' && github.event.action == 'published') needs: build runs-on: ubuntu-latest - environment: Deploy # CF and Clusteer secrets + environment: Deploy # Clusteer secrets concurrency: # only one job runs at a time == DNSLinks are updated in-order group: ${{ github.workflow }}-${{ github.ref }} @@ -195,15 +197,14 @@ jobs: version: "${{ env.CLUSTER_CTL_VER }}" - name: Init IPFS daemon run: | + # TODO remove if we no longer need these # 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 + #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 \ @@ -249,8 +250,8 @@ jobs: CLUSTER_USER: ${{ secrets.CLUSTER_USER }} CLUSTER_PASSWORD: ${{ secrets.CLUSTER_PASSWORD }} timeout-minutes: 60 - - name: Update DNSLink at inbrowser.dev (Dev Testing) - if: github.ref == 'refs/heads/main' + - name: Update DNSLink at inbrowser.dev (Staging for Dev Testing) if main branch was updated + if: (github.event_name == 'workflow_dispatch' || github.event_name == 'push') && github.ref == 'refs/heads/main' run: | curl --request PUT --header "Authorization: Bearer ${AUTH_TOKEN}" --header 'Content-Type: application/json' \ --url "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}" \ @@ -261,9 +262,8 @@ jobs: ZONE_ID: ${{ secrets.CF_INBROWSERDEV_ZONE_ID }} RECORD_ID: ${{ secrets.CF_INBROWSERDEV_RECORD_ID }} AUTH_TOKEN: ${{ secrets.CF_INBROWSERDEV_AUTH_TOKEN }} - - name: Update DNSLink at inbrowser.link (Stable Production) - # TODO: make this run only on release - if: github.ref == 'refs/heads/main' + - name: Update DNSLink at inbrowser.link (Stable Production) if new release was published + if: github.event_name == 'release' && github.event.action == 'published' run: | curl --request PUT --header "Authorization: Bearer ${AUTH_TOKEN}" --header 'Content-Type: application/json' \ --url "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}" \ @@ -276,7 +276,7 @@ jobs: AUTH_TOKEN: ${{ secrets.CF_INBROWSERLINK_AUTH_TOKEN }} pin-to-w3: # ported from ipfs/ipfs-webui - if: ${{ success() && needs.publish-to-ipfs.outputs.cid }} + if: needs.publish-to-ipfs.outputs.cid needs: publish-to-ipfs runs-on: ubuntu-latest environment: web3.storage @@ -313,7 +313,7 @@ jobs: W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING: ${{ secrets.W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING }} pin-to-scaleway: - if: ${{ success() && needs.publish-to-ipfs.outputs.cid }} + if: needs.publish-to-ipfs.outputs.cid needs: publish-to-ipfs runs-on: ubuntu-latest environment: Scaleway @@ -349,15 +349,42 @@ jobs: env: CID: ${{ needs.publish-to-ipfs.outputs.cid }} - smoke-test-http: # basic smoke test that lets us know when eother caching or content routing does not work - if: ${{ success() && needs.publish-to-ipfs.outputs.cid }} - needs: [ publish-to-ipfs, pin-to-scaleway, pin-to-w3 ] + smoke-test-cached-http: # basic smoke test that lets us know when stale-while-revalidate caching does not work on either env + if: needs.publish-to-ipfs.outputs.cid + needs: publish-to-ipfs runs-on: ubuntu-latest + strategy: + matrix: + dnslink: + - inbrowser.link + - inbrowser.dev steps: - - name: Smoke-test instant (cached, stale-while-revalidate) /ipfs-sw-main.js at inbrowser.link - run: curl --retry 3 --retry-delay 61 --retry-all-errors -v https://inbrowser.link/ipfs-sw-main.js > /dev/null - - name: Smoke-test instant (cached, stale-while-revalidate) /ipfs-sw-main.js at inbrowser.dev - run: curl --retry 3 --retry-delay 61 --retry-all-errors -v https://inbrowser.dev/ipfs-sw-main.js > /dev/null - - name: Smoke-test fetching the new CID as CAR from trustless-gateway.link - run: curl --retry 3 --retry-delay 61 --retry-all-errors -v "https://trustless-gateway.link/ipfs/${{ needs.publish-to-ipfs.outputs.cid }}?format=car" > /dev/null + - 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 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: + matrix: + gateway: + - trustless-gateway.link + - cloudflare-ipfs.com + - w3s.link + steps: + - name: Smoke-test fetching the new CID as CAR from ${{ matrix.gateway }} + run: curl --retry 3 --retry-delay 61 --retry-all-errors -v "https://${{ matrix.gateway }}/ipfs/${{ needs.publish-to-ipfs.outputs.cid }}?format=car" > /dev/null + + 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 + steps: + - uses: ipfs/download-ipfs-distribution-action@v1 + with: + name: kubo + version: "${{ env.KUBO_VER }}" + - uses: ipfs/start-ipfs-daemon-action@v1 + - name: Smoke-test p2p retrieval with Kubo + run: ipfs dag stat ${{ steps.ipfs-import.outputs.cid }}