Skip to content

Tests

Tests #1544

Workflow file for this run

name: Tests
on:
push:
branches:
- main
pull_request:
schedule:
- cron: "0 0 * * *" # daily
env:
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
jobs:
test:
runs-on: ubuntu-latest
concurrency: test
name: Tests
steps:
- name: Setup repo
uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
# - name: Verify formatting
# run: deno fmt --check
# - name: Lint
# run: deno lint
- name: Run tests
run: deno test -A --fail-fast --shuffle ./pkg
- name: Build
run: deno run -A ./cmd/build.ts
netlify-local:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Build
run: deno run -A ./cmd/build.ts
- name: Install example
run: |
pnpm add @upstash/redis@../../dist
npm i -g netlify-cli
working-directory: ./examples/netlify
- name: Start example
run: netlify dev --port 15015 & sleep 10
working-directory: ./examples/netlify
- name: Test
run: deno test --allow-net --allow-env ./examples/netlify/test.ts
env:
DEPLOYMENT_URL: http://localhost:15015
netlify-deployed:
concurrency: netlify-deployed
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Install @upstash/redis
run: pnpm add @upstash/redis@${{needs.release.outputs.version}}
working-directory: ./examples/netlify
- name: Deploy
run: |
DEPLOYMENT_URL=$(npx netlify-cli deploy --dir=. --prod --json | jq -r '.deploy_url')
echo "DEPLOYMENT_URL=${DEPLOYMENT_URL}" >> $GITHUB_ENV
working-directory: ./examples/netlify
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: 4da5ba73-dedc-44b2-b27b-fa951c3da512
- name: Test
run: deno test --allow-net --allow-env ./examples/netlify/test.ts
netlify-edge-local:
if: false
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Install Dependencies
run: pnpm install
working-directory: ./examples/netlify
- name: Start
run: |
npx netlify-cli dev --port 15015 & sleep 10
working-directory: ./examples/netlify-edge
- name: Test
run: deno test --allow-net --allow-env ./examples/netlify-edge/test.ts
env:
DEPLOYMENT_URL: http://localhost:15015
netlify-edge-deployed:
if: false
concurrency: netlify-edge-deployed
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Install Dependencies
run: pnpm install
working-directory: ./examples/netlify
- name: Deploy
run: |
DEPLOYMENT_URL=$(npx netlify-cli deploy --dir=. --prod --json | jq -r '.deploy_url')
echo "DEPLOYMENT_URL=${DEPLOYMENT_URL}" >> $GITHUB_ENV
working-directory: ./examples/netlify-edge
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: c3fbfe63-06ee-4aca-8e38-14ba73cb035e
- name: Test
run: deno test --allow-net --allow-env ./examples/netlify-edge/test.ts
nextjs-local:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Build
run: deno run -A ./cmd/build.ts
- name: Install example
run: pnpm add @upstash/redis@../../dist
working-directory: ./examples/nextjs
- name: Build example
run: pnpm build
working-directory: ./examples/nextjs
- name: Start example
run: pnpm start &
working-directory: ./examples/nextjs
env:
NEXT_PUBLIC_UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
NEXT_PUBLIC_UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
- name: Test
run: deno test --allow-net --allow-env ./examples/nextjs/test.ts
env:
DEPLOYMENT_URL: http://localhost:3000
nextjs-export-local:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Build
run: deno run -A ./cmd/build.ts
- name: Install example
run: pnpm add @upstash/redis@../../dist
working-directory: ./examples/nextjs_export
- name: Build example
run: pnpm build
working-directory: ./examples/nextjs_export
- name: Start example
run: pnpm start &
working-directory: ./examples/nextjs_export
env:
NEXT_PUBLIC_UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
NEXT_PUBLIC_UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
- name: Test
run: deno test --allow-net --allow-env ./examples/nextjs_export/test.ts
env:
DEPLOYMENT_URL: http://localhost:3000
nextjs-edge-local:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Build
run: deno run -A ./cmd/build.ts
- name: Install example
run: pnpm add @upstash/redis@../../dist
working-directory: ./examples/nextjs_edge
- name: Build example
run: pnpm build
working-directory: ./examples/nextjs_edge
- name: Start example
run: pnpm start & sleep 5
working-directory: ./examples/nextjs_edge
env:
NEXT_PUBLIC_UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
NEXT_PUBLIC_UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
- name: Test
run: deno test --allow-net --allow-env ./examples/nextjs_edge/test.ts
env:
DEPLOYMENT_URL: http://localhost:3000
nextjs-deployed:
concurrency: nextjs-deployed
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Deploy
run: |
pnpm --dir=examples/nextjs add @upstash/redis@${{needs.release.outputs.version}}
DEPLOYMENT_URL=$(npx vercel --token=${{ secrets.VERCEL_TOKEN }})
echo "DEPLOYMENT_URL=${DEPLOYMENT_URL}" >> $GITHUB_ENV
env:
VERCEL_ORG_ID: ${{secrets.VERCEL_TEAM_ID}}
VERCEL_PROJECT_ID: "prj_pFFK1XgNIlnW014iiuqAIQmBBuZA"
- name: Test
run: deno test --allow-net --allow-env ./test.ts
working-directory: examples/nextjs
nextjs-export-deployed:
concurrency: nextjs-export-deployed
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Deploy
run: |
pnpm --dir=examples/nextjs add @upstash/redis@${{needs.release.outputs.version}}
DEPLOYMENT_URL=$(npx vercel --token=${{ secrets.VERCEL_TOKEN }})
echo "DEPLOYMENT_URL=${DEPLOYMENT_URL}" >> $GITHUB_ENV
env:
VERCEL_ORG_ID: ${{secrets.VERCEL_TEAM_ID}}
VERCEL_PROJECT_ID: "prj_O4xbovmJKQ2xLtjhwrtxA3sKpPAY"
- name: Test
run: deno test --allow-net --allow-env ./examples/nextjs/test.ts
nextjs-edge-deployed:
concurrency: nextjs-edge-deployed
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Deploy
run: |
pnpm --dir=examples/nextjs_edge add @upstash/redis@${{needs.release.outputs.version}}
DEPLOYMENT_URL=$(npx vercel --token=${{ secrets.VERCEL_TOKEN }})
echo "DEPLOYMENT_URL=${DEPLOYMENT_URL}" >> $GITHUB_ENV
env:
VERCEL_ORG_ID: ${{secrets.VERCEL_TEAM_ID}}
VERCEL_PROJECT_ID: "prj_bc5kMFz6ifbAaA7U3N86YSYqUUUI"
- name: Test
run: deno test --allow-net --allow-env ./examples/nextjs_edge/test.ts
cloudflare-workers-local:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Build
run: deno run -A ./cmd/build.ts
- name: Install example
run: |
pnpm add @upstash/redis@../../dist
pnpm add -g wrangler
working-directory: examples/cloudflare-workers
- name: Add environment
run: |
echo 'account_id = "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}"' >> wrangler.toml
echo '[vars]' >> wrangler.toml
echo 'UPSTASH_REDIS_REST_URL = "${{ secrets.UPSTASH_REDIS_REST_URL }}"' >> ./wrangler.toml
echo 'UPSTASH_REDIS_REST_TOKEN = "${{ secrets.UPSTASH_REDIS_REST_TOKEN }}"' >> ./wrangler.toml
working-directory: examples/cloudflare-workers
- name: Start example
run: wrangler dev & sleep 5
working-directory: examples/cloudflare-workers
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
- name: Test
run: deno test -A ./test.ts
working-directory: examples/cloudflare-workers
env:
DEPLOYMENT_URL: http://localhost:8787
cloudflare-workers-deployed:
concurrency: cloudflare-workers-deployed
needs:
- release
env:
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Install example
run: |
pnpm add @upstash/redis@${{needs.release.outputs.version}}
pnpm add -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: Deploy
run: wrangler publish
working-directory: examples/cloudflare-workers
env:
CLOUDFLARE_API_TOKEN: ${{secrets.CF_API_TOKEN}}
- name: Test
run: deno test -A ./test.ts
working-directory: examples/cloudflare-workers
env:
DEPLOYMENT_URL: https://upstash-redis.upstash.workers.dev
cloudflare-workers-with-typescript-local:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Build
run: deno run -A ./cmd/build.ts
- name: Install example
run: |
pnpm add @upstash/redis@../../dist
pnpm add -g wrangler
working-directory: examples/cloudflare-workers-with-typescript
- name: Add environment
run: |
echo 'account_id = "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}"' >> wrangler.toml
echo '[vars]' >> wrangler.toml
echo 'UPSTASH_REDIS_REST_URL = "${{ secrets.UPSTASH_REDIS_REST_URL }}"' >> ./wrangler.toml
echo 'UPSTASH_REDIS_REST_TOKEN = "${{ secrets.UPSTASH_REDIS_REST_TOKEN }}"' >> ./wrangler.toml
working-directory: examples/cloudflare-workers-with-typescript
- name: Start example
run: wrangler dev & sleep 5
working-directory: examples/cloudflare-workers-with-typescript
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
- name: Test
run: deno test -A ./test.ts
working-directory: examples/cloudflare-workers-with-typescript
env:
DEPLOYMENT_URL: http://localhost:8787
cloudflare-workers-with-typescript-deployed:
concurrency: cloudflare-workers-with-typescript-deployed
needs:
- release
env:
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Install example
run: |
pnpm add @upstash/redis@${{needs.release.outputs.version}}
pnpm add -g wrangler
working-directory: examples/cloudflare-workers-with-typescript
- name: Add account ID
run: echo 'account_id = "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}"' >> wrangler.toml
working-directory: examples/cloudflare-workers-with-typescript
- name: Deploy
run: wrangler publish
working-directory: examples/cloudflare-workers-with-typescript
env:
CLOUDFLARE_API_TOKEN: ${{secrets.CF_API_TOKEN}}
- name: Test
run: deno test -A ./test.ts
working-directory: examples/cloudflare-workers-with-typescript
env:
DEPLOYMENT_URL: https://cloudflare-workers-with-typescript.upstash.workers.dev
fastly-local:
if: false
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Build
run: deno run -A ./cmd/build.ts
- name: Install example
working-directory: ./examples/fastly
run: |
pnpm add @upstash/redis@../../dist
curl -L https://github.com/fastly/cli/releases/download/v1.7.0/fastly_v1.7.0_linux-amd64.tar.gz > fastly.tar.gz
tar -xf ./fastly.tar.gz
- name: Inject variables
working-directory: ./examples/fastly
run: |
sed -i 's;<UPSTASH_REDIS_REST_URL>;${{ secrets.UPSTASH_REDIS_REST_URL }};' fastly.toml
sed -i 's;<UPSTASH_REDIS_REST_URL>;${{ secrets.UPSTASH_REDIS_REST_URL }};' src/index.js
sed -i 's;<UPSTASH_REDIS_REST_TOKEN>;${{ secrets.UPSTASH_REDIS_REST_TOKEN }};' src/index.js
- name: Start example
working-directory: ./examples/fastly
run: ./fastly compute serve & sleep 10
- name: Test
run: deno test -A ./examples/fastly/test.ts
env:
DEPLOYMENT_URL: http://localhost:7676
fastly-deployed:
if: false
concurrency: fastly-deployed
needs:
- release
env:
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Install example
working-directory: ./examples/fastly
run: |
npm install --global npm@latest
pnpm add @upstash/redis@${{needs.release.outputs.version}}
curl -L https://github.com/fastly/cli/releases/download/v1.7.0/fastly_v1.7.0_linux-amd64.tar.gz > fastly.tar.gz
tar -xf ./fastly.tar.gz
- name: Inject variables
working-directory: ./examples/fastly
run: |
sed -i 's;<UPSTASH_REDIS_REST_URL>;${{ secrets.UPSTASH_REDIS_REST_URL }};' fastly.toml
sed -i 's;<UPSTASH_REDIS_REST_URL>;${{ secrets.UPSTASH_REDIS_REST_URL }};' src/index.js
sed -i 's;<UPSTASH_REDIS_REST_TOKEN>;${{ secrets.UPSTASH_REDIS_REST_TOKEN }};' src/index.js
- name: Deploy
working-directory: ./examples/fastly
run: ./fastly compute publish --service-id=${{ secrets.FASTLY_SERVICE_ID }}
env:
FASTLY_API_TOKEN: ${{secrets.FASTLY_API_TOKEN}}
- run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' https://terminally-flowing-lizard.edgecompute.app)" != "200" ]]; do sleep 1; done
timeout-minutes: 2
- name: Test
run: deno test -A ./examples/fastly/test.ts
env:
DEPLOYMENT_URL: https://terminally-flowing-lizard.edgecompute.app
nodejs-local:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Build
run: deno run -A ./cmd/build.ts
- name: Install example
run: pnpm add @upstash/redis@../../dist
working-directory: examples/nodejs
- name: Run example
run: node ./index.js
working-directory: examples/nodejs
nodejs-18-local:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Build
run: deno run -A ./cmd/build.ts
- name: Install example
run: pnpm add @upstash/redis@../../dist
working-directory: examples/nodejs-18
- name: Run example
run: node ./index.js
working-directory: examples/nodejs-18
deno-local:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Run example
run: deno run -A ./main.ts & sleep 5
working-directory: examples/deno
- name: Test
run: deno test -A ./main.test.ts
working-directory: examples/deno
env:
DEPLOYMENT_URL: http://localhost:8000
deno-deployed:
concurrency: deno-deployed
needs:
- release
env:
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Deploy
run: deno run -A https://deno.land/x/deploy/deployctl.ts deploy --project=upstash-redis ./main.ts
working-directory: examples/deno
env:
DENO_DEPLOY_TOKEN: ${{ secrets.DENO_DEPLOY_TOKEN }}
- name: Test
run: deno test -A ./main.test.ts
working-directory: examples/deno
env:
DEPLOYMENT_URL: https://upstash-redis-70jbfgxwz310.deno.dev
release:
concurrency: release
outputs:
version: ${{ steps.version.outputs.version }}
needs:
- nodejs-local
- nodejs-18-local
# - fastly-local - not working in ci for some reason, local is fine
- nextjs-local
- nextjs-export-local
- nextjs-edge-local
- netlify-local
- deno-local
# - netlify-edge-local - their own cli doesn't work right now. I'll try again in a week
- cloudflare-workers-with-typescript-local
- cloudflare-workers-local
name: Release
runs-on: ubuntu-latest
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::8}-$(date '+%Y%m%d')"
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 18
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Build
run: deno run -A ./cmd/build.ts ${{ steps.version.outputs.version }}
- name: Publish ci version
working-directory: ./dist
run: |
echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" > .npmrc
npm publish --access public --tag=ci