-
Notifications
You must be signed in to change notification settings - Fork 0
CC-2: Improve Pairing Workflow #322
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4bac10b
CC-2: Improve Pairing Workflow
ianpaschal 1a2c2ee
WIP
ianpaschal ab7b482
CC-64: Add First Playwright Tests (#333)
ianpaschal ae6b7e8
Improve tests
ianpaschal 5b10bdd
Remove deleted workflow files
ianpaschal 7ab101b
Improve tests
ianpaschal ec4d136
Merge branch 'main' into ian/cc-2-improve-pairing-workflow
ianpaschal 38472e0
WIP
ianpaschal 70a4880
PR Feedback
ianpaschal 21a48cc
Update TournamentCompetitorsCard.tsx
ianpaschal e05319b
Final Tweaks
ianpaschal 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | ||
| with: | ||
| node-version: '24' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
|
||
| - name: Unit tests | ||
| run: npm test | ||
|
|
||
| - name: Deploy Convex preview | ||
| run: | | ||
| npx convex deploy \ | ||
| --preview-create "pr-${{ github.event.pull_request.number }}-${{ github.run_attempt }}" \ | ||
| --cmd-url-env-var-name VITE_CONVEX_URL \ | ||
| --cmd 'echo "VITE_CONVEX_URL=$VITE_CONVEX_URL" >> "$GITHUB_ENV"' | ||
| env: | ||
| CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }} | ||
|
|
||
| - name: Configure preview deployment environment | ||
| run: | | ||
| PREVIEW="pr-${{ github.event.pull_request.number }}-${{ github.run_attempt }}" | ||
| npx convex env set --preview-name "$PREVIEW" -- JWT_PRIVATE_KEY "$JWT_PRIVATE_KEY" | ||
| npx convex env set --preview-name "$PREVIEW" -- JWKS "$JWKS" | ||
| npx convex env set --preview-name "$PREVIEW" -- AUTH_RESEND_KEY "$AUTH_RESEND_KEY" | ||
| npx convex env set --preview-name "$PREVIEW" -- SITE_URL "http://localhost:5173" | ||
| env: | ||
| CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }} | ||
| JWT_PRIVATE_KEY: ${{ secrets.CONVEX_JWT_PRIVATE_KEY }} | ||
| JWKS: ${{ secrets.CONVEX_JWKS }} | ||
| AUTH_RESEND_KEY: ${{ secrets.CONVEX_AUTH_RESEND_KEY }} | ||
|
|
||
| - name: Install Playwright browsers | ||
| run: npx playwright install firefox --with-deps | ||
|
|
||
| - name: E2E tests | ||
| run: npm run test:e2e | ||
| env: | ||
| CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }} | ||
| CONVEX_PREVIEW_NAME: pr-${{ github.event.pull_request.number }}-${{ github.run_attempt }} | ||
|
|
||
| - name: Upload Playwright report | ||
| if: failure() | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| with: | ||
| name: playwright-report | ||
| path: playwright-report/ | ||
| retention-days: 7 |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
File renamed without changes.
File renamed without changes.
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export * from './actions/populateUsers'; | ||
| export * from './mutations/cleanUp'; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import type { TableNamesInDataModel } from 'convex/server'; | ||
| import { Infer, v } from 'convex/values'; | ||
|
|
||
| import type { DataModel } from '../../../_generated/dataModel'; | ||
| import type { MutationCtx } from '../../../_generated/server'; | ||
| import schema from '../../../schema'; | ||
|
|
||
| type TableName = TableNamesInDataModel<DataModel>; | ||
|
|
||
| export const cleanUpArgs = v.object({ | ||
| preservedTables: v.array(v.string()), | ||
| }); | ||
|
|
||
| export const cleanUp = async ( | ||
| ctx: MutationCtx, | ||
| args: Infer<typeof cleanUpArgs>, | ||
| ): Promise<void> => { | ||
| const preserved = new Set(args.preservedTables); | ||
| const tables = (Object.keys(schema.tables) as TableName[]).filter((t) => !preserved.has(t)); | ||
| for (const table of tables) { | ||
| const docs = await ctx.db.query(table).collect(); | ||
| await Promise.all(docs.map((doc) => ctx.db.delete(doc._id))); | ||
| } | ||
| }; |
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,36 @@ | ||
| import { tournamentPairingConfig as config } from '@ianpaschal/combat-command-game-systems/common'; | ||
| import { TournamentPairingPolicy } from '@ianpaschal/combat-command-game-systems/common'; | ||
| import { createEnumSchema } from '@ianpaschal/combat-command-game-systems/utils'; | ||
| import { zodToConvex } from 'convex-helpers/server/zod'; | ||
| import { z } from 'zod'; | ||
|
|
||
| export const tournamentPairingConfig = zodToConvex(config.schema); | ||
| import { Id } from '../../_generated/dataModel'; | ||
|
|
||
| export const schema = z.object({ | ||
| orderBy: z.union([z.literal('ranking'), z.literal('random')]), | ||
| policies: z.object({ | ||
| sameAlignment: createEnumSchema(TournamentPairingPolicy), | ||
| repeat: createEnumSchema(TournamentPairingPolicy), | ||
| }), | ||
| tableCount: z.optional(z.number().min(1)), // TODO: REMOVE POST MIGRATION | ||
| }); | ||
|
|
||
| export const generationSchema = schema.extend({ | ||
| include: z.array(z.string()).transform((val): Id<'tournamentCompetitors'>[] => val as Id<'tournamentCompetitors'>[]), | ||
| }); | ||
|
|
||
| export type TournamentPairingConfig = z.infer<typeof schema>; | ||
|
|
||
| export type TournamentPairingPolicies = Partial<TournamentPairingConfig['policies']>; | ||
|
|
||
| export const defaultValues = { | ||
| orderBy: 'ranking', | ||
| policies: { | ||
| sameAlignment: TournamentPairingPolicy.Allow, | ||
| repeat: TournamentPairingPolicy.Block, | ||
| }, | ||
| tableCount: 1, | ||
| } satisfies TournamentPairingConfig; | ||
|
|
||
| export const tournamentPairingConfig = zodToConvex(schema); | ||
|
|
||
| export const tournamentPairingInput = zodToConvex(generationSchema); |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.