From fbe8f1a08b9e43991e7353fb490241f07d7328a4 Mon Sep 17 00:00:00 2001 From: Na'aman Hirschfeld Date: Sat, 2 Dec 2023 08:49:51 +0100 Subject: [PATCH] chore: added git submodule for gateway proto --- .commitlintrc | 5 + .deepsource.toml | 15 +++ .github/dependabot.yaml | 6 + .github/workflows/pr-agent.yaml | 18 +++ .github/workflows/pr-title.yaml | 20 ++++ .github/workflows/validate.yaml | 36 ++++++ .gitmodules | 3 + .pre-commit-config.yaml | 32 ++++++ .prettierignore | 1 + .prettierrc | 8 ++ Package.resolved | 8 +- SECURITY.md | 5 + Taskfile.yaml | 189 +------------------------------- proto/gateway | 1 + 14 files changed, 159 insertions(+), 188 deletions(-) create mode 100644 .commitlintrc create mode 100644 .deepsource.toml create mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/pr-agent.yaml create mode 100644 .github/workflows/pr-title.yaml create mode 100644 .github/workflows/validate.yaml create mode 100644 .gitmodules create mode 100644 .pre-commit-config.yaml create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 SECURITY.md create mode 160000 proto/gateway diff --git a/.commitlintrc b/.commitlintrc new file mode 100644 index 0000000..0df1d25 --- /dev/null +++ b/.commitlintrc @@ -0,0 +1,5 @@ +{ + "extends": [ + "@commitlint/config-conventional" + ] +} diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..51ffe88 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,15 @@ +version = 1 + +exclude_patterns = ["package/**", "example-app/**"] + +test_patterns = ["**/Tests/**"] + +[[analyzers]] +name = "test-coverage" +enabled = true + +[[analyzers]] +name = "swift" + +[analyzers.meta] +swift_version = "5.9" diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..1124bf5 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'daily' diff --git a/.github/workflows/pr-agent.yaml b/.github/workflows/pr-agent.yaml new file mode 100644 index 0000000..49c7e50 --- /dev/null +++ b/.github/workflows/pr-agent.yaml @@ -0,0 +1,18 @@ +name: CodiumAI PR Agent +on: + pull_request: + issue_comment: +jobs: + pr_agent: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + contents: write + steps: + - name: Exec PR Agent + id: pragent + uses: Codium-ai/pr-agent@main + env: + OPENAI_KEY: ${{ secrets.OPENAI_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr-title.yaml b/.github/workflows/pr-title.yaml new file mode 100644 index 0000000..76fb2c3 --- /dev/null +++ b/.github/workflows/pr-title.yaml @@ -0,0 +1,20 @@ +name: 'Lint PR Title' + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +permissions: + pull-requests: read + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml new file mode 100644 index 0000000..d090431 --- /dev/null +++ b/.github/workflows/validate.yaml @@ -0,0 +1,36 @@ +name: 'Validate' +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + validate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Swift + uses: swift-actions/setup-swift@v1 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 21 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Install Task + uses: arduino/setup-task@v1 + - name: Install Pre-Commit + run: python -m pip install pre-commit && pre-commit install + - name: Load Cached Pre-Commit Dependencies + id: cached-pre-commit-dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit/ + key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Lint + run: task lint diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..277d798 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "proto/gateway"] + path = proto/gateway + url = https://github.com/basemind-ai/gateway-proto diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..66861c8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +default_stages: [commit] +repos: + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: "v9.10.0" + hooks: + - id: commitlint + stages: [commit-msg] + additional_dependencies: + - "@commitlint/cli" + - "@commitlint/config-conventional" + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v4.5.0" + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + exclude: "package" + - id: check-yaml + - id: check-added-large-files + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v3.1.0" + hooks: + - id: prettier + exclude: "package" + - repo: github.com/nicklockwood/SwiftFormat + rev: "" + hooks: + - id: swiftformat + - repo: github.com/realm/SwiftLint + rev: "" + hooks: + - id: swiftlint + entry: swiftlint --fix --strict diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..f65519e --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +build/** diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..3f5e934 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "quoteProps": "consistent", + "semi": true, + "singleQuote": true, + "tabWidth": 4, + "trailingComma": "all", + "useTabs": true +} diff --git a/Package.resolved b/Package.resolved index 0d0c641..989545a 100644 --- a/Package.resolved +++ b/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-http-types", "state" : { - "revision" : "99d066e29effa8845e4761dd3f2f831edfdf8925", - "version" : "1.0.0" + "revision" : "4c542094de9b8316809a28ef51c434ee6ce6ee43", + "version" : "1.0.1" } }, { @@ -95,8 +95,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { - "revision" : "07f7f26ded8df9645c072f220378879c4642e063", - "version" : "1.25.1" + "revision" : "65e8f29b2d63c4e38e736b25c27b83e012159be8", + "version" : "1.25.2" } } ], diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..5049216 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +# Security Policy + +## Reporting a Vulnerability + +Please open an issue on GitHub. diff --git a/Taskfile.yaml b/Taskfile.yaml index 89ccd34..d7f34ff 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -1,196 +1,17 @@ -version: '3' +version: "3" tasks: - # project dependencies - install-pnpm: - cmds: - - | - if command -v brew &> /dev/null; then - brew install pnpm - else - npm install -g pnpm - fi - status: - - command -v pnpm &> /dev/null || exit 1 - install-pre-commit: - cmds: - - | - if command -v brew &> /dev/null; then - brew install pre-commit - else - pip install pre-commit - fi - status: - - command -v pre-commit &> /dev/null || exit 1 - install-sqlc: - cmds: - - | - if command -v brew &> /dev/null; then - brew install sqlc - else - go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest - fi - status: - - command -v sqlc &> /dev/null || exit 1 - install-atlas: - cmds: - - | - if command -v brew &> /dev/null; then - brew install ariga/tap/atlas - else - curl -sSf https://atlasgo.sh | sh - fi - status: - - command -v atlas &> /dev/null || exit 1 - install-buf: - cmds: - - | - if command -v brew &> /dev/null; then - brew install bufbuild/buf/buf - else - npm install -g @bufbuild/buf - fi - status: - - command -v buf &> /dev/null || exit 1 - install-terraform: - cmds: - - | - if command -v brew &> /dev/null; then - brew tap hashicorp/tap - brew install hashicorp/tap/terraform - brew install tflint - else - curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" - sudo apt-get update && sudo apt-get install terraform - curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash - fi - status: - - command -v terraform &> /dev/null || exit 1 - update-brew: - cmds: - - | - if command -v brew &> /dev/null; then - brew update; - brew upgrade; - brew cleanup || true; - fi setup: desc: Setup the project dependencies cmds: - - task: update-brew - - task: install-pnpm - - task: install-pre-commit - - task: install-sqlc - - task: install-atlas - - task: install-buf - - task: install-terraform - - pre-commit install && pre-commit install --hook-type commit-msg - - pnpm install -r - - go mod download - # repository management - update:android: - cmds: - - ./gradlew wrapper --gradle-version latest - - ./gradlew androidDependencies - - ./gradlew versionCatalogUpdate - lint:android: - desc: Lint the android codebase with in-built lint checks - cmds: - - ./gradlew :sdks:android:sdk:lint - - ./gradlew :sdks:android:test-app:lint - - ./gradlew spotlessApply + - command -v pre-commit &> /dev/null || brew install pre-commit + - pre-commit install && pre-commit install --hook-type commit-msg && pre-commit install-hooks update: - desc: Update the project dependencies cmds: - - task: update-brew - - task: update:android - - pnpm add -g pnpm && pnpm update -r --latest - - go mod tidy && go get -u ./... &> /dev/null - pre-commit autoupdate + - swift package update + - swift outdated lint: desc: Lint the project cmds: - pre-commit run --show-diff-on-failure --color=always --all-files - - task: lint:android - # database - db:up: - desc: Bring up the local database - cmds: - - docker compose stop && docker compose up db --detach - db:down: - desc: Tear down the local database - cmds: - - docker compose down db - migrations:apply: - desc: Apply the migrations to the local database - cmds: - - task: db:up - - sleep 2 - - atlas migrate apply --dir "file://sql/migrations" --url "postgresql://basemind:basemind@localhost:5432/basemind?search_path=public&sslmode=disable" - migrations:create: - desc: Create a new migration - cmds: - - task: db:up - - sleep 2 - - atlas migrate diff {{.CLI_ARGS}} --dir "file://sql/migrations" --to "file://sql/schema.sql" --dev-url "postgresql://basemind:basemind@localhost:5432/basemind?search_path=public&sslmode=disable" - slqc:generate: - desc: Generate the database code from the sqlc.yaml file - cmds: - - rm -rf shared/go/db/models - - sqlc generate - slqc:vet: - desc: Lint the database schema - cmds: - - task: db:up - - sleep 2 - - sqlc vet - # protobuf - buf:generate: - desc: Generate gRPC types and code from proto files - cmds: - - rm -rf gen - - npx buf generate - - rm -rf gen/go/openai - - rm -rf gen/go/cohere - - rm -rf gen/ts/gateway - - rm -rf gen/ts/ptesting - - rm -rf sdks/ios/Sources/BaseMindGateway - - mv gen/swift/gateway/v1 sdks/ios/Sources/BaseMindGateway - - rm -rf gen/swift - buf:lint: - desc: Lint the protobuf files - cmds: - - npx buf lint - buf:format: - desc: Format the protobuf files - cmds: - - npx buf format - # testing - e2e:seed: - desc: Seed the local database with testing data - cmds: - - task: db:up - - go run e2e/main.go seed - e2e:clean: - desc: Clean the local database of all testing data - cmds: - - task: db:up - - go run e2e/main.go clean - e2e:create-jwt: - desc: Create a JWT from the given applicationId arg - cmds: - - go run e2e/main.go create-jwt {{.CLI_ARGS}} - # gcp commands - gcp:deploy-emailsender: - desc: Deploys the email sender cloud function to GCP - dir: cloud-functions/emailsender - cmds: - - | - gcloud functions deploy email-sender \ - --gen2 \ - --runtime=go121 \ - --region=europe-west3 \ - --source=. \ - --entry-point=SendgridEmailPubSub \ - --trigger-topic=send-email diff --git a/proto/gateway b/proto/gateway new file mode 160000 index 0000000..7d6dc8e --- /dev/null +++ b/proto/gateway @@ -0,0 +1 @@ +Subproject commit 7d6dc8e579aa8514fd83dbde6ae00bc056aac2d8