Skip to content

Commit

Permalink
Merge branch 'ubiquibot:development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen authored Apr 7, 2024
2 parents 108e55f + 873c863 commit 08e7028
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir", "ubiquibot"],
"words": ["dataurl", "devpool", "outdir", "servedir", "ubiquibot", "tiktoken", "typebox"],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/build.yml

This file was deleted.

5 changes: 2 additions & 3 deletions .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: Run Jest Tests

on:
workflow_dispatch:
push:
branches:
- development
pull_request:

jobs:
test:
permissions: write-all
Expand Down
17 changes: 11 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
name: "Conversation Rewards"
description: "Compute rewards for contributors' discussion on issues that are closed as complete."
inputs:
authentication_token:
description: "The GitHub authentication token"
issue_url:
description: "The URL the the issue needing to be parsed"
required: true
outputs:
result: # id of output
description: "The result of a event handler"
value: ${{ steps.main.outputs.result}}
result:
description: "The result containing all the rewards of the users"
value: ${{ steps.main.outputs.result }}
runs:
using: "composite"
steps:
- run: |
yarn --cwd ${{ github.action_path }} --production=true
yarn --cwd ${{ github.action_path }} start --auth ${{ inputs.authentication_token }}
yarn --cwd ${{ github.action_path }} start --issue "${{ inputs.issue_url }}" --file "${{ github.action_path }}/results.json"
output=$(cat ${{ github.action_path }}/results.json | tr -s ' ' | tr -d '\n')
echo "Output of calculations:"
echo "$output"
echo "Pushing results to REWARDS output"
echo "REWARDS=$output" >> $GITHUB_OUTPUT
id: main
shell: bash
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"test": "jest --setupFiles dotenv/config --coverage",
"start": "tsx src/start.ts",
"start": "tsx src/index.ts",
"format": "run-s format:lint format:prettier format:cspell",
"format:lint": "eslint --fix .",
"format:prettier": "prettier --write .",
Expand All @@ -36,6 +36,7 @@
"jsdom": "24.0.0",
"markdown-it": "14.1.0",
"openai": "4.29.1",
"tsx": "4.7.1",
"yaml": "2.4.1"
},
"devDependencies": {
Expand Down Expand Up @@ -68,7 +69,6 @@
"npm-run-all": "4.1.5",
"prettier": "3.2.5",
"ts-node": "^10.9.2",
"tsx": "4.7.1",
"typescript": "5.3.3"
},
"lint-staged": {
Expand Down
16 changes: 16 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { IssueActivity } from "./issue-activity";
import program from "./parser/command-line";
import { Processor } from "./parser/processor";
import { parseGitHubUrl } from "./start";

async function main() {
const issueUrl = program.opts().issue;
const issue = parseGitHubUrl(issueUrl);
const activity = new IssueActivity(issue);
await activity.init();
const processor = new Processor();
await processor.run(activity);
processor.dump();
}

main().catch((e) => console.error("Failed to run comment evaluation:", e));
8 changes: 8 additions & 0 deletions src/parser/command-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ import packageJson from "../../package.json";

config();

// On test mode pass the env value directly to the CLI
if (process.env.NODE_ENV === "test") {
process.argv.splice(2);
process.argv.push("-i");
process.argv.push(`${process.env.TEST_ISSUE_URL}`);
}

const program = new Command()
.requiredOption("-i, --issue <url>", "The url of the issue to parse")
.option("-c, --config <path>", "The path to the desired configuration to use", "rewards-configuration.default.yml")
.option("-f, --file <file>", "The target file to store the results in")
.version(packageJson.version)
Expand Down
2 changes: 1 addition & 1 deletion src/parser/content-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class ContentEvaluatorModule implements Module {
for (let j = 0; j < results[0].length; j++) {
let sum = new Decimal(0);
for (let i = 0; i < results.length; i++) {
sum = sum.plus(results[i][j]);
sum = sum.plus(results[i][j] || 0);
}
columnSums.push(sum);
}
Expand Down

0 comments on commit 08e7028

Please sign in to comment.