benchmark-action / benchmark-action/github-action-benchmark

Support writing data as JSON but still uploading it

Aperta
#261 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
TypeScript
Stelle
1.3k
Fork
183
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I've written a custom UI on top of the benchmark data where I load the data using fetch() from raw.githubusercontent.com so I can switch between branches in the UI from a single deployed GitHub Pages site (as GitHub Pages does not support multiple branches).

However, as the data is expected to be loaded via a <script> tag as JavaScript, I need to trim the prefix from the file before parsing it as JSON.

const dataUrl = `https://raw.githubusercontent.com/${username}/${repository}/${branch}/${application}/data.js`;
const response = await fetch(dataUrl, { cache: 'no-cache' });
const dataText = await response.text();
const data = JSON.parse(dataText.slice('window.BENCHMARK_DATA = '.length));

I otherwise use the auto-push functionality, so would rather be able to control the format of the written file, rather than need to handle all that that functionality myself by using the external-data-json-path input.

If there were an input option to set the format between JavaScript and JSON, then I could directly fetch the data as JSON:

- uses: benchmark-action/github-action-benchmark@v1
  with:
    output-format: json # Optional, default would be javascript as it is today
const dataUrl = `https://raw.githubusercontent.com/${username}/${repository}/${branch}/${application}/data.json`;
const response = await fetch(dataUrl, { cache: 'no-cache' });
const data = await response.json();

I'd be happy to contribute a PR to add support for this if such a feature would be welcome.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia tracciando il percorso di output dell’auto-push dell’action e il writer esistente per data.js, quindi esamina come vengono dichiarati gli input dell’action. Il comportamento richiesto è un’opzione output-format che mantenga l’output JavaScript per impostazione predefinita e scriva dati JSON quando viene scelta l’opzione JSON, con il nome del file caricato corrispondente. Verifica i file generati e la gestione degli input.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
github-actions, typescript
Ambito
ci-cd
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.