Skip to content

Commit 0775864

Browse files
authored
feat: fleek deploy
2 parents 2a3febb + 69834e0 commit 0775864

30 files changed

+779
-444
lines changed

.github/workflows/deploy-pages.yml

+10-89
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,12 @@ defaults:
2222
shell: bash
2323

2424
jobs:
25-
# Pulls the output.json from the latest successful run of the gateway-conformance.yml workflow
26-
# and stores these as an artifacts for the build job.
27-
pull-outputs:
28-
runs-on: "ubuntu-latest"
29-
strategy:
30-
matrix:
31-
target: ["ipfs/kubo", "ipfs/boxo", "ipfs/bifrost-gateway"]
32-
fail-fast: false
33-
defaults:
34-
run:
35-
shell: bash
36-
steps:
37-
- name: get repo details
38-
id: get-details
39-
env:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
OWNER_AND_REPO: ${{ matrix.target }}
42-
run: |
43-
DETAILS=$(gh api repos/${OWNER_AND_REPO})
44-
45-
DEFAULT_BRANCH=$(echo $DETAILS | jq -r '.default_branch')
46-
echo "default-branch=${DEFAULT_BRANCH}" >> $GITHUB_OUTPUT
47-
48-
NAME=$(echo $DETAILS | jq -r '.name')
49-
echo "name=${NAME}" >> $GITHUB_OUTPUT
50-
- name: Download json output
51-
id: download-artifact
52-
uses: dawidd6/action-download-artifact@v2 # TODO: pin
53-
with:
54-
workflow: gateway-conformance.yml
55-
workflow_conclusion: "completed" # TODO: ideally we could request success|failure (https://github.com/dawidd6/action-download-artifact#usage)
56-
github_token: ${{ secrets.GITHUB_TOKEN }}
57-
branch: ${{ steps.get-details.outputs.default-branch }}
58-
name: gateway-conformance.json
59-
repo: ${{ matrix.target }}
60-
if_no_artifact_found: fail
61-
- name: Upload JSON output
62-
if: (failure() || success())
63-
uses: actions/upload-artifact@v3
64-
with:
65-
name: conformance-${{ steps.get-details.outputs.name }}.json
66-
path: ./output.json
67-
# https://github.com/actions/starter-workflows/blob/4a8f18e34dd13d2b6ee4d8da2ba72629eafe1609/pages/hugo.yml#L1
6825
build:
6926
runs-on: ubuntu-latest
7027
env:
7128
HUGO_VERSION: 0.117.0
72-
needs: [pull-outputs]
29+
permissions:
30+
contents: write
7331
steps:
7432
- name: Setup Hugo
7533
uses: peaceiris/actions-hugo@16361eb4acea8698b220b76c0d4e84e1fd22c61d # v2.6.0
@@ -81,55 +39,18 @@ jobs:
8139
- name: Setup Pages
8240
id: pages
8341
uses: actions/configure-pages@v1
84-
- name: Download Artifacts
85-
uses: actions/download-artifact@v3
86-
with:
87-
path: artifacts
88-
- name: Generate Data Aggregates
89-
working-directory: ./
42+
- name: Build
9043
run: |
9144
npm ci
92-
mkdir ./munged
93-
94-
# download-artifact downloads artifacts in a directory named after the artifact
95-
# details: https://github.com/actions/download-artifact#download-all-artifacts
96-
for folder in ./artifacts/conformance-*.json; do
97-
file="${folder}/output.json"
98-
new_file="./munged/${folder#.\/artifacts\/conformance-}" # drop the ./artifacts/conformance- prefix
99-
cat "$file" | node ./munge.js > "${new_file}"
100-
done
101-
102-
# generate the sqlite database from our munged files
103-
node ./munge_sql.js ./aggregates.db ./munged/*.json
45+
make website
46+
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
OUTPUT_BASE_URL: ${{ steps.pages.outputs.base_url }}
10449
- name: Upload Data Aggregates
105-
# will be very useful for local debugging
50+
# Used for local debugging
10651
if: (failure() || success())
10752
uses: actions/upload-artifact@v3
10853
with:
109-
name: dashboard-aggregates
54+
name: artifacts
11055
path: |
111-
./munged
112-
./aggregates.db
113-
- name: Generate Content
114-
run: |
115-
node ./munge_aggregates.js ./aggregates.db ./www
116-
- name: Build with Hugo
117-
run: |
118-
hugo \
119-
--minify \
120-
--baseURL ${{ steps.pages.outputs.base_url }}
121-
working-directory: www
122-
- name: Upload artifact
123-
uses: actions/upload-pages-artifact@v1
124-
with:
125-
path: ./www/public
126-
deploy:
127-
environment:
128-
name: github-pages
129-
url: ${{ steps.deployment.outputs.page_url }}
130-
runs-on: ubuntu-latest
131-
needs: build
132-
steps:
133-
- name: Deploy to GitHub Pages
134-
id: deployment
135-
uses: actions/deploy-pages@v1
56+
./artifacts

.github/workflows/test-prod-e2e.yml

-115
This file was deleted.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/artifacts
2+
/aggregates.db
13
/output.html
24
/output.xml
35
/fixtures.car

Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,21 @@ clean-docker:
6161
docker image rm gateway-conformance; \
6262
fi
6363

64+
# dashboard
65+
raw_artifacts:
66+
cat REPOSITORIES | xargs ./munge_download.sh ./artifacts
67+
68+
artifacts: raw_artifacts
69+
find ./artifacts -name '*.json' -exec sh -c 'cat "{}" | node ./munge.js > out && mv out "{}"' \;
70+
71+
aggregates.db: artifacts
72+
rm -f ./aggregates.db
73+
node ./munge_sql.js ./aggregates.db ./artifacts/*.json
74+
75+
website_content: aggregates.db
76+
node ./munge_aggregates.js ./aggregates.db ./www
77+
78+
website: website_content
79+
cd www && hugo --minify $(if ${OUTPUT_BASE_URL},--baseURL ${OUTPUT_BASE_URL})
80+
6481
.PHONY: gateway-conformance

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
- [Local Development](#local-development)
1818
- [Examples](#examples)
1919
- [APIs](#apis)
20+
- [Dashboard](#dashboard)
21+
- [Adding your gateway to the dashboard](#adding-your-gateway-to-the-dashboard)
22+
- [Building the Dashboard](#building-the-dashboard)
2023
- [FAQ](#faq)
2124
- [In Development](#in-development)
2225

@@ -301,6 +304,29 @@ This templating is used almost everywhere in the test sugar, for example in requ
301304
Request().Path("ipfs/{{cid}}", myCid) // will use "ipfs/Qm...."
302305
```
303306

307+
## Dashboard
308+
309+
The gateway conformance test suite includes a web dashboard. This dashboard aggregates results from many test runs and renders them on a static website. This'll give you more detailed insights and navigation options.
310+
311+
### Adding your gateway to the dashboard
312+
313+
The dashboard is hosted at [conformance.ipfs.tech](https://conformance.ipfs.tech/). It aggregates test outputs from various IPFS implementations and renders them on a static website.
314+
315+
To add your gateway to the dashboard, you need to:
316+
317+
- Ensure that your gateway's repository is public.
318+
- Ensure your gateway generates generates the `output.json` file in a `gateway-conformance.yml` file. Check [kubo's workflow](https://github.com/ipfs/kubo/blob/master/.github/workflows/gateway-conformance.yml) for an example.
319+
- Add your gateway to the list of repositories in the [REPOSITORIES](./REPOSITORIES) file.
320+
321+
Once you join the dashboard, your test results will be picked up automatically and your implementation will show up on the dashboard.
322+
323+
### Building the Dashboard
324+
325+
- Set up a GitHub Token: Ensure you have a GitHub Token with `repo:read` scope. This is required to download artifacts.
326+
- Run the Build Command: `GH_TOKEN=your_github_token make website`
327+
328+
This command downloads the latest test artifacts from the repositories listed in the `./REPOSITORIES` file. Then it generates a static website with Hugo in the `www/public` directory.
329+
304330
## FAQ
305331

306332
### How to generate XML, HTML and Markdown reports when using the tool as a Docker container?

REPOSITORIES

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ipfs/kubo
2+
ipfs/boxo
3+
ipfs/bifrost-gateway

munge_download.sh

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
# This script downloads the latest gateway-conformance.json artifacts from the
3+
# given repos and saves them to the output folder.
4+
# it requires GH_TOKEN to be set to a valid GitHub token with repo access.
5+
6+
if [ "$#" -lt 2 ]; then
7+
echo "Usage: $0 output_folder repo1 [repo2 ...]"
8+
exit 1
9+
fi
10+
11+
# if GH_TOKEN is empty, show a message to the user
12+
if [ -z "$GH_TOKEN" ]; then
13+
echo "::warning::GH_TOKEN is required to download the build artifact."
14+
exit 1
15+
fi
16+
17+
if ! command -v jq &> /dev/null || ! command -v unzip &> /dev/null; then
18+
echo "::error::Required command(s) 'jq' and/or 'unzip' not found."
19+
exit 1
20+
fi
21+
22+
output_folder=$1
23+
mkdir -p "$output_folder"
24+
25+
shift
26+
REPOS=("$@")
27+
28+
GH_TOKEN="${GH_TOKEN:-}"
29+
GH_API_BASE_URL="https://api.github.com"
30+
31+
gh_api_request() {
32+
local endpoint="${@: -1}"
33+
34+
if [[ $endpoint =~ ^https?:// ]]; then
35+
local url="$endpoint"
36+
else
37+
local url="$GH_API_BASE_URL$endpoint"
38+
fi
39+
40+
curl -H "Authorization: token $GH_TOKEN" "${@:1:$#-1}" "$url"
41+
}
42+
43+
for repo in "${REPOS[@]}"; do
44+
default_branch=$(gh_api_request "/repos/$repo" | jq -r '.default_branch')
45+
[ -z "$default_branch" ] && echo "::warning::Failed to fetch default branch for $repo" && continue
46+
47+
run_id=$(gh_api_request "/repos/$repo/actions/workflows/gateway-conformance.yml/runs?branch=$default_branch&status=success&per_page=1" | jq -r '.workflow_runs[0].id')
48+
[ -z "$run_id" ] && echo "::warning::Failed to fetch workflow run ID for $repo" && continue
49+
50+
artifact_url=$(gh_api_request "/repos/$repo/actions/runs/$run_id/artifacts" | jq -r '.artifacts[] | select(.name=="gateway-conformance.json") | .archive_download_url')
51+
[ -z "$artifact_url" ] && echo "::warning::Failed to fetch artifact URL for $repo" && continue
52+
53+
temp_dir=$(mktemp -d)
54+
zip_file="$temp_dir/${repo##*/}-artifact.zip"
55+
gh_api_request -L -o "${zip_file}" "$artifact_url" || echo "::warning::Failed to download artifact for $repo"
56+
unzip -j "$zip_file" "output.json" -d "$temp_dir" && mv "$temp_dir/output.json" "$output_folder/${repo##*/}.json" || echo "::warning::Failed to extract output.json for $repo" && continue
57+
58+
rm -rf "$temp_dir"
59+
done

munge_sql.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ const main = async () => {
126126
const fileName = file.split("/").slice(-1)[0].split(".")[0];
127127
const implemId = fileName;
128128

129+
console.log(`Processing ${file}...`);
129130
const content = JSON.parse(fs.readFileSync(file));
130131
const { TestMetadata, ...tests } = content;
131132

132133
const time = TestMetadata?.time;
133-
const { version, job_url } = TestMetadata?.meta || {};
134+
const version = TestMetadata?.meta?.version || 'unknown';
135+
const job_url = TestMetadata?.meta?.job_url || null;
134136

135137
await run(`
136138
INSERT INTO TestRun (implementation_id, version, time, job_url)

www/config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
baseURL: http://example.org/
1+
baseURL: https://conformance.ipfs.tech/
22
languageCode: en-us
33
title: Gateway Conformance Dashboard
44

0 commit comments

Comments
 (0)