Skip to content

Commit

Permalink
Merge pull request #416 from oaknational/rc-20241202-1
Browse files Browse the repository at this point in the history
build: release candidate
  • Loading branch information
mikeritson-oak authored Dec 3, 2024
2 parents c373a6e + 5f749f4 commit c27c76d
Show file tree
Hide file tree
Showing 154 changed files with 1,757 additions and 1,365 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Install deps (with cache)
run: pnpm install

- name: Prisma generate (no engine)
run: pnpm turbo db-generate:no-engine --cache-dir=".turbo"

- name: Build, lint and type-check
run: pnpm turbo lint type-check --cache-dir=".turbo"

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,17 @@ jobs:
doppler-token: ${{ secrets.DOPPLER_TOKEN }}
inject-env-vars: true

- name: Get App Version
id: app-version
run: |
APP_VERSION=$(grep -m 1 -oP '(?<=## \[)\d+\.\d+\.\d+' CHANGE_LOG.md)
echo "version=$APP_VERSION" >> $GITHUB_OUTPUT
- name: SonarCloud scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ steps.doppler.outputs.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectVersion=${{ steps.app-version.outputs.version }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ yarn-error.log*

# Allow each developer to have personal settings, but ignore these files
.vscode/launch.json
.vscode/*.settings.json
.vscode/*.settings.json

.sonar
.sonar/**/*
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
".vscode-insiders"
],
"cSpell.words": [
"agentic",
"Aila",
"APIV",
"authed",
Expand All @@ -46,14 +47,17 @@
"cuid",
"dashify",
"datadoghq",
"datamodel",
"dialog",
"Dialogs",
"distractor",
"distractors",
"dmmf",
"Docgen",
"dockerized",
"dopplerhq",
"dotenv",
"Dsonar",
"EASS",
"Edtech",
"EHRC",
Expand Down Expand Up @@ -84,6 +88,7 @@
"initialisation",
"initialise",
"inngest",
"ipcountry",
"Jayne",
"jsonparse",
"jsonrepair",
Expand All @@ -102,8 +107,10 @@
"moderations",
"multilogical",
"NDJSON",
"Neue",
"nextjs",
"nocheck",
"Noto",
"Nullability",
"oakai",
"oaknational",
Expand Down Expand Up @@ -144,7 +151,11 @@
"RSHE",
"rushstack",
"Sedar",
"Segoe",
"slidedeck",
"sonarcloud",
"sonarqube",
"sonarsource",
"sslcert",
"sslmode",
"SUBJ",
Expand Down
1 change: 1 addition & 0 deletions apps/nextjs/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
extends: ["../../.eslintrc.cjs", "next", "plugin:storybook/recommended"],
rules: {
"react/prefer-read-only-props": "error",
"react/jsx-no-useless-fragment": "warn",
"no-restricted-imports": [
"error",
{
Expand Down
1 change: 0 additions & 1 deletion apps/nextjs/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const decorators: Decorator[] = [
ClerkDecorator,
(Story) => (
<>
{/* TODO: Mock tRPC calls with MSW */}
<TRPCReactProvider>
<AnalyticsProvider>
<DialogProvider>
Expand Down
4 changes: 4 additions & 0 deletions apps/nextjs/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const config = {
rootDir: ".",
resetMocks: true,
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
collectCoverage:
process.env.CI === "true" || process.env.COLLECT_TEST_COVERAGE === "true",
coverageReporters: ["lcov", "text"],
coverageDirectory: "coverage",
};

module.exports = config;
2 changes: 1 addition & 1 deletion apps/nextjs/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/basic-features/typescript for more information.
1 change: 1 addition & 0 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"test-e2e-ui": "pnpm with-env playwright test --ui",
"test-e2e-ui-serve": "pnpm build && pnpm start --port 4848 --turbo",
"test-e2e-ui-built": "PORT=4848 pnpm with-env playwright test --ui",
"test-coverage": "COLLECT_TEST_COVERAGE=true pnpm with-env jest --colors --config jest.config.js --coverage",
"with-env": "dotenv -e ../../.env --",
"aila": "tsx scripts/aila-cli.ts",
"storybook": "dotenv -e ../../.env -- storybook dev -p 6006 --no-open",
Expand Down
17 changes: 12 additions & 5 deletions apps/nextjs/scripts/preload-chat-routes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ const preBuildRoutes = async (
.get(`http://localhost:2525${route}`, { headers })
.then(() => console.log(`Pre-built route: ${route}`))
.catch((error) => {
console.log(`Error pre-building route: ${route}`, error.message);
return Promise.reject(error);
const errorToLog =
error instanceof Error ? error : new Error(String(error));
console.log(
`Error pre-building route: ${route}`,
errorToLog.message,
);
return Promise.reject(errorToLog);
});
} else {
return axios({
Expand All @@ -51,12 +56,14 @@ const preBuildRoutes = async (
),
)
.catch((error) => {
console.log(error);
const errorToLog =
error instanceof Error ? error : new Error(String(error));
console.log(errorToLog);
console.log(
`Error pre-building route: ${route.url}`,
error.message,
errorToLog.message,
);
return Promise.reject(error);
return Promise.reject(errorToLog);
});
}
});
Expand Down
17 changes: 12 additions & 5 deletions apps/nextjs/src/ai-apps/quiz-designer/quizRequestGeneration.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import type { GenerationPart } from "@oakai/core/src/types";
import { aiLogger } from "@oakai/logger";

import { getAgesFromKeyStage } from "@/utils/getAgesFromKeyStage";

import { extraQuizPromptInfo } from "./extraQuizPromptInfo";
import type { QuizAppState, QuizAppStateQuestion } from "./state/types";

type RequestionGenerationInputs = {
const logger = aiLogger("quiz");

export type RequestionGenerationInputs = {
lastGenerationId: string | null;
sessionId: string;
factQuestion: string;
Expand All @@ -26,14 +29,16 @@ type RequestionGenerationInputs = {
};
};

type QuizRequestGenerationProps = {
export type QuizRequestGenerationProps = {
state: QuizAppState;
questionRow: QuizAppStateQuestion;
lastGeneration: GenerationPart<string> | undefined;
requestGeneration: (requestionGenInputs: RequestionGenerationInputs) => void;
requestGeneration: (
requestionGenInputs: RequestionGenerationInputs,
) => Promise<void>;
};

export function quizRequestGeneration({
export async function quizRequestGeneration({
state,
questionRow,
requestGeneration,
Expand All @@ -47,7 +52,7 @@ export function quizRequestGeneration({
state,
questionRow,
});
requestGeneration({
await requestGeneration({
lastGenerationId: lastGeneration?.lastGenerationId ?? null,
sessionId,
factQuestion: `${topic}: ${questionRow.question.value}`,
Expand All @@ -68,5 +73,7 @@ export function quizRequestGeneration({
(distractor) => distractor.value,
),
},
}).catch((e) => {
logger.error(e);
});
}
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function getChatById(
id,
sessionOutput: session.output,
userId: session.userId,
}) || null
}) ?? null
);
}

Expand Down
26 changes: 16 additions & 10 deletions apps/nextjs/src/app/admin/aila/[chatId]/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { OakAccordion, OakPrimaryButton } from "@oaknational/oak-components";

import { trpc } from "@/utils/trpc";

function ModerationListItem({ moderation }: { readonly moderation: Moderation }) {
function ModerationListItem({
moderation,
}: {
readonly moderation: Moderation;
}) {
const { id, invalidatedAt } = moderation;
const [invalidated, setInvalidated] = useState(Boolean(invalidatedAt));
const invalidateModeration = trpc.admin.invalidateModeration.useMutation({
Expand All @@ -28,7 +32,7 @@ function ModerationListItem({ moderation }: { readonly moderation: Moderation })
iconName="cross"
className="ml-auto"
onClick={() =>
invalidateModeration.mutateAsync({ moderationId: id })
void invalidateModeration.mutateAsync({ moderationId: id })
}
isLoading={invalidateModeration.isLoading}
disabled={!!invalidated}
Expand All @@ -41,14 +45,16 @@ function ModerationListItem({ moderation }: { readonly moderation: Moderation })
{moderation.justification}
</blockquote>
<div className="mt-2 space-x-2">
{moderation.categories.map((category, index) => (
<span
key={index}
className="inline-block rounded-md bg-zinc-300 px-8 py-4 text-xs font-semibold text-zinc-800"
>
{String(category)}
</span>
))}
{Array.from(new Set(moderation.categories))
.map((c) => String(c))
.map((category) => (
<span
key={category}
className="inline-block rounded-md bg-zinc-300 px-8 py-4 text-xs font-semibold text-zinc-800"
>
{category}
</span>
))}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit c27c76d

Please sign in to comment.