-
Notifications
You must be signed in to change notification settings - Fork 41
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
CI: Local and Deployment Project Tests #123
Merged
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
09408ff
ci(tests): add cf local example
fahreddinozcan 9023d20
ci(tests.yaml): add release step
fahreddinozcan b1a4f53
ci(tests.yaml): add deploy cf workers step
fahreddinozcan 20ad940
ci(tests.yaml): add local nextjs project test
fahreddinozcan bfe34c4
ci(tests.yaml): update release step needs
fahreddinozcan 197f03b
fix: next.js example types deps
fahreddinozcan eefa3f9
fix: next.js example types deps
fahreddinozcan e674c63
fix
fahreddinozcan a9e79f3
ci:(tests.yaml): add next.js deployed example
fahreddinozcan dbe4ed9
fix
fahreddinozcan ed27ec6
fix
fahreddinozcan 388e5fd
enable tests
fahreddinozcan 1ea3755
test pipeline
fahreddinozcan ff4ad00
remove redundancy
fahreddinozcan 31ab84f
cleanup env variables
fahreddinozcan 6c84d45
re-enable flaky tests
fahreddinozcan 4a5455d
fix(nextjs example): remove index.ts
fahreddinozcan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,237 @@ jobs: | |
|
||
- 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 | ||
|
||
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/ratelimit@${{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_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: 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-ratelimit.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/ratelimit@../.. | ||
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 | ||
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: Pull Vercel Environment Information | ||
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} | ||
env: | ||
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }} | ||
VERCEL_PROJECT_ID: "prj_NSOSq2ZawugKhtZGb3ViHX4b56hx" | ||
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 }} | ||
env: | ||
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }} | ||
VERCEL_PROJECT_ID: "prj_NSOSq2ZawugKhtZGb3ViHX4b56hx" | ||
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }} | ||
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }} | ||
working-directory: examples/nextjs | ||
|
||
- name: Deploy to Vercel | ||
run: | | ||
DEPLOYMENT_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} \ | ||
--env UPSTASH_REDIS_REST_URL=${{ secrets.UPSTASH_REDIS_REST_URL }} \ | ||
--env UPSTASH_REDIS_REST_TOKEN=${{ secrets.UPSTASH_REDIS_REST_TOKEN }}) | ||
echo "DEPLOYMENT_URL=${DEPLOYMENT_URL}" >> $GITHUB_ENV | ||
env: | ||
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }} | ||
VERCEL_PROJECT_ID: "prj_NSOSq2ZawugKhtZGb3ViHX4b56hx" | ||
working-directory: examples/nextjs | ||
|
||
- name: Test | ||
run: bun test ci.test.ts | ||
working-directory: examples/nextjs | ||
env: | ||
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }} | ||
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }} | ||
|
||
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=canary | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ci |
||
|
||
- name: Sleep | ||
run: sleep 5 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm nitpicking here but we don't need these since they are given in the top level anyways. It should work without these lines