Skip to content

Commit

Permalink
Add a script to gather the WGSL meeting agenda
Browse files Browse the repository at this point in the history
  • Loading branch information
grorg committed Apr 25, 2020
1 parent d05d63c commit 09cc0ad
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "webgpu-tools",
"version": "1.0.0",
"description": "Scripts to help WebGPU development",
"main": "extract-wgsl-agenda.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@octokit/rest": "^17.6.0",
"yargs": "^15.3.1"
}
}
89 changes: 89 additions & 0 deletions tools/wgsl-meeting-helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env node

const yargs = require("yargs");
const { Octokit } = require("@octokit/rest");

// The identifier for the meeting discussion column in the WGSL project.
// You can list all the columns by calling this script with the "project-info" command.

const WGSL_MEETING_COLUMN = 8898490;

const TOKEN_ENV_NAME = "GPUWEB_GITHUB_TOKEN";

async function authenticate(token) {
const octokit = new Octokit({ auth: token });
await octokit.request("/user");
return octokit;
}

async function agenda(kit, column) {
console.log("Suggested meeting agenda from Github project.");
console.log("----");
const cards = await kit.projects.listCards({ column_id: column });
for (let card of cards.data) {
// Notes are agenda topics that don't have an issue.
if (card.note) {
console.log(`- ${card.note}`);
} else {
// Check if the card is an issue. https://api.github.com/repos/gpuweb/gpuweb/issues/569
const url = card.content_url;
const matches = /gpuweb\/gpuweb\/issues\/(\d+)$/.exec(url);
if (matches) {
const issueIdentifier = matches[1];
const issue = await kit.issues.get({ owner: "gpuweb", repo: "gpuweb", issue_number: issueIdentifier });
console.log(`- ${issue.data.title.replace(/\s*\[wgsl\]\s*/i, "")} (#${issueIdentifier})`);
console.log(` ${issue.data.html_url}`);
}
}
console.log("");
}
}

async function projectInfo(kit) {
const projects = await kit.projects.listForOrg({ org: "gpuweb" });
for (let project of projects.data) {
console.log(`Columns for project "${project.name}" (id: ${project.id})`);
console.log("----");
const columns = await kit.projects.listColumns({ project_id: project.id });
for (let column of columns.data) {
console.log(`${column.name} (id: ${column.id})`);
}
console.log("");
}
}

const argumentProcessor = yargs
.scriptName("wgsl-meeting-helper")
.usage("$0 <command>")
.command({
command: ["agenda", "$0"],
desc: "Build the meeting agenda from the WGSL Github Project.",
handler: () => {
run(agenda, WGSL_MEETING_COLUMN);
}
})
.command({
command: "project-info",
desc: "Build the meeting agenda from the WGSL Github Project.",
handler: () => {
run(projectInfo);
}
})
.version(false)
.help()
.epilogue(`Requires a Github Personal Access Token to be provided as the environment variable ${TOKEN_ENV_NAME}.`)

const token = process.env[TOKEN_ENV_NAME];
if (!token) {
console.log("Error: missing Github Personal Access Token.\n");
argumentProcessor.showHelp();
process.exit();
}

async function run(targetFunction, ...args) {
const kit = await authenticate(token);
targetFunction(kit, ...args);
}

argumentProcessor.parse();

0 comments on commit 09cc0ad

Please sign in to comment.