CI: Local and Deployment Project Tests #1128
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: | |
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 }} | |
US1_UPSTASH_REDIS_REST_URL: ${{ secrets.US1_UPSTASH_REDIS_REST_URL }} | |
US1_UPSTASH_REDIS_REST_TOKEN: ${{ secrets.US1_UPSTASH_REDIS_REST_TOKEN }} | |
APN_UPSTASH_REDIS_REST_URL: ${{ secrets.APN_UPSTASH_REDIS_REST_URL }} | |
APN_UPSTASH_REDIS_REST_TOKEN: ${{ secrets.APN_UPSTASH_REDIS_REST_TOKEN }} | |
EU2_UPSTASH_REDIS_REST_URL: ${{ secrets.EU2_UPSTASH_REDIS_REST_URL }} | |
EU2_UPSTASH_REDIS_REST_TOKEN: ${{ secrets.EU2_UPSTASH_REDIS_REST_TOKEN }} | |
jobs: | |
test: | |
runs-on: | |
group: large-runners | |
labels: ubuntu-4x | |
name: Tests | |
steps: | |
- name: Setup repo | |
uses: actions/checkout@v2 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install | |
# - name: Run tests | |
# run: bun run test | |
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/ratelimit@../.. | |
working-directory: examples/cloudflare-workers | |
- name: Add environment | |
run: | | |
echo '[vars]' >> wrangler.toml | |
echo "UPSTASH_REDIS_REST_URL = \"$UPSTASH_REDIS_REST_URL\"" >> ./wrangler.toml | |
echo "UPSTASH_REDIS_REST_TOKEN = \"$UPSTASH_REDIS_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 | |
release: | |
name: Release | |
concurrency: release | |
needs: | |
- cloudflare-workers-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=canary | |
- name: Sleep | |
run: sleep 5 |