Skip to content
Draft
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
15 changes: 11 additions & 4 deletions .github/workflows/watch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
XDG_CACHE_HOME: ${{ github.workspace }}/build/cache
HTDOCS_DIR: ${{ github.workspace }}/build/htdocs
BUILD_DIR: ${{ github.workspace }}/build
API_DIR: ${{ github.workspace }}/build/htdocs/api/v1
outputs:
changed: ${{ steps.generate.outputs.changed }}
steps:
Expand Down Expand Up @@ -77,12 +77,14 @@ jobs:
env:
GITHUB_TOKEN: ${{github.token}}
run: >
mkdir -p ${API_DIR}

k6registry -v
--lint
--ref "${BASE_URL}/registry.json"
registry.yaml --out "${HTDOCS_DIR}/registry.json"
registry.yaml --out "${API_DIR}/registry.json"

./generate-api-files.sh -b "${HTDOCS_DIR}"
./generate-api-files.sh -b "${API_DIR}"

- name: Cache Clean
if: ${{ ( github.ref_name == 'main' && steps.generate.outputs.changed == 'true' ) || inputs.force_changed }}
Expand Down Expand Up @@ -148,6 +150,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HTDOCS_DIR: ${{ github.workspace }}/htdocs
API_DIR: ${{ github.workspace }}/build/htdocs/api/v1
WIKI_WORK_DIR: ${{ github.workspace }}/wiki.work
steps:
- name: Checkout
Expand Down Expand Up @@ -176,7 +179,11 @@ jobs:
- name: Generate
run: |
rm -rf ${WIKI_WORK_DIR}/*
gomplate -c registry=${HTDOCS_DIR}/registry.json -c metrics=${HTDOCS_DIR}/metrics.json -c official_metrics=${HTDOCS_DIR}/tier/official-metrics.json -c schema=registry.schema.json --input-dir wiki --output-map="${WIKI_WORK_DIR}/{{.in|strings.TrimSuffix \".tpl\"}}"
gomplate -c registry=${API_DIR}/registry.json \
-c metrics=${API_DIR}/metrics.json \
-c official_metrics=${API_DIR}/tier/official-metrics.json \
-c schema=registry.schema.json --input-dir wiki \
--output-map="${WIKI_WORK_DIR}/{{.in|strings.TrimSuffix \".tpl\"}}"
- name: Push
run: |
cd ${WIKI_WORK_DIR}
Expand Down
10 changes: 4 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ mv public/schema/registry.schema.html public/schema/index.html
The registry is exposed using and API defined in [openapi.yaml]. This API is served using static files generated from the registry using the [generate-api-files.sh] script. The script takes the registry.json generated from [registry.yaml] using `k6registry` as input to generate the json file to be returned by each endpoint. It also generates a metrics.txt file with metrics for the extensions by tier, grade, and issues found.

```bash
BUILD_DIR=build
export BUILD_DIR=build/api/v1
k6registry registry.yaml > ${BUILD_DIR}/registry.json
./generate-api-files.sh -b ${BUILD_DIR}
```

Generates the following files

```ascii
build/
build/api/v1
├── catalog.json
├── metrics.json
├── metrics.txt
Expand Down Expand Up @@ -121,8 +121,6 @@ build/

```bash
export BASE_URL=https://registry.k6.io
curl -s -o build/registry.json $BASE_URL/registry.json
curl -s -o build/metrics.json $BASE_URL/metrics.json
curl -s -o build/official-metrics.json $BASE_URL/tier/official-metrics.json
gomplate -c registry=build/registry.json -c metrics=build/metrics.json -c official_metrics=build/tier/official-metrics.json -c schema=registry.schema.json --input-dir wiki --output-map='build/wiki/{{.in|strings.TrimSuffix ".tpl"}}'
export API_DIR=build/api/v1
gomplate -c registry=${API_DIR}/registry.json -c metrics=${API_DIR}/metrics.json -c official_metrics=${API_DIR}/tier/official-metrics.json -c schema=registry.schema.json --input-dir wiki --output-map='build/wiki/{{.in|strings.TrimSuffix ".tpl"}}'
```
3 changes: 2 additions & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: "3.1.0"
info:
version: "0.1.0"
version: "1.0.0"
title: Grafana k6 Extension Registry Service
summary: Query the Grafana k6 Extension Registry database.
description: |
Expand All @@ -26,6 +26,7 @@ info:
externalDocs:
description: Find out more about Grafana k6 extensions
url: https://grafana.com/docs/k6/latest/extensions/
basePath: "/api/v1"
servers:
- url: https://registry.k6.io
tags:
Expand Down
Loading
Loading