Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): additional pin to scaleway #107

Merged
merged 8 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 47 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- '**'
workflow_dispatch:

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:

Expand Down Expand Up @@ -173,9 +176,6 @@ jobs:
# only one job runs at a time == DNSLinks are updated in-order
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
KUBO_VER: 'v0.26.0' # kubo daemon used for publishing to IPFS
CLUSTER_CTL_VER: 'v1.0.8' # ipfs-cluster-ctl used for pinning
outputs:
cid: ${{ steps.ipfs-import.outputs.cid }}
steps:
Expand Down Expand Up @@ -312,15 +312,52 @@ jobs:
W3_PRINCIPAL: ${{ secrets.W3_AGENT_PRINCIPAL }}
W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING: ${{ secrets.W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING }}

smoke-test--http: # basic smoke test that lets us know when eother caching or content routing does not work
pin-to-scaleway:
if: ${{ success() && needs.publish-to-ipfs.outputs.cid }}
needs: publish-to-ipfs
runs-on: ubuntu-latest
environment: Scaleway
steps:
- name: Smoke-test instant (cached) /ipfs-sw-main.js at inbrowser.link
run: curl --retry 3 --retry-delay 61 -s -D - -o /dev/null https://inbrowser.link/ipfs-sw-main.js
- name: Smoke-test instant (cached) /ipfs-sw-main.js at inbrowser.dev
run: curl --retry 3 --retry-delay 61 -s -D - -o /dev/null https://inbrowser.dev/ipfs-sw-main.js
- name: Smoke-test fetching full DAG as CAR from trustless-gateway.link
run: curl --retry 3 --retry-delay 61 -s -D - -o /dev/null "https://trustless-gateway.link/ipfs/${{ needs.publish-to-ipfs.outputs.cid }}?format=car"
- uses: actions/checkout@v4
- uses: ipfs/download-ipfs-distribution-action@v1
with:
name: kubo
version: "${{ env.KUBO_VER }}"
- name: Init IPFS daemon
run: ipfs init --profile flatfs,server,randomports,lowpower
- uses: ipfs/start-ipfs-daemon-action@v1
with:
args: --enable-gc=false
- name: Retrieve CAR produced by publish-to-ipfs job
uses: actions/download-artifact@v4
with:
name: dist_${{ github.sha }}.car
- name: Import CAR to local Kubo
run: ipfs dag import --offline dist_${{ github.sha }}.car
- name: Set up and check Scaleway
id: scaleway
run: |
ipfs pin remote service add scaleway "$SCALEWAY_URL" "$SCALEWAY_SECRET"
echo "existing-pin=$(ipfs pin remote ls --service=scaleway --name=$CID)" >> $GITHUB_OUTPUT # using --name because --cid does not work with Scaleway (2024-Q1)
env:
CID: ${{ needs.publish-to-ipfs.outputs.cid }}
SCALEWAY_SECRET: ${{ secrets.SCALEWAY_SECRET }}
SCALEWAY_URL: ${{ secrets.SCALEWAY_URL }}
- name: Pin to Scaleway
if: ${{ steps.scaleway.outputs.existing-pin == '' }}
Comment on lines +346 to +347
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Skipping on any preexisting pins for the CID before pinning it again to avoid HTTP 409 error due to duplicate pin. It would often happen in main branch when ./dist output does not change (e.g. commits with docs edits).

run: ipfs pin remote add --service=scaleway --name=$CID $CID # using --name because --cid does not work with Scaleway (2024-Q1)
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 ]
runs-on: ubuntu-latest
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

24 changes: 17 additions & 7 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!--

This HTML page initializes IPFS Service Worker Gateway.

The HTTP server behind this HTTP URL does not host this website.
Instead, it sends basic website code along with JavaScript. The JS sets
up a tool called IPFS Service Worker Gateway in the user's browser and
uses JavaScript version of IPFS (https://helia.io/) to get IPFS blocks
from content providers.

CID hash verification and data assembly happens in the browser.

Learn more about it here: https://github.com/ipfs-shipyard/helia-service-worker-gateway

-->
Comment on lines +4 to +18
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ @2color fysa added this disclaimer for curl/cli devs and users expecting deserialized payload, feel free to adjust in follow-up PR.

<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title><%= htmlWebpackPlugin.options.title %></title>

<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/css/tachyons.min.css"
/>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/ipfs.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/tachyons.min.css" integrity="sha256-MgEf5i1a74lVzhT+1R6mBbWCUeUaxC8sQTaN5GY+CoI=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/ipfs.css" integrity="sha256-tlU/gvVvLjSbTOfSZyCzuQxY8QcmHPtJJ1oTXilA9gk=" crossorigin="anonymous">
Comment on lines +23 to +24
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ I needed to produce new ./dist for testing, so switched to SRI + jsdelivr here.

</head>
<body>
<div id="root" class="montserrat f5"></div>
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const common = {
// Generates deprecation warning: https://github.com/jantimon/html-webpack-plugin/issues/1501
new HtmlWebpackPlugin({
excludeChunks: ['sw'],
title: 'Helia service worker gateway',
title: 'IPFS Service Worker Gateway',
favicon: paths.public + '/favicon.ico',
template: paths.public + '/index.html', // template file
filename: 'index.html', // output file,
Expand Down
Loading