Skip to content

Commit

Permalink
Merge pull request #93 from ubiquity-whilefoo/deploy-fix
Browse files Browse the repository at this point in the history
feat: switch to Bun and fix deploy
  • Loading branch information
gentlementlegen authored Nov 26, 2024
2 parents a787355 + bb9e06e commit 688dfbb
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 7,007 deletions.
12 changes: 11 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "bun.lockb", "tests/http/**", "node_modules", "**/*.log", "./src/adapters/supabase/**/**.ts"],
"ignorePaths": [
"**/*.json",
"**/*.css",
"bun.lockb",
"tests/http/**",
"node_modules",
"**/*.log",
"./src/adapters/supabase/**/**.ts",
"dist/**",
"coverage/**"
],
"useGitignore": true,
"language": "en",
"words": [
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/cspell.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/formatting-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Formatting Check

on:
push:

jobs:
format-check:
name: Check for formatting errors
runs-on: ubuntu-latest

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

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install toolchain
run: bun install --frozen-lockfile

- name: Eslint
run: bun run eslint --fix-dry-run

- name: Cspell
run: bun run format:cspell

- name: Prettier
run: bun run prettier --check .
9 changes: 6 additions & 3 deletions .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ jobs:
with:
fetch-depth: 0

- name: Enable corepack
run: corepack enable
- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install toolchain
run: bun install --frozen-lockfile

- name: Jest With Coverage
run: yarn install && yarn test
run: bun run test

- name: Add Jest Report to Summary
if: always()
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ jobs:
with:
node-version: 20.10.0

- name: Enable corepack
run: corepack enable
- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install toolchain
run: yarn install
run: bun install --frozen-lockfile

- 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
run: bun run knip || bun run knip --reporter json > knip-results.json

- name: Upload knip result
if: failure()
Expand Down
56 changes: 8 additions & 48 deletions .github/workflows/update-configuration.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,21 @@
name: "Update Configuration"
name: Update Manifest and Commit Changes

on:
workflow_dispatch:
push:

jobs:
update:
name: "Update Configuration in manifest.json"
update-manifest:
name: "Update Manifest and Commit Changes"
runs-on: ubuntu-latest
permissions: write-all

steps:
- uses: actions/checkout@v4

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

- name: Enable corepack
run: corepack enable

- name: Install deps and run configuration update
run: |
yarn install
yarn tsc --noCheck --project tsconfig.json
- name: Update manifest configuration using GitHub Script
uses: actions/github-script@v7
- name: Update Manifest and Commit Changes
uses: ubiquity-os/action-deploy-plugin@main
with:
script: |
const fs = require('fs');
const path = require('path');
const { pluginSettingsSchema } = require('./src/types/plugin-input');
const manifestPath = path.resolve("${{ github.workspace }}", './manifest.json');
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
const configuration = JSON.stringify(pluginSettingsSchema);
manifest["configuration"] = JSON.parse(configuration);
const updatedManifest = JSON.stringify(manifest, null, 2);
console.log('Updated manifest:', updatedManifest);
fs.writeFileSync(manifestPath, updatedManifest);
- name: Commit and Push generated types
run: |
git config --global user.name 'ubiquity-os[bot]'
git config --global user.email 'ubiquity-os[bot]@users.noreply.github.com'
git add ./manifest.json
if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then
git commit -m "chore: updated generated configuration" || echo "Lint-staged check failed"
git push origin HEAD:${{ github.ref_name }}
else
echo "No changes to commit"
fi
treatAsEsm: false
sourcemap: false
pluginEntry: ${{ github.workspace }}/src/worker.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 7 additions & 1 deletion .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:

- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Update wrangler.toml Name Field
run: |
branch_name=$(echo '${{ github.event.ref }}' | sed 's#refs/heads/##' | sed 's#[^a-zA-Z0-9]#-#g')
Expand All @@ -32,21 +35,24 @@ jobs:
# Update the wrangler.toml file
sed -i "s/^name = .*/name = \"$new_name\"/" wrangler.toml
echo "Updated wrangler.toml name to: $new_name"
- name: Deploy with Wrangler
id: wrangler_deploy
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.79.0"
wranglerVersion: "3.87.0"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
SUPABASE_URL
SUPABASE_KEY
BOT_USER_ID
${{ secrets.KERNEL_PUBLIC_KEY && secrets.KERNEL_PUBLIC_KEY != '' && 'KERNEL_PUBLIC_KEY' || '' }}
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
BOT_USER_ID: ${{ secrets.BOT_USER_ID }}
KERNEL_PUBLIC_KEY: ${{ secrets.KERNEL_PUBLIC_KEY }}

- name: Write Deployment URL to Summary
run: |
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
coverage/
Binary file added bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default tsEslint.config({
"@typescript-eslint": tsEslint.plugin,
"check-file": checkFile,
},
ignores: [".github/knip.ts", ".github/cspell.ts", ".wrangler/**/*.ts", ".wrangler/**/*.js"],
ignores: [".github/knip.ts", ".github/cspell.ts", ".wrangler/**/*.ts", ".wrangler/**/*.js", "dist/**", "eslint.config.mjs"],
extends: [eslint.configs.recommended, ...tsEslint.configs.recommended, sonarjs.configs.recommended],
languageOptions: {
parser: tsEslint.parser,
Expand Down
17 changes: 3 additions & 14 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"name": "Start | Stop",
"description": "Assign or un-assign yourself from an issue/task.",
"ubiquity:listeners": [
"issue_comment.created",
"issues.assigned",
"issues.unassigned",
"pull_request.opened",
"pull_request.edited"
],
"ubiquity:listeners": ["issue_comment.created", "issues.assigned", "issues.unassigned", "pull_request.opened", "pull_request.edited"],
"commands": {
"start": {
"ubiquity:example": "/start",
Expand Down Expand Up @@ -85,12 +79,7 @@
"type": "string"
},
"rolesWithReviewAuthority": {
"default": [
"OWNER",
"ADMIN",
"MEMBER",
"COLLABORATOR"
],
"default": ["OWNER", "ADMIN", "MEMBER", "COLLABORATOR"],
"uniqueItems": true,
"type": "array",
"items": {
Expand Down Expand Up @@ -133,4 +122,4 @@
"requiredLabelsToStart"
]
}
}
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,5 @@
"extends": [
"@commitlint/config-conventional"
]
},
"packageManager": "[email protected]"
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* Modules */
"module": "CommonJS" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
Expand Down
Loading

0 comments on commit 688dfbb

Please sign in to comment.