Skip to content

Commit

Permalink
Merge pull request #1 from gentlementlegen/feat/activity-watch
Browse files Browse the repository at this point in the history
feat: user activity watch
  • Loading branch information
gentlementlegen authored Jun 18, 2024
2 parents 77252bb + c36f971 commit ac6aa04
Show file tree
Hide file tree
Showing 60 changed files with 8,021 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "**/*.http", "**/*.toml", "src/types/database.ts", "supabase/migrations/**", "tests/**"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir", "typebox", "supabase", "ubiquibot", "mswjs", "luxon", "millis"],
"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}"]
}
2 changes: 2 additions & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUPABASE_URL=
SUPABASE_KEY=
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUPABASE_URL=
SUPABASE_KEY=
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./** @gentlementlegen
13 changes: 13 additions & 0 deletions .github/knip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { KnipConfig } from "knip";

const config: KnipConfig = {
entry: ["build/index.ts"],
project: ["src/**/*.ts"],
ignore: ["**/__mocks__/**", "**/__fixtures__/**", "src/types/database.ts"],
ignoreExportsUsedInFile: true,
// eslint can also be safely ignored as per the docs: https://knip.dev/guides/handling-issues#eslint--jest
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "eslint-plugin-filename-rules", "eslint-plugin-sonarjs", "@types/jest", "msw"],
eslint: true,
};

export default config;
6 changes: 6 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Resolves #

<!--
- You must link the issue number e.g. "Resolves #1234"
- Please do not replace the keyword "Resolves" https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->
40 changes: 40 additions & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Watch Activity

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: User Activity Watcher
runs-on: ubuntu-latest
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}

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: Watch Activity
uses: ./
12 changes: 12 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Conventional Commits

on:
push:

jobs:
conventional-commits:
name: Conventional Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ubiquity/action-conventional-commits@master
24 changes: 24 additions & 0 deletions .github/workflows/cspell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Spell Check

on:
push:

jobs:
spellcheck:
name: Check for spelling errors
runs-on: ubuntu-latest

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

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

- name: Install cspell
run: yarn add cspell

- name: Run cspell
run: yarn format:cspell
67 changes: 67 additions & 0 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Database

on:
push:
branches:
- main

env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}

jobs:
run-migration:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- uses: supabase/setup-cli@v1
with:
version: latest

- name: Link Supabase project
run: supabase link --project-ref $SUPABASE_PROJECT_ID

- name: Run migrations
run: supabase db push

generate_types:
runs-on: ubuntu-latest
needs:
- run-migration
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Generate Supabase Types
run: |
yarn install
yarn run "supabase:generate:remote"
- name: Commit and Push generated types
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add src/types/database.ts
if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then
git commit -m "chore: updated generated Supabase types" || echo "Lint-staged check failed"
git push origin main
else
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy to Cloudflare Pages

on:
workflow_dispatch:

jobs:
deploy-to-cloudflare:
name: Automatic Cloudflare Deploy
runs-on: ubuntu-22.04
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- uses: actions/checkout@v4
- uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: '3.57.0'
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
secrets: |
SUPABASE_URL
SUPABASE_KEY
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
33 changes: 33 additions & 0 deletions .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run Jest testing suite
on:
workflow_dispatch:
workflow_run:
workflows: ["Knip"]
types:
- completed

env:
NODE_ENV: "test"
SUPABASE_URL: "http://127.0.0.1:54321"
SUPABASE_KEY: "key"

jobs:
testing:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: "20.10.0"

- uses: actions/checkout@master
with:
fetch-depth: 0

- name: Jest With Coverage Comment
# Ensures this step is run even on previous step failure (e.g. test failed)
if: always()
uses: ArtiomTr/jest-coverage-report-action@v2
with:
package-manager: yarn
prnumber: ${{ github.event.pull_request.number || github.event.workflow_run.pull_requests[0].number }}
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 }}
35 changes: 35 additions & 0 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Knip

on:
pull_request:
workflow_dispatch:

jobs:
run-knip:
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

- 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:
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
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# macOS
.DS_Store
# node
node_modules
# yarn2
.yarn
.pnp.cjs
.pnp.loader.mjs
.env
static/dist
coverage
junit.xml
cypress/screenshots
.dev.vars
/tests/http/http-client.private.env.json
.wrangler
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.10.0
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"printWidth": 160,
"htmlWhitespaceSensitivity": "strict",
"plugins": [],
"useTabs": false
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
Loading

0 comments on commit ac6aa04

Please sign in to comment.