Tests #615
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
schedule: | |
- cron: "0 0 * * *" # daily | |
env: | |
UPSTASH_VECTOR_REST_URL: ${{ secrets.UPSTASH_VECTOR_REST_URL }} | |
UPSTASH_VECTOR_REST_TOKEN: ${{ secrets.UPSTASH_VECTOR_REST_TOKEN }} | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
concurrency: test | |
name: Tests | |
steps: | |
- name: Setup repo | |
uses: actions/checkout@v3 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install Dependencies | |
run: bun install | |
- name: Run Lint | |
run: bun run fmt | |
- name: Run tests | |
run: bun run test | |
- name: Run Build | |
run: bun run build | |
cloudflare-workers-local: | |
needs: | |
- test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup repo | |
uses: actions/checkout@v3 | |
- name: Setup nodejs | |
uses: actions/setup-node@v3 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install | |
- name: Build | |
run: bun run build | |
- name: Install example | |
run: bun add @upstash/vector@../.. | |
working-directory: examples/cloudflare-workers | |
- name: Add environment | |
run: | | |
echo '[vars]' >> wrangler.toml | |
echo "UPSTASH_VECTOR_REST_URL = \"$UPSTASH_VECTOR_REST_URL\"" >> ./wrangler.toml | |
echo "UPSTASH_VECTOR_REST_TOKEN = \"$UPSTASH_VECTOR_REST_TOKEN\"" >> ./wrangler.toml | |
working-directory: examples/cloudflare-workers | |
- name: Start example | |
run: bun dev & | |
working-directory: examples/cloudflare-workers | |
- name: Run tests | |
run: bun test ci.test.ts | |
working-directory: examples/cloudflare-workers | |
env: | |
DEPLOYMENT_URL: http://127.0.0.1:8787 | |
cloudflare-workers-deployed: | |
concurrency: cloudflare-workers-deployed | |
needs: | |
- release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup repo | |
uses: actions/checkout@v3 | |
- name: Setup nodejs | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install example | |
run: | | |
bun add @upstash/vector@${{needs.release.outputs.version}} | |
npm i -g wrangler | |
working-directory: examples/cloudflare-workers | |
- name: Add account ID | |
run: echo 'account_id = "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}"' >> wrangler.toml | |
working-directory: examples/cloudflare-workers | |
- name: Add environment | |
run: | | |
echo '[vars]' >> wrangler.toml | |
echo "UPSTASH_VECTOR_REST_URL = \"$UPSTASH_VECTOR_REST_URL\"" >> ./wrangler.toml | |
echo "UPSTASH_VECTOR_REST_TOKEN = \"$UPSTASH_VECTOR_REST_TOKEN\"" >> ./wrangler.toml | |
working-directory: examples/cloudflare-workers | |
- name: Deploy | |
run: wrangler publish | |
working-directory: examples/cloudflare-workers | |
env: | |
CLOUDFLARE_API_TOKEN: ${{secrets.CLOUDFLARE_API_TOKEN}} | |
- name: Test | |
run: bun test examples/cloudflare-workers/ci.test.ts | |
env: | |
DEPLOYMENT_URL: https://upstash-vector.upsdev.workers.dev | |
nextjs-local: | |
needs: | |
- test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup repo | |
uses: actions/checkout@v3 | |
- name: Setup nodejs | |
uses: actions/setup-node@v3 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install Dependencies | |
run: bun install | |
- name: Build | |
run: bun run build | |
- name: Install example | |
run: bun add @upstash/vector@../.. | |
working-directory: examples/nextjs | |
- name: Build example | |
run: bun run build | |
working-directory: examples/nextjs | |
- name: Run example | |
run: npm run start & | |
working-directory: examples/nextjs | |
- name: Test | |
run: bun test ci.test.ts | |
working-directory: examples/nextjs | |
env: | |
DEPLOYMENT_URL: http://localhost:3000 | |
nextjs-deployed: | |
concurrency: nextjs-deployed | |
runs-on: ubuntu-latest | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }} | |
VERCEL_PROJECT_ID: "prj_TmF7Y5rOxDXmq7FmuzCpL41ol7zo" | |
UPSTASH_VECTOR_REST_URL: ${{ secrets.UPSTASH_VECTOR_REST_URL }} | |
UPSTASH_VECTOR_REST_TOKEN: ${{ secrets.UPSTASH_VECTOR_REST_TOKEN }} | |
needs: | |
- release | |
steps: | |
- name: Setup repo | |
uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Install @upstash/vector canary version | |
run: npm install @upstash/vector@${{needs.release.outputs.version}} | |
working-directory: examples/nextjs | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} | |
working-directory: examples/nextjs | |
- name: Install dependencies | |
run: bun install | |
working-directory: examples/nextjs | |
- name: Build Project | |
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} | |
working-directory: examples/nextjs | |
- name: Deploy to Vercel | |
run: | | |
DEPLOYMENT_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} \ | |
--env UPSTASH_VECTOR_REST_URL=${{ secrets.UPSTASH_VECTOR_REST_URL }} \ | |
--env UPSTASH_VECTOR_REST_TOKEN=${{ secrets.UPSTASH_VECTOR_REST_TOKEN }}) | |
echo "DEPLOYMENT_URL=${DEPLOYMENT_URL}" >> $GITHUB_ENV | |
working-directory: examples/nextjs | |
- name: Test | |
run: bun test ci.test.ts | |
working-directory: examples/nextjs | |
release: | |
name: Release | |
concurrency: release | |
needs: | |
- cloudflare-workers-local | |
- nextjs-local | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
- name: Get version | |
id: version | |
run: echo "::set-output name=version::v0.0.0-ci.${GITHUB_SHA}-$(date +%Y%m%d%H%M%S)" | |
- name: Setup Node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18 | |
- name: Set package version | |
run: echo $(jq --arg v "${{ steps.version.outputs.version }}" '(.version) = $v' package.json) > package.json | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install | |
- name: Build | |
run: bun run build | |
- name: Add npm token | |
run: echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" > .npmrc | |
- name: Publish release candidate | |
run: npm publish --access public --tag=ci | |
- name: Sleep | |
run: sleep 5 |