Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge development into main #10

Merged
merged 97 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
7884dd1
chore: removed default labels as it was unused
gentlementlegen May 8, 2024
e2c0f39
feat: database type generation
gentlementlegen May 8, 2024
a494891
feat: added release-please.yml workflow
gentlementlegen May 8, 2024
32a0d75
fix: added secrets for Supabase generation
gentlementlegen May 8, 2024
ba46893
fix: added secrets for Supabase generation
gentlementlegen May 8, 2024
f79b679
chore: changed command check for labels
gentlementlegen May 8, 2024
dd87a2c
chore: changed command check for labels
gentlementlegen May 8, 2024
ba6ba6c
chore: changed comment content
gentlementlegen May 8, 2024
66d2167
chore: changed comment content
gentlementlegen May 8, 2024
2b7b80a
chore: command parsing
gentlementlegen May 9, 2024
6b3d68f
chore: command parsing
gentlementlegen May 9, 2024
d0713f0
chore: command parsing
gentlementlegen May 9, 2024
b10b456
chore: command parsing
gentlementlegen May 9, 2024
00fb85b
chore: command parsing
gentlementlegen May 9, 2024
f733a2a
chore: command parsing
gentlementlegen May 9, 2024
8748a66
chore: fixed comment typo
gentlementlegen May 9, 2024
851bb90
chore: enabled RLS for tables and bun for knip
gentlementlegen May 10, 2024
7978c60
feat: generating supabase types on build
gentlementlegen May 14, 2024
ea88692
chore: added missing packages
gentlementlegen May 14, 2024
49c6c7c
Merge pull request #4 from gentlementlegen/feat/supabase-types
molecula451 May 14, 2024
dc5ac0b
Update package.json
0x4007 May 15, 2024
d8c63cb
chore: changed code to be easier to add more commands
gentlementlegen May 15, 2024
7352f21
chore: removed useless regex check
gentlementlegen May 15, 2024
43b2704
Merge branch 'development' into development
gentlementlegen May 15, 2024
fd41b71
Merge pull request #3 from gentlementlegen/development
molecula451 May 15, 2024
94d5bb7
feat: now runs on cloudflare worker
gentlementlegen May 19, 2024
74ec58c
chore: fixed node version
gentlementlegen May 19, 2024
1ebde4f
chore: content type checks
gentlementlegen May 19, 2024
39543f7
chore: send back run result
gentlementlegen May 19, 2024
4c50e32
chore: removed github package
gentlementlegen May 19, 2024
0781d9f
chore: added node compat
gentlementlegen May 19, 2024
08c9c93
chore: test for full run
gentlementlegen May 19, 2024
6c76102
chore: fix spell check
gentlementlegen May 19, 2024
ae21291
chore: test adding core
gentlementlegen May 19, 2024
d784d7b
chore: added env to deployment
gentlementlegen May 19, 2024
301d968
chore: added env to deployment
gentlementlegen May 19, 2024
79b5f8f
chore: added env to deployment
gentlementlegen May 19, 2024
4605d00
chore: test wrangler v2
gentlementlegen May 19, 2024
cba1c5d
chore: test wrangler v2
gentlementlegen May 19, 2024
6004e4b
chore: test wrangler v2
gentlementlegen May 19, 2024
4a29eb1
chore: test wrangler 3
gentlementlegen May 19, 2024
f8b3b1a
chore: test wrangler 3.57.0
gentlementlegen May 19, 2024
cfa813b
chore: removed log
gentlementlegen May 20, 2024
964a222
chore: decode env for worker
gentlementlegen May 20, 2024
612c851
fix: fixed TTY environment missing
gentlementlegen May 20, 2024
61f7e65
chore: check filter commands
gentlementlegen May 20, 2024
3f3a555
chore: return OK json content
gentlementlegen May 20, 2024
05db424
chore: trim body to avoid trailing spaces
gentlementlegen May 20, 2024
6cacf60
chore: entry point for actions
gentlementlegen May 20, 2024
fca57b6
chore: mock Supabase and GitHub routes
gentlementlegen May 20, 2024
47c3c02
chore: knip and jest on pull_request
gentlementlegen May 20, 2024
c3be195
chore: removed unnecessary test
gentlementlegen May 20, 2024
bf57164
chore: knip on push to dev
gentlementlegen May 20, 2024
aeac6bb
chore: fixed knip workflow
gentlementlegen May 21, 2024
2b91303
Update README.md
gentlementlegen May 21, 2024
97c24ee
chore: fixed jest workflow
gentlementlegen May 21, 2024
89c6fa6
chore: some fixes for knip
gentlementlegen May 21, 2024
5ffad79
chore: some fixes for knip
gentlementlegen May 21, 2024
459cbc2
chore: knip reporter write all
gentlementlegen May 21, 2024
f36ee9a
Merge branch 'refs/heads/development' into feat/worker-instance
gentlementlegen May 21, 2024
3a236dd
Merge branch 'refs/heads/meniole-develop' into feat/worker-instance
gentlementlegen May 21, 2024
c14c096
chore: change test url for repo
gentlementlegen May 21, 2024
49c08bf
chore: fixed knip
gentlementlegen May 21, 2024
5b1551b
chore: replace test by ubiquibot repo
gentlementlegen May 21, 2024
965eca6
chore: fixed handlers for mocked routes
gentlementlegen May 21, 2024
7212a15
chore: renamed GITHUB_TOKEN to UBIQUIBOT_TOKEN
gentlementlegen May 22, 2024
811a7ce
chore: removed unused Cypress and added example
gentlementlegen May 22, 2024
d80c364
chore: fixed example link
gentlementlegen May 22, 2024
623ea3f
chore: fixed typos
gentlementlegen May 22, 2024
c1dacb6
chore: check that incoming request is a POST
gentlementlegen May 23, 2024
78a9765
chore: added back calculateDurations as a comment to avoid knip error
gentlementlegen May 23, 2024
8a13b1e
chore: added back calculateDurations as a comment to avoid knip error
gentlementlegen May 23, 2024
6d88062
chore: added test for non POST requests
gentlementlegen May 23, 2024
207a189
chore: test for POST also checks error code
gentlementlegen May 23, 2024
437ed6a
Merge pull request #6 from gentlementlegen/feat/worker-instance
gentlementlegen May 23, 2024
c149116
feat: check signature
whilefoo Jun 5, 2024
4a9cfc3
fix: tests
whilefoo Jun 6, 2024
83a3d83
fix: sample request
whilefoo Jun 6, 2024
92bfa6e
fix: cspell
whilefoo Jun 6, 2024
be0f10d
Merge pull request #7 from ubiquibot/check-signature
whilefoo Jun 11, 2024
c2ed20e
Update worker-deploy.yml
gentlementlegen Jun 12, 2024
1d733d2
Merge pull request #1 from Meniole/development
gentlementlegen Jun 12, 2024
7e15c0b
chore: added back calculateDurations as a comment to avoid knip error
gentlementlegen May 23, 2024
eb2ffbe
chore: added back calculateDurations as a comment to avoid knip error
gentlementlegen May 23, 2024
6f21b60
chore: updated worker publish
gentlementlegen Jun 17, 2024
ca213da
chore: fixed compile error
gentlementlegen Jun 17, 2024
ecbf7ab
feat: env is now validated
gentlementlegen Jun 17, 2024
5cc14ff
chore: fixed env check for worker
gentlementlegen Jun 17, 2024
fb1dfb8
Merge pull request #9 from gentlementlegen/fix/signature-check
whilefoo Jun 18, 2024
c6573e1
chore: pinned node version for worker-deploy.yml
gentlementlegen Jun 24, 2024
166aaa8
chore: removed comments in pricing.ts
gentlementlegen Jun 24, 2024
711e979
chore: changed return code to 403 on bad signature
gentlementlegen Jun 24, 2024
aebc44d
chore: shortened statements in handlers.ts
gentlementlegen Jun 24, 2024
46fb282
Merge pull request #11 from gentlementlegen/development
gentlementlegen Jul 2, 2024
88c8087
chore: fixed error messages to match status
gentlementlegen Jul 4, 2024
47854b3
chore: fixed tests
gentlementlegen Jul 4, 2024
bbbc53a
chore: fixed tests
gentlementlegen Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
gentlementlegen marked this conversation as resolved.
Show resolved Hide resolved

- 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
Loading