Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependabot and CI to integrations #2149

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/packages/dolt/integrations"
schedule:
interval: monthly
time: "06:30"
timezone: America/Los_Angeles
open-pull-requests-limit: 5
reviewers:
- liuliu-dev
labels:
- dependencies
25 changes: 25 additions & 0 deletions .github/workflows/ci-dolt-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Run CI on dolt/integration
on:
pull_request:
paths:
- "packages/dolt/integration/**"
workflow_dispatch:

concurrency:
group: ci-integration-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
ci:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install and run CI
working-directory: ./packages/dolt/integration
run: |
yarn
yarn run ci
11 changes: 8 additions & 3 deletions packages/dolt/integration/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"name": "embedDoltHubSQL",
"name": "embed-dolthub-sql",
"private": true,
"scripts": {
"ci": "yarn ignore-node-modules && yarn typecheck && yarn lint",
"ignore-node-modules": "sh ./ts-ignore-node-modules.sh",
"lint": "eslint ./**/*.ts*",
"typecheck": "tsc --noEmit",
"publish-integrations": "gitbook publish .",
"publish-integrations-staging": "gitbook publish ."
},
"devDependencies": {
"@cloudflare/workers-types": "latest",
"@gitbook/api": "*",
"@gitbook/cli": "^0.9.0",
"@gitbook/eslint-config": "^0.1.0",
"@gitbook/runtime": "latest",
"@cloudflare/workers-types": "latest",
"@gitbook/tsconfig": "latest",
"@gitbook/api": "*"
"eslint": "^8",
"typescript": "^5.4.5"
}
}
101 changes: 50 additions & 51 deletions packages/dolt/integration/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,68 @@
import {
FetchEventCallback,
RuntimeContext,
RuntimeEnvironment,
createComponent,
createIntegration,
} from "@gitbook/runtime";
FetchEventCallback,
RuntimeContext,
RuntimeEnvironment,
createComponent,
createIntegration,
} from '@gitbook/runtime';

interface EmbedDoltHubSQLConfiguration {}

type EmbedDoltHubSQLRuntimeEnvironment =
RuntimeEnvironment<EmbedDoltHubSQLConfiguration>;
type EmbedDoltHubSQLRuntimeContext =
RuntimeContext<EmbedDoltHubSQLRuntimeEnvironment>;
type EmbedDoltHubSQLRuntimeEnvironment = RuntimeEnvironment<EmbedDoltHubSQLConfiguration>;
type EmbedDoltHubSQLRuntimeContext = RuntimeContext<EmbedDoltHubSQLRuntimeEnvironment>;

const handleFetchEvent: FetchEventCallback<
EmbedDoltHubSQLRuntimeContext
> = async (request, context) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { api } = context;
const user = api.user.getAuthenticatedUser();
const handleFetchEvent: FetchEventCallback<EmbedDoltHubSQLRuntimeContext> = async (_, context) => {
const { api } = context;
const user = api.user.getAuthenticatedUser();

return new Response(JSON.stringify(user));
return new Response(JSON.stringify(user));
};

/**
* Component to render the block when embeding an DoltHub URL.
* Component to render the block when embedding an DoltHub URL.
*/
const embedBlock = createComponent<{
url?: string;
}>({
componentId: "embed",
type Props = {
url: string;
};

const embedBlock = createComponent<Props>({
componentId: 'embed',

async action(element, action) {
switch (action.action) {
case "@link.unfurl": {
const { url } = action;
async action(element, action) {
// @ts-ignore
switch (action.action) {
case '@link.unfurl': {
// @ts-ignore
const { url } = action;

return {
props: {
url,
},
};
}
}
return {
props: {
url,
},
};
}
}

return element;
},
return element;
},

async render(element, context) {
const { url } = element.props;
const aspectRatio = 16 / 9;
return (
<block>
<webframe
source={{
url: url,
}}
aspectRatio={aspectRatio}
/>
</block>
);
},
async render(element) {
const { url } = element.props;
const aspectRatio = 16 / 9;
return (
<block>
<webframe
source={{
url,
}}
aspectRatio={aspectRatio}
/>
</block>
);
},
});

export default createIntegration<EmbedDoltHubSQLRuntimeContext>({
fetch: handleFetchEvent,
components: [embedBlock],
fetch: handleFetchEvent,
components: [embedBlock],
});
1 change: 1 addition & 0 deletions packages/dolt/integration/ts-ignore-node-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
find node_modules -type f -name '*.ts' -exec sh -c 'echo "// @ts-nocheck" > /tmp/file.tmp && cat "$1" >> /tmp/file.tmp && mv /tmp/file.tmp "$1"' _ {} \;
3 changes: 2 additions & 1 deletion packages/dolt/integration/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "@gitbook/tsconfig/integration.json",
"compilerOptions": {
"lib": ["ES6", "DOM"]
"lib": ["ES6", "DOM"],
"skipLibCheck": true,
}
}
Loading