-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from devsheva/develop
[release]: 1.0.0-alpha
- Loading branch information
Showing
37 changed files
with
2,562 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: Deploy | ||
on: | ||
push: | ||
branches: develop | ||
|
||
pull_request: | ||
branches: master | ||
types: [closed] | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
APP_ENV: test | ||
BOT_TOKEN: dummy | ||
SUPABASE_URL: ${{secrets.SUPABASE_URL}} | ||
SUPABASE_KEY: ${{secrets.SUPABASE_KEY}} | ||
SUPABASE_SCHEMA: test | ||
|
||
steps: | ||
- name: Setup repo | ||
uses: actions/checkout@v4 | ||
|
||
- uses: denoland/setup-deno@main | ||
with: | ||
deno-version: v1.x | ||
|
||
- name: Cache Dependencies | ||
run: deno cache src/bot.ts | ||
|
||
- name: Run Tests | ||
run: deno task test | ||
|
||
coverage: | ||
name: Coverage | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
APP_ENV: test | ||
BOT_TOKEN: dummy | ||
SUPABASE_URL: ${{secrets.SUPABASE_URL}} | ||
SUPABASE_KEY: ${{secrets.SUPABASE_KEY}} | ||
SUPABASE_SCHEMA: test | ||
|
||
steps: | ||
- name: Setup repo | ||
uses: actions/checkout@v3 | ||
|
||
- uses: denoland/setup-deno@main | ||
with: | ||
deno-version: v1.x | ||
|
||
- name: Run Coverage | ||
run: deno task coverage | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
|
||
format-and-lint: | ||
name: Format and Lint | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
APP_ENV: test | ||
BOT_TOKEN: dummy | ||
SUPABASE_URL: ${{secrets.SUPABASE_URL}} | ||
SUPABASE_KEY: ${{secrets.SUPABASE_KEY}} | ||
SUPABASE_SCHEMA: test | ||
|
||
steps: | ||
- name: Setup repo | ||
uses: actions/checkout@v4 | ||
|
||
- uses: denoland/setup-deno@main | ||
with: | ||
deno-version: v1.x | ||
|
||
- name: Run Format | ||
run: deno fmt --check | ||
|
||
- name: Run Lint | ||
run: deno lint | ||
|
||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
|
||
needs: | ||
- test | ||
- format-and-lint | ||
|
||
environment: | ||
name: ${{github.ref_name}} | ||
|
||
permissions: | ||
id-token: write # Needed for auth with Deno Deploy | ||
contents: read # Needed to clone the repository | ||
|
||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Deno | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: v1.x | ||
|
||
- name: Upload to Deno Deploy | ||
uses: denoland/deployctl@v1 | ||
env: | ||
APP_ENV: ${{vars.APP_ENV}} | ||
with: | ||
project: "hn-telegram-bot" | ||
entrypoint: "src/bot.ts" | ||
root: "." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
nodejs 20.14.0 | ||
deno 1.45.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["denoland.vscode-deno", "github.vscode-github-actions"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"deno.enable": true, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "denoland.vscode-deno", | ||
"editor.formatOnSave": true, | ||
"editor.tabSize": 2 | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## [unreleased] | ||
|
||
### 🚀 Features | ||
|
||
- *(analysis)* Send message to user | ||
- Add daily analysis cron job | ||
- *(supabase)* Add test schema support | ||
- Add supabase as storage for preferences | ||
- *(analysis)* Respond with filtered story titles based on user preferences | ||
- *(gemini-adapter)* Add responseSchema for storyIds | ||
- *(gemini-adapter)* Replace with v1beta API and add responseMimeType on config | ||
- *(gemini-adapter)* Implement generateContent call with response parsing | ||
- Add changelog | ||
- Deploy workflow | ||
- Validate Item schema | ||
- [**breaking**] Complete deno migration by fixing last tests | ||
- Add list preferences cmd | ||
- [**breaking**] Replace jest with vitest cause of esm troubles | ||
- Reset preferences and fix convo loop | ||
- Store preferences in session with conversations | ||
- Ask for preference | ||
- Determine session adapter in bot setup | ||
- Get storage adapter for env | ||
- Remove axios to use builtin fetch API | ||
- Get 500 top stories | ||
|
||
### 🐛 Bug Fixes | ||
|
||
- *(utils)* Type generic supabaseAdapter | ||
- Correctly type users preferences group | ||
- *(config)* Restore test task arg when setting env | ||
- Add missing test variables for coverage | ||
- Remove env leaking log | ||
- Change root to cwd | ||
- Import new types in bot.ts | ||
- Adapt for deno deploy | ||
- Use test flag on test task to retrieve right env file | ||
- Remove overkilling functions and declare adapters inside always condition | ||
- Disable noEmit during build | ||
- Add ESM support for jest | ||
- Remove ts-node and use tsx with watch mode | ||
|
||
### 🚜 Refactor | ||
|
||
- *(gemini-adapter)* Simplify body object gen | ||
- Improve env loading with zod | ||
- [**breaking**] Move types in a single declaration file | ||
- Add generic slashCommand generator | ||
|
||
### 📚 Documentation | ||
|
||
- Update changelog | ||
- Add instructions to run tests with test schema | ||
- Force env variable setup | ||
- Removed setMyCommands tip since an issue has been opened for it(#13) | ||
- Fix typo on README | ||
- Sort commits by newest for git-cliff | ||
- Prioritize testing over styling in changelog | ||
- Update changelog | ||
- Add deployment section | ||
- Move codefactor badge on top | ||
- Add codefactor badge | ||
- Add todo for clear preferences and update readme with BDD tips | ||
- Update readme with right usage of jest object | ||
- Add setMyCommands usage tip | ||
- Add testing guideline | ||
- Update README with test instructions | ||
- Add usage instructions | ||
|
||
### 🧪 Testing | ||
|
||
- *(helpers)* Cleanup database sessions | ||
- *(analysis)* Add promisify factory with item mocks | ||
- Stub global fetch | ||
- [**breaking**] Fix specs adapting to vitest | ||
- It responds to setup command | ||
- Add type checkers | ||
- Add faker and mock array of top stories | ||
- Should return null for not found item | ||
- Mock getItem api | ||
- Add watch flag | ||
|
||
### 🎨 Styling | ||
|
||
- Remove unused no-explicit-any in spec | ||
- Set editor.tabSize on 2 | ||
- Underscore file names | ||
- Fix fmt of api.ts | ||
- Add develop codefactor | ||
- Add newline on heading | ||
|
||
### ⚙️ Miscellaneous Tasks | ||
|
||
- Update config.ts to load environment variables with export option | ||
- *(analysis)* Parse user preferences and filter their stories | ||
- Correctly type all parts using ramda | ||
- Add deno check task to improve code quality | ||
- *(types)* Type getUserPreferences | ||
- *(ramda)* Add @types/ramda | ||
- Remove any type from custom schemas in utils.ts | ||
- Upgrade @std/testing to major 1 | ||
- Fix supabase deps | ||
- Upgrade deno to 1.45.4 and include unstable cron | ||
- *(analysis)* Get users preferences and seed db | ||
- Add supabase secrets | ||
- *(supabase)* Add db types and client connection | ||
- Update changelog | ||
- *(utils)* Add mapIndexed fn | ||
- *(analysis)* Add error tests todo for __bulkRetrieveItems__ | ||
- *(analysis)* Bulk retrieve top stories as items with parallel requests | ||
- *(gemini-adapter)* Add body builder function | ||
- *(ai-adapter)* Add body call signature | ||
- *(ai-adapter)* Add buildBody method | ||
- *(gemini-adapter)* Init apiKey and baseUrl | ||
- *(ai-adapter)* Rename text to input as generateContent param | ||
- *(ai-adapter)* Init base adapter | ||
- Upgrade deno to 1.45.1 | ||
- *(analysis)* Init folder structure | ||
- *(gemini-response)* Add zod types for request and response schema of `generateContent` api | ||
- Point ramda package to deno instead of nest | ||
- AllowBreaking on updater | ||
- Add format and lint job | ||
- Ignore any lint in specs | ||
- Cache dependencies during test | ||
- Upgrade grammy to 1.27 with latest types | ||
- Reignore .env.test | ||
- Upgrade packages | ||
- Manual update workflow | ||
- Add update workflow | ||
- Add codecov | ||
- Add test job dependency | ||
- Do not ignore .env test | ||
- Add zod package | ||
- Add coverage task | ||
- Add recommended deno ext | ||
- [**breaking**] Add grammy from deno | ||
- [**breaking**] Add faker deno module | ||
- [**breaking**] Add ramda external dep | ||
- [**breaking**] Add deno and remove type definitions and tsconfig | ||
- Add dependabot | ||
- Upgrade dotenvx to major 1 | ||
- [**breaking**] Remove export of bot and use bot.ts as entrypoint | ||
- Upgrade typescript npm | ||
- Upgrade grammy | ||
- Add todo on mocking api calls | ||
- Upgrade grammy | ||
- Init conversation plugin | ||
- Remove some types and cleanup config | ||
- Init setup composer | ||
- [**breaking**] Use bot.ts as entrypoint | ||
- Init grammy bot | ||
- Replace telegraf with grammY | ||
- Add tsconfig.build for excluding specs on compilation | ||
- Remove error test | ||
- Improve item typing for req | ||
- Config jest to match only __tests__ folder | ||
- Config jest for ts and move to src folder | ||
- Move env declaration at root | ||
- Add support of dotenvx | ||
- Add build script for npm to run tsc | ||
- Extend ProcessEnv of node with BOT_TOKEN | ||
- Init project | ||
|
||
### Deno | ||
|
||
- Update imports | ||
- Update imports | ||
|
||
<!-- generated by git-cliff --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,47 @@ | ||
# hn-telegram-bot | ||
|
||
 | ||
[](https://codecov.io/gh/devsheva/hn-telegram-bot) | ||
|
||
HackerNews Telegram Bot | ||
|
||
## Usage | ||
|
||
### Development | ||
|
||
To develop in local just run `deno task dev` that will start in watch mode. | ||
To update the changelog just run `git-cliff -o CHANGELOG.md`. | ||
|
||
### Testing | ||
|
||
**Pass the necessary environment variables to run against test mode!** | ||
|
||
- APP_ENV=test | ||
- SUPABASE_KEY=your_key | ||
- SUPABASE_SCHEMA=test | ||
- SUPABASE_URL=your_url | ||
|
||
Put all tests under this [folder](src/__tests__) and run `deno task test`, which will run test environment with Deno in watch mode. | ||
|
||
You must pass at least the following environment variables to make testing work: | ||
|
||
- APP_ENV | ||
- SUPABASE_URL | ||
- SUPABASE_KEY | ||
|
||
> Note: this is a temporary workaround until conversations plugin is fixed | ||
When running tests on a composer that involves conversation, always add `await new Promise(r => setTimeout(r, 0))`, so it doesn't lead to | ||
deno leaks due to sanitizers. | ||
|
||
### Tips | ||
|
||
This project is made by mainly following BDD principles, so you should stick to it, you won't regret. | ||
|
||
## Deployment | ||
|
||
It's handled with GitHub Actions, with two [workflows](.github/workflows/): | ||
|
||
- **deploy.yml** | ||
- 3 jobs: test, coverage, deploy | ||
- **update.yml**: external GH Action that acts like dependabot but for deno |
Oops, something went wrong.