Skip to content

Commit

Permalink
Merge pull request #2 from subquery/CI
Browse files Browse the repository at this point in the history
Setup PR action
  • Loading branch information
stwiname authored Oct 8, 2024
2 parents a8b0a82 + d310eac commit 5d2bda9
Show file tree
Hide file tree
Showing 42 changed files with 2,023 additions and 1,635 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: PR
on:
pull_request:
paths-ignore:
- ".github/workflows/**"

jobs:
test:
name: test
runs-on: ubuntu-latest

permissions:
id-token: write # Needed for auth with Deno Deploy
contents: read # Needed to clone the repository

steps:
- uses: actions/checkout@v4

- uses: denoland/setup-deno@v1
with:
deno-version: 2.0.0-rc.10

- name: Run tests
run: deno task test

code-style:
name: code-style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: denoland/setup-deno@v1
with:
deno-version: 2.0.0-rc.10

- name: Lint
run: deno lint

typescript:
name: typescript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: denoland/setup-deno@v1
with:
deno-version: 2.0.0-rc.10

- name: Check typescript
run: deno task check-ts
67 changes: 67 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Docker Publish
on:
release:
types:
- published
workflow_dispatch:
inputs:
isLatest:
description: "Add latest tag"
default: "true"
required: true

jobs:
publish-docker:
name: test
runs-on: ubuntu-latest

permissions:
id-token: write # Needed for auth with Deno Deploy
contents: read # Needed to clone the repository

steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: subquerynetwork
password: ${{ secrets.SQ_DOCKERHUB_TOKEN }}

# Read the version from deno.json
- name: Extract version
id: extract_version
run: |
version=$(cat deno.json | jq -r '.version')
echo "AI_APP_VERSION=$version" >> $GITHUB_ENV
- name: Build and push
if: github.event_name == 'workflow_dispatch' && github.event.inputs.isLatest == 'false'
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: arm64,amd64
file: ./Dockerfile
tags: subquerynetwork/subql-ai-app
build-args: RELEASE_VERSION=${{ env.AI_APP_VERSION }}

- name: Build and push
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.isLatest == 'true')
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: arm64,amd64
file: ./Dockerfile
tags: subquerynetwork/subql-ai-app:v${{ env.AI_APP_VERSION }},subquerynetwork/subql-ai-app:latest
build-args: RELEASE_VERSION=${{ env.AI_APP_VERSION }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
3 changes: 3 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/hook.sh"
deno run -A npm:lint-staged
6 changes: 6 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"*.ts": [
"deno lint --fix",
"deno fmt"
]
}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM denoland/deno:2.0.0-rc.10

WORKDIR /ai-app

# Prefer not to run as root.
USER deno

COPY . .
RUN deno cache ./src/index.ts

ENTRYPOINT ["./src/index.ts"]

CMD ["-p","/app"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ run a command like so:
## Tests

Running tests: `deno test`

### Installing

To install

`deno install -g -f --allow-env --allow-net --allow-read --allow-write --allow-ffi --allow-run --unstable-worker-options -n subql-ai ./src/index.ts`
2 changes: 1 addition & 1 deletion RESEARCH.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ model:
url: http://localhost:1234

tools:
- name: 'get-balance'
- name: "get-balance"
type: "code"
file: "./get-balance.js"
arguments:
Expand Down
9 changes: 8 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "@subql/ai-app-framework",
"version": "1.0.0-0",
"exports": "./src/index.ts",
"tasks": {
"dev": "deno run --watch src/index.ts",
"test": "deno test --allow-env --allow-net --allow-read --allow-run --allow-write --unstable-worker-options"
"check-ts": "deno check src/index.ts",
"test": "deno test --allow-env --allow-net --allow-read --allow-run --allow-write --unstable-worker-options",
"hook": "deno run --allow-read --allow-run --allow-write https://deno.land/x/[email protected]/mod.ts"
},
"imports": {
"@lancedb/lancedb": "npm:@lancedb/lancedb@^0.10.0",
Expand All @@ -16,6 +21,8 @@
"@std/io": "jsr:@std/io@^0.224.8",
"@std/path": "jsr:@std/path@^1.0.6",
"@std/tar": "jsr:@std/tar@^0.1.1",
"@types/estree": "npm:@types/estree@^1.0.5",
"@types/mdast": "npm:@types/mdast@^4.0.4",
"@types/yargs": "npm:@types/yargs@^17.0.33",
"apache-arrow": "npm:apache-arrow@^17.0.0",
"esbuild": "npm:esbuild@^0.24.0",
Expand Down
Loading

0 comments on commit 5d2bda9

Please sign in to comment.