Skip to content

Commit

Permalink
Merge pull request #35 from ubiquibot/development
Browse files Browse the repository at this point in the history
chore: merge development into main
  • Loading branch information
gentlementlegen authored Jun 11, 2024
2 parents 873c863 + 5b57570 commit 2a0252a
Show file tree
Hide file tree
Showing 71 changed files with 11,236 additions and 1,052 deletions.
4 changes: 2 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "**/tests/__mocks__"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir", "ubiquibot", "tiktoken", "typebox"],
"words": ["dataurl", "devpool", "outdir", "servedir", "ubiquibot", "tiktoken", "typebox", "supabase", "wxdai", "noopener", "knip", "hellip"],
"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
45 changes: 45 additions & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Compute Rewards

on:
workflow_dispatch:
inputs:
stateId:
description: "State Id"
eventName:
description: "Event Name"
eventPayload:
description: "Event Payload"
settings:
description: "Settings"
authToken:
description: "Auth Token"
ref:
description: "Ref"

jobs:
compute:
name: Rewards
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
X25519_PRIVATE_KEY: ${{ secrets.X25519_PRIVATE_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
NFT_MINTER_PRIVATE_KEY: ${{ secrets.NFT_MINTER_PRIVATE_KEY }}
NFT_CONTRACT_ADDRESS: ${{ secrets.NFT_CONTRACT_ADDRESS }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.10.0"

- run: ${{ toJSON(inputs) }}
shell: cat {0}

- name: Generate Rewards
uses: ./
1 change: 1 addition & 0 deletions .github/workflows/cspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Spell Check

on:
push:
pull_request:

jobs:
spellcheck:
Expand Down
43 changes: 23 additions & 20 deletions .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,41 @@ name: Run Jest Tests

on:
workflow_dispatch:
pull_request:
workflow_run:
workflows: ["Knip"]
types:
- completed

env:
NODE_ENV: "test"

jobs:
test:
testing:
permissions: write-all
name: Run Jest Tests
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
# Dummy values, not production ones!
X25519_PRIVATE_KEY: "wrQ9wTI1bwdAHbxk2dfsvoK1yRwDc0CEenmMXFvGYgY"
EVM_PRIVATE_ENCRYPTED: "kmpTKq5Wh9r9x5j3U9GqZr3NYnjK2g0HtbzeUBOuLC2y3x8ja_SKBNlB2AZ6LigXHP_HeMitftVUtzmoj8CFfVP9SqjWoL6IPku1hVTWkdTn97g1IxzmjydFxjdcf0wuDW1hvVtoq3Uw5yALABqxcQ"
NFT_MINTER_PRIVATE_KEY: ${{ secrets.NFT_MINTER_PRIVATE_KEY }}
NFT_CONTRACT_ADDRESS: ${{ secrets.NFT_CONTRACT_ADDRESS }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
- uses: actions/setup-node@v4
with:
node-version: "20.10.0"

- name: Install dependencies
run: yarn install

- name: Run tests
run: yarn test | tee ./coverage.txt && exit ${PIPESTATUS[0]}
- uses: actions/checkout@master
with:
fetch-depth: 0

- name: Jest Coverage Comment
- name: Jest With Coverage Comment
# Ensures this step is run even on previous step failure (e.g. test failed)
if: always()
uses: MishaKav/jest-coverage-comment@main
uses: ArtiomTr/jest-coverage-report-action@v2
with:
coverage-summary-path: coverage/coverage-summary.json
junitxml-path: junit.xml
junitxml-title: JUnit
coverage-path: ./coverage.txt
package-manager: yarn
prnumber: ${{ github.event.pull_request.number || github.event.workflow_run.pull_requests[0].number }}
49 changes: 49 additions & 0 deletions .github/workflows/knip-reporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Knip-reporter

on:
workflow_run:
workflows: ["Knip"]
types:
- completed

jobs:
knip-reporter:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.10.0

- name: Install toolchain
run: yarn install

- uses: actions/download-artifact@v4
with:
name: knip-results
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Read pr number
id: pr-number
uses: juliangruber/read-file-action@v1
with:
path: ./pr-number.txt
trim: true

- name: Report knip results to pull request
if: ${{ github.event.workflow_run.conclusion != 'success' }}
uses: gitcoindev/knip-reporter@main
with:
verbose: true
comment_id: ${{ github.workflow }}-reporter
command_script_name: knip-ci
annotations: true
ignore_results: false
json_input: true
json_input_file_name: knip-results.json
pull_request_number: ${{ steps.pr-number.outputs.content }}
token: ${{ secrets.GITHUB_TOKEN }}
22 changes: 13 additions & 9 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Knip
on:
pull_request:

permissions: write-all

jobs:
run-knip:
runs-on: ubuntu-latest
Expand All @@ -20,11 +18,17 @@ jobs:
- name: Install toolchain
run: yarn install

- name: Report knip results to pull request
uses: Codex-/knip-reporter@v2
- name: Store PR number
run: echo ${{ github.event.number }} > pr-number.txt

- name: Run Knip
run: yarn knip || yarn -s knip --reporter json > knip-results.json

- name: Upload knip result
if: failure()
uses: actions/upload-artifact@v4
with:
verbose: true
comment_id: ${{ github.workflow }}-reporter
command_script_name: knip-ci
annotations: true
ignore_results: false
name: knip-results
path: |
knip-results.json
pr-number.txt
19 changes: 19 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release Please

on:
workflow_dispatch:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
with:
release-type: simple
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules
static/dist
.env
junit.xml
coverage
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,82 @@ Be sure to review all `*.test.*` files for implementation details.
```

Reward formula: `((count * wordValue) * (score * formattingMultiplier) * n) * relevance + task.reward = total`

## Plugin configuration

Here is a possible valid configuration to enable this plugin.


```yaml
plugin: ubiquibot/conversation-rewards
with:
evmNetworkId: 100
evmPrivateEncrypted: "encrypted-key"
incentives:
enabled: true
requirePriceLabel: true
contentEvaluator:
enabled: true
userExtractor:
enabled: true
redeemTask: true
dataPurge:
enabled: true
formattingEvaluator:
enabled: true
scores:
br: 0
code: 1
p: 1
em: 0
img: 0
strong: 0
blockquote: 0
h1: 1
h2: 1
h3: 1
h4: 1
h5: 1
h6: 1
a: 1
li: 1
td: 1
hr: 0
multipliers:
- targets: [ ISSUE, ISSUER, SPECIFICATION ]
formattingMultiplier: 1
wordValue: 0.1
- targets: [ ISSUE, ISSUER, COMMENTED ]
formattingMultiplier: 1
wordValue: 0.2
- targets: [ ISSUE, ASSIGNEE, COMMENTED ]
formattingMultiplier: 0
wordValue: 0
- targets: [ ISSUE, COLLABORATOR, COMMENTED ]
formattingMultiplier: 1
wordValue: 0.1
- targets: [ ISSUE, CONTRIBUTOR, COMMENTED ]
formattingMultiplier: 0.25
wordValue: 0.1
- targets: [ REVIEW, ISSUER, TASK ]
formattingMultiplier: 0
wordValue: 0
- targets: [ REVIEW, ISSUER, COMMENTED ]
formattingMultiplier: 2
wordValue: 0.2
- targets: [ REVIEW, ASSIGNEE, COMMENTED ]
formattingMultiplier: 1
wordValue: 0.1
- targets: [ REVIEW, COLLABORATOR, COMMENTED ]
formattingMultiplier: 1
wordValue: 0.1
- targets: [ REVIEW, CONTRIBUTOR, COMMENTED ]
formattingMultiplier: 0.25
wordValue: 0.1
permitGeneration:
enabled: false
githubComment:
enabled: true
post: true
debug: false
```
15 changes: 4 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: "Conversation Rewards"
description: "Compute rewards for contributors' discussion on issues that are closed as complete."
inputs:
issue_url:
description: "The URL the the issue needing to be parsed"
required: true
outputs:
result:
description: "The result containing all the rewards of the users"
Expand All @@ -13,11 +9,8 @@ runs:
steps:
- run: |
yarn --cwd ${{ github.action_path }} --production=true
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
id: install
shell: bash
- run: yarn --cwd ${{ github.action_path }} start
shell: bash
id: main
10 changes: 7 additions & 3 deletions knip.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import type { KnipConfig } from "knip";

const config: KnipConfig = {
entry: ["build/index.ts"],
entry: ["src/index.ts"],
project: ["src/**/*.ts"],
ignore: ["src/types/config.ts"],
ignore: ["src/data-collection/examples/*.ts", "src/configuration/common-config-type.ts"],
ignoreExportsUsedInFile: true,
ignoreDependencies: [],
ignoreDependencies: ["ts-node", "msw", "@mswjs/data"],
jest: {
config: ["jest.config.ts"],
entry: ["src/**/*.test.ts"],
},
};

export default config;
Loading

0 comments on commit 2a0252a

Please sign in to comment.