Skip to content
Draft
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
65 changes: 65 additions & 0 deletions .github/workflows/tinybird-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Tinybird CD

on:
workflow_dispatch:
push:
branches:
- main
- master
paths:
- 'tinybird/**'

concurrency: ${{ github.workflow }}-${{ github.event.ref }}

permissions:
contents: read

env:
TINYBIRD_HOST: ${{ secrets.TINYBIRD_HOST }}
TINYBIRD_TOKEN: ${{ secrets.TINYBIRD_TOKEN }}
# URL must point at a pinned Tinybird CLI installer or binary published by Tinybird
# (e.g., a GitHub Release asset). The checksum must be computed from that asset and
# stored in secrets so we can detect tampering before executing the installer.
TINYBIRD_INSTALLER_URL: ${{ vars.TINYBIRD_INSTALLER_URL }}
TINYBIRD_INSTALLER_SHA256: ${{ secrets.TINYBIRD_INSTALLER_SHA256 }}

jobs:
cd:
name: Deploy
runs-on: ubuntu-latest
defaults:
run:
working-directory: 'tinybird'
steps:
- uses: actions/checkout@v3

- name: Install Tinybird CLI
env:
INSTALLER_URL: ${{ env.TINYBIRD_INSTALLER_URL }}
INSTALLER_SHA256: ${{ env.TINYBIRD_INSTALLER_SHA256 }}
run: |
set -euo pipefail

if [[ -z "${INSTALLER_URL:-}" ]]; then
echo "TINYBIRD_INSTALLER_URL repo variable is not set. Point it to the" >&2
echo "pinned Tinybird CLI release asset (e.g., https://github.com/tinybirdco/... )." >&2
exit 1
fi

if [[ -z "${INSTALLER_SHA256:-}" ]]; then
echo "TINYBIRD_INSTALLER_SHA256 secret is not defined." >&2
echo "Store the SHA-256 computed from the trusted release asset so tampering" >&2
echo "causes the workflow to fail before execution." >&2
exit 1
fi

installer_path="/tmp/tinybird-cli-installer"
curl -fSL "$INSTALLER_URL" -o "$installer_path"

echo "${INSTALLER_SHA256} ${installer_path}" | sha256sum -c -

chmod +x "$installer_path"
"$installer_path"

- name: Deploy project
run: tb --cloud --host ${{ env.TINYBIRD_HOST }} --token ${{ env.TINYBIRD_TOKEN }} deploy
99 changes: 99 additions & 0 deletions .github/workflows/tinybird-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Tinybird CI

on:
workflow_dispatch:
pull_request:
branches:
- main
- master
paths:
- 'tinybird/**'
types: [opened, reopened, labeled, unlabeled, synchronize]

concurrency: ${{ github.workflow }}-${{ github.event.pull_request.number }}

permissions:
contents: read

env:
TINYBIRD_HOST: ${{ secrets.TINYBIRD_HOST }}
TINYBIRD_TOKEN: ${{ secrets.TINYBIRD_TOKEN }}
TINYBIRD_INSTALLER_URL: ${{ vars.TINYBIRD_INSTALLER_URL }}
TINYBIRD_INSTALLER_SHA256: ${{ secrets.TINYBIRD_INSTALLER_SHA256 }}

jobs:
ci:
name: Validate
runs-on: ubuntu-latest
defaults:
run:
working-directory: 'tinybird'
services:
tinybird:
image: tinybirdco/tinybird-local:latest
ports:
- 7181:7181
steps:
- uses: actions/checkout@v3

- name: Install Tinybird CLI
env:
INSTALLER_URL: ${{ env.TINYBIRD_INSTALLER_URL }}
INSTALLER_SHA256: ${{ env.TINYBIRD_INSTALLER_SHA256 }}
run: |
set -euo pipefail

if [[ -z "${INSTALLER_URL:-}" ]]; then
echo "TINYBIRD_INSTALLER_URL repo variable is not set. Point it to the" >&2
echo "pinned Tinybird CLI release asset (e.g., https://github.com/tinybirdco/... )." >&2
exit 1
fi

if [[ -z "${INSTALLER_SHA256:-}" ]]; then
echo "TINYBIRD_INSTALLER_SHA256 secret is not defined." >&2
echo "Store the SHA-256 computed from the trusted release asset so tampering" >&2
echo "causes the workflow to fail before execution." >&2
exit 1
fi

installer_path="/tmp/tinybird-cli-installer"
curl -fSL "$INSTALLER_URL" -o "$installer_path"

echo "${INSTALLER_SHA256} ${installer_path}" | sha256sum -c -

chmod +x "$installer_path"
"$installer_path"

- name: Build project
run: tb build

- name: Wait for Tinybird Local
run: |
set -euo pipefail

endpoints=("http://localhost:7181/_health" "http://localhost:7181/health")
max_attempts=20
base_delay=3

for ((attempt = 1; attempt <= max_attempts; attempt++)); do
for endpoint in "${endpoints[@]}"; do
status=$(curl -fsS -o /dev/null -w "%{http_code}" "$endpoint" || true)
if [[ "$status" == "200" ]]; then
echo "Tinybird local is healthy via $endpoint"
exit 0
fi
done

sleep_seconds=$((base_delay * attempt))
echo "Tinybird local not ready (attempt ${attempt}/${max_attempts}). Retrying in ${sleep_seconds}s..."
sleep "$sleep_seconds"
done

echo "Tinybird local failed to become healthy after waiting ~$((base_delay * max_attempts * (max_attempts + 1) / 2))s" >&2
exit 1

- name: Test project
run: tb test run

- name: Deployment check
run: tb --cloud --host ${{ env.TINYBIRD_HOST }} --token ${{ env.TINYBIRD_TOKEN }} deploy --check
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ tauri.windows.conf.json
# Cursor
.cursor
.env*.local

# Tinybird
.tinyb
28 changes: 0 additions & 28 deletions apps/web/actions/videos/get-analytics.ts

This file was deleted.

6 changes: 3 additions & 3 deletions apps/web/app/(org)/dashboard/caps/Caps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import { useEffectMutation, useRpcClient } from "@/lib/EffectRuntime";
import { useVideosAnalyticsQuery } from "@/lib/Queries/Analytics";
import { usePublicEnv } from "@/utils/public-env";
import { useDashboardContext } from "../Contexts";
import {
NewFolderDialog,
Expand Down Expand Up @@ -55,18 +56,17 @@ export type VideoData = {
export const Caps = ({
data,
count,
dubApiKeyEnabled,
folders,
}: {
data: VideoData;
count: number;
folders: FolderDataType[];
dubApiKeyEnabled: boolean;
}) => {
const router = useRouter();
const params = useSearchParams();
const page = Number(params.get("page")) || 1;
const { user } = useDashboardContext();
const publicEnv = usePublicEnv();
const limit = 15;
const [openNewFolderDialog, setOpenNewFolderDialog] = useState(false);
const totalPages = Math.ceil(count / limit);
Expand All @@ -78,7 +78,7 @@ export const Caps = ({

const analyticsQuery = useVideosAnalyticsQuery(
data.map((video) => video.id),
dubApiKeyEnabled,
publicEnv.analyticsAvailable,
);
const analytics = analyticsQuery.data || {};

Expand Down
7 changes: 1 addition & 6 deletions apps/web/app/(org)/dashboard/caps/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,6 @@ export default async function CapsPage(props: PageProps<"/dashboard/caps">) {
).pipe(runPromise);

return (
<Caps
data={processedVideoData}
folders={foldersData}
count={totalCount}
dubApiKeyEnabled={!!serverEnv().DUB_API_KEY}
/>
<Caps data={processedVideoData} folders={foldersData} count={totalCount} />
);
}
22 changes: 0 additions & 22 deletions apps/web/app/api/analytics/route.ts

This file was deleted.

Loading
Loading