Skip to content

Commit

Permalink
Merge pull request #10 from ubiquibot/development
Browse files Browse the repository at this point in the history
Merge development into main
  • Loading branch information
gentlementlegen authored Jul 4, 2024
2 parents 94f867e + bbbc53a commit 4bf1916
Show file tree
Hide file tree
Showing 40 changed files with 2,184 additions and 1,518 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", "**/*.toml", "src/adapters/supabase/types/database.ts"],
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "**/*.toml", "**/*.http", "src/adapters/supabase/types/database.ts"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir", "supabase", "typebox", "typeguards"],
"words": ["dataurl", "devpool", "outdir", "servedir", "supabase", "typebox", "typeguards", "mswjs", "ubiquibot"],
"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
3 changes: 3 additions & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUPABASE_URL=
SUPABASE_KEY=
UBIQUIBOT_PUBLIC_KEY=
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
MY_SECRET="MY_SECRET"
SUPABASE_URL=
SUPABASE_KEY=
UBIQUIBOT_PUBLIC_KEY=
6 changes: 3 additions & 3 deletions .github/knip.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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/types/config.ts", "src/adapters/supabase/types/database.ts"],
ignoreExportsUsedInFile: true,
ignoreDependencies: [],
ignoreDependencies: ["ts-node", "@types/jest"],
};

export default config;
19 changes: 17 additions & 2 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,23 @@ jobs:
with:
node-version: "20"

- name: Install Bun
run: npm install -g bun
- uses: oven-sh/setup-bun@v1

- name: Generate Supabase Types
run: |
yarn install
yarn run "supabase:generate:remote"
env:
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}

- name: Generate Supabase Types
run: |
yarn install
yarn run "supabase:generate:remote"
env:
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}

- name: Calling action
uses: ./
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Run Jest testing suite
on:
workflow_dispatch:
pull_request_target:
pull_request:
types: [ opened, synchronize ]

env:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/knip-reporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Knip-reporter

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

permissions: write-all

jobs:
knip-reporter:
runs-on: ubuntu-latest
steps:
- 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 }}
24 changes: 14 additions & 10 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Knip

on:
pull_request_target:
pull_request:
workflow_dispatch:

permissions: write-all

jobs:
run-knip:
runs-on: ubuntu-latest
Expand All @@ -21,11 +19,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 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
20 changes: 20 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: release-please

on:
workflow_dispatch:
push:
branches:
- $default-branch

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/release-please-action@v4
with:
release-type: simple
30 changes: 30 additions & 0 deletions .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy

on:
workflow_dispatch:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20.10.0"
- uses: actions/checkout@v4
- uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: '3.57.0'
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
secrets: |
SUPABASE_URL
SUPABASE_KEY
UBIQUIBOT_PUBLIC_KEY
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
UBIQUIBOT_PUBLIC_KEY: ${{ secrets.UBIQUIBOT_PUBLIC_KEY }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ static/dist
coverage
junit.xml
cypress/screenshots

.dev.vars
/tests/http/http-client.private.env.json
63 changes: 50 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,62 @@
# `@ubiquity/ts-template`
# `@ubiquibot/assistive-pricing`

This template repository includes support for the following:
Helps settings prices and adds label to the issues accordingly.

- TypeScript
- Environment Variables
- Conventional Commits
- Automatic deployment to Cloudflare Pages

## Testing
## Usage
Example of valid configuration:
```yml
- plugin: https://ubiquibot-assistive-pricing.ubq.fi
type: github
with:
labels:
time:
- "Time: <1 Hour"
- "Time: <2 Hours"
- "Time: <4 Hours"
- "Time: <1 Day"
- "Time: <1 Week"
priority:
- "Priority: 1 (Normal)"
- "Priority: 2 (Medium)"
- "Priority: 3 (High)"
- "Priority: 4 (Urgent)"
- "Priority: 5 (Emergency)"
basePriceMultiplier: 1
publicAccessControl:
setLabel: true
fundExternalClosedIssue: false
```
### Cypress
To test with Cypress Studio UI, run
## Running locally
### Supabase
Supabase can be started through the CLI running
```shell
yarn cy:open
supabase start
```

Otherwise to simply run the tests through the console, run
### Worker
Start the Worker by running
```shell
yarn cy:run
yarn worker
```

### Make requests
To trigger the worker, `POST` requests should be made to http://localhost:4000 with a `Content-Type: application/json`
header and a body
looking like
```json
{
"stateId": "",
"eventName": "",
"eventPayload": "",
"settings": "",
"ref": ""
}
```
For convenience you can find an `.http` file with a valid request [here](/tests/http/request.http).

## Testing

### Jest
To start Jest tests, run
```shell
Expand Down
11 changes: 0 additions & 11 deletions cypress.config.ts

This file was deleted.

11 changes: 0 additions & 11 deletions cypress/e2e/main.cy.ts

This file was deleted.

5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

37 changes: 0 additions & 37 deletions cypress/support/commands.ts

This file was deleted.

20 changes: 0 additions & 20 deletions cypress/support/e2e.ts

This file was deleted.

Loading

0 comments on commit 4bf1916

Please sign in to comment.