From 32dd04f3c05d468f3ab762355e463e01b261ff21 Mon Sep 17 00:00:00 2001 From: braddf Date: Mon, 30 Sep 2024 15:36:36 +0100 Subject: [PATCH 1/6] fix node CI run config --- apps/nowcasting-app/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/nowcasting-app/package.json b/apps/nowcasting-app/package.json index b1de0328..2de237b0 100644 --- a/apps/nowcasting-app/package.json +++ b/apps/nowcasting-app/package.json @@ -10,7 +10,8 @@ "build-storybook": "build-storybook", "lint": "next lint", "pre-commit": "pre-commit run", - "test": "cypress run --browser chrome && jest" + "test": "yarn dev & cypress run --browser chrome && jest && lsof -t -i :3002 | xargs kill", + "test:ci": "yarn dev & cypress run --browser chrome && jest" }, "dependencies": { "@auth0/nextjs-auth0": "^1.8.0", From 5cd242fad9c2e82bd5da767bd8be73e12721bc0f Mon Sep 17 00:00:00 2001 From: braddf Date: Tue, 1 Oct 2024 09:57:47 +0100 Subject: [PATCH 2/6] amend CI test command --- .github/workflows/yarn_test.yaml | 2 +- apps/nowcasting-app/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/yarn_test.yaml b/.github/workflows/yarn_test.yaml index b05c3a76..8a8e2965 100644 --- a/.github/workflows/yarn_test.yaml +++ b/.github/workflows/yarn_test.yaml @@ -28,4 +28,4 @@ jobs: - name: run tests run: | cd apps/nowcasting-app - yarn start & sleep 5 && yarn test --coverage --coverageDirectory=../.. + yarn start & sleep 5 && yarn test:ci --coverage --coverageDirectory=../.. diff --git a/apps/nowcasting-app/package.json b/apps/nowcasting-app/package.json index 2de237b0..0e8ba364 100644 --- a/apps/nowcasting-app/package.json +++ b/apps/nowcasting-app/package.json @@ -11,7 +11,7 @@ "lint": "next lint", "pre-commit": "pre-commit run", "test": "yarn dev & cypress run --browser chrome && jest && lsof -t -i :3002 | xargs kill", - "test:ci": "yarn dev & cypress run --browser chrome && jest" + "test:ci": "cypress run --browser chrome && jest" }, "dependencies": { "@auth0/nextjs-auth0": "^1.8.0", From 995df1393013f42ee176c763041bf480bbecf113 Mon Sep 17 00:00:00 2001 From: braddf Date: Tue, 1 Oct 2024 10:13:29 +0100 Subject: [PATCH 3/6] add env secret to workflow --- .github/workflows/yarn_test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/yarn_test.yaml b/.github/workflows/yarn_test.yaml index 8a8e2965..7d92a247 100644 --- a/.github/workflows/yarn_test.yaml +++ b/.github/workflows/yarn_test.yaml @@ -29,3 +29,5 @@ jobs: run: | cd apps/nowcasting-app yarn start & sleep 5 && yarn test:ci --coverage --coverageDirectory=../.. + env: + AUTH0_SECRET: ${{ secrets.AUTH0_SECRET }} From 497b13423239a75aaa374e9f8392a6f6996dc351 Mon Sep 17 00:00:00 2001 From: braddf Date: Tue, 1 Oct 2024 10:29:15 +0100 Subject: [PATCH 4/6] add remaining env secrets to workflow --- .github/workflows/yarn_test.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/yarn_test.yaml b/.github/workflows/yarn_test.yaml index 7d92a247..3cd416f6 100644 --- a/.github/workflows/yarn_test.yaml +++ b/.github/workflows/yarn_test.yaml @@ -30,4 +30,19 @@ jobs: cd apps/nowcasting-app yarn start & sleep 5 && yarn test:ci --coverage --coverageDirectory=../.. env: + AUTH0_AUDIENCE: ${{ secrets.AUTH0_AUDIENCE }} + AUTH0_BASE_URL: ${{ secrets.AUTH0_BASE_URL }} + AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }} + AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }} + AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} + AUTH0_ISSUER_BASE_URL: ${{ secrets.AUTH0_ISSUER_BASE_URL }} + AUTH0_SCOPE: ${{ secrets.AUTH0_SCOPE }} AUTH0_SECRET: ${{ secrets.AUTH0_SECRET }} + NEXT_PUBLIC_AUTH0_AUDIENCE: ${{ secrets.NEXT_PUBLIC_AUTH0_AUDIENCE }} + NEXT_PUBLIC_AUTH0_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_AUTH0_CLIENT_ID }} + NEXT_PUBLIC_AUTH0_DOMAIN: ${{ secrets.NEXT_PUBLIC_AUTH0_DOMAIN }} + NEXT_PUBLIC_AUTH0_PASSWORD: ${{ secrets.NEXT_PUBLIC_AUTH0_PASSWORD }} + NEXT_PUBLIC_AUTH0_SCOPE: ${{ secrets.NEXT_PUBLIC_AUTH0_SCOPE }} + NEXT_PUBLIC_AUTH0_USERNAME: ${{ secrets.NEXT_PUBLIC_AUTH0_USERNAME }} + + From 28643a93a65ffbbc5991ff19dca68148e3bf8469 Mon Sep 17 00:00:00 2001 From: braddf Date: Tue, 1 Oct 2024 17:37:38 +0100 Subject: [PATCH 5/6] fix squished sites view --- .../solar-site-view/solar-site-chart.tsx | 20 +++++++++++++------ .../solar-site-view/solar-site-tables.tsx | 4 ++-- .../components/side-layout/index.tsx | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/apps/nowcasting-app/components/charts/solar-site-view/solar-site-chart.tsx b/apps/nowcasting-app/components/charts/solar-site-view/solar-site-chart.tsx index 25f40f85..ae047465 100644 --- a/apps/nowcasting-app/components/charts/solar-site-view/solar-site-chart.tsx +++ b/apps/nowcasting-app/components/charts/solar-site-view/solar-site-chart.tsx @@ -324,30 +324,38 @@ const SolarSiteChart: FC<{ )} -
+
-
+
diff --git a/apps/nowcasting-app/components/charts/solar-site-view/solar-site-tables.tsx b/apps/nowcasting-app/components/charts/solar-site-view/solar-site-tables.tsx index 728cf77a..6cab734c 100644 --- a/apps/nowcasting-app/components/charts/solar-site-view/solar-site-tables.tsx +++ b/apps/nowcasting-app/components/charts/solar-site-view/solar-site-tables.tsx @@ -29,7 +29,7 @@ import { formatISODateString } from "../../helpers/utils"; const TableHeader: React.FC<{ text: string }> = ({ text }) => { return (
@@ -81,7 +81,7 @@ const TableData: React.FC = ({ rows }) => { return ( <> -
+
{rows?.sort(sortFn).map((site) => { const mostAccurateGeneration = site.actualPV || site.expectedPV; return ( diff --git a/apps/nowcasting-app/components/side-layout/index.tsx b/apps/nowcasting-app/components/side-layout/index.tsx index 55795ecf..f998a76d 100644 --- a/apps/nowcasting-app/components/side-layout/index.tsx +++ b/apps/nowcasting-app/components/side-layout/index.tsx @@ -46,7 +46,7 @@ const SideLayout: FC = ({ >
{children}
-
+
setIsOpen((o) => !o)} />
From 10088fb86ff02345fb6e8c76efb3b67b573f697d Mon Sep 17 00:00:00 2001 From: braddf Date: Tue, 1 Oct 2024 17:54:51 +0100 Subject: [PATCH 6/6] tidy precommit/CI configs --- .github/workflows/yarn_test.yaml | 3 ++- .husky/pre-commit | 13 +++++++++++-- apps/nowcasting-app/package.json | 3 +-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/yarn_test.yaml b/.github/workflows/yarn_test.yaml index 3cd416f6..280ef83a 100644 --- a/.github/workflows/yarn_test.yaml +++ b/.github/workflows/yarn_test.yaml @@ -28,7 +28,7 @@ jobs: - name: run tests run: | cd apps/nowcasting-app - yarn start & sleep 5 && yarn test:ci --coverage --coverageDirectory=../.. + yarn start & sleep 5 && yarn test --coverage --coverageDirectory=../.. env: AUTH0_AUDIENCE: ${{ secrets.AUTH0_AUDIENCE }} AUTH0_BASE_URL: ${{ secrets.AUTH0_BASE_URL }} @@ -38,6 +38,7 @@ jobs: AUTH0_ISSUER_BASE_URL: ${{ secrets.AUTH0_ISSUER_BASE_URL }} AUTH0_SCOPE: ${{ secrets.AUTH0_SCOPE }} AUTH0_SECRET: ${{ secrets.AUTH0_SECRET }} + NEXT_PUBLIC_API_PREFIX: ${{ secrets.NEXT_PUBLIC_API_PREFIX }} NEXT_PUBLIC_AUTH0_AUDIENCE: ${{ secrets.NEXT_PUBLIC_AUTH0_AUDIENCE }} NEXT_PUBLIC_AUTH0_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_AUTH0_CLIENT_ID }} NEXT_PUBLIC_AUTH0_DOMAIN: ${{ secrets.NEXT_PUBLIC_AUTH0_DOMAIN }} diff --git a/.husky/pre-commit b/.husky/pre-commit index e2ec2352..90576a12 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,6 +1,15 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -cd apps/nowcasting-app +cd apps/nowcasting-app || exit yarn lint -yarn test + +# check if the server is already running and save the boolean result +serverRunning=$(lsof -t -i :3002) +# if the server is running, just run the tests and don't start the server +if [ -z "$serverRunning" ]; then + yarn test +else + # if the server isn't running, start it, run the tests, and then kill the server after the tests are done + yarn dev & yarn test && lsof -t -i :3002 | xargs kill +fi diff --git a/apps/nowcasting-app/package.json b/apps/nowcasting-app/package.json index 0e8ba364..b1de0328 100644 --- a/apps/nowcasting-app/package.json +++ b/apps/nowcasting-app/package.json @@ -10,8 +10,7 @@ "build-storybook": "build-storybook", "lint": "next lint", "pre-commit": "pre-commit run", - "test": "yarn dev & cypress run --browser chrome && jest && lsof -t -i :3002 | xargs kill", - "test:ci": "cypress run --browser chrome && jest" + "test": "cypress run --browser chrome && jest" }, "dependencies": { "@auth0/nextjs-auth0": "^1.8.0",