From 037796f222ee4f13509c1d79a1bce8a918ff4e4f Mon Sep 17 00:00:00 2001 From: Julien Bouquillon Date: Sat, 29 Jul 2023 13:48:07 +0200 Subject: [PATCH] fix: align with hasura branch --- .github/workflows/build.yml | 31 ++++++ .github/workflows/e2e.yml | 7 +- .talismanrc | 4 + next.config.js | 1 + scripts/prebuild.ts | 2 +- src/pages/_app.tsx | 183 +++++++++++++++++++----------------- 6 files changed, 138 insertions(+), 90 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..6c0a7788 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,31 @@ +name: Build + +on: [pull_request, push] + +concurrency: + cancel-in-progress: true + group: build-${{ github.ref }} + +jobs: + build: + name: Build and export + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Restore cache + uses: actions/cache@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install dependencies + run: | + yarn install --prefer-offline --frozen-lockfile + - name: Build and export + run: | + yarn build diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b2aae750..d16cc474 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -14,7 +14,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - name: Cypress run - uses: cypress-io/github-action@v2 + uses: cypress-io/github-action@v5 with: build: yarn build start: yarn start + component: false + env: + NEXTAUTH_URL: "http://keycloak:3000" + NEXTAUTH_SECRET: "A+EQqudlGhqTLDnBbCvohHBfbhUjTXAbZYy1NKsSsys=" + NEXT_PUBLIC_HASURA_GRAPHQL_ENDPOINT_URL: "http://hasura:8082/v1/graphql" diff --git a/.talismanrc b/.talismanrc index 7eeee45e..b1cd14c5 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,6 +1,10 @@ fileignoreconfig: - filename: .env.development checksum: 44d017f8bd7ac1f3f4fb8b8175b3dddb6f160cf05b2738ec16b5b848aeb62d3f +- filename: .github/workflows/build.yml + checksum: 76b8b3bba21c8029b1fd0dd2759cf96448ee257439ea4118fddfb4254199a59b +- filename: .github/workflows/e2e.yml + checksum: eaf3ce6b34b2ceee77a0c89066d8c05b5938c60c71458e4341b636eb6b9d51da - filename: .github/workflows/kontinuous-webhook-delete.yml checksum: 6debf4f640d4ed9cb39bb19445214ab52dcb23fb7da12feeb85070816d7ee52a - filename: .github/workflows/kontinuous-webhook-deploy.yml diff --git a/next.config.js b/next.config.js index c5c5cf5c..e52b33cb 100644 --- a/next.config.js +++ b/next.config.js @@ -4,6 +4,7 @@ const { version } = require("./package.json"); const ContentSecurityPolicy = require("./csp.config"); +/** @type {import('next').NextConfig} */ const moduleExports = { reactStrictMode: true, swcMinify: true, diff --git a/scripts/prebuild.ts b/scripts/prebuild.ts index 2b55dd85..98a31fcb 100644 --- a/scripts/prebuild.ts +++ b/scripts/prebuild.ts @@ -22,7 +22,7 @@ const run = () => { process.env.PRODUCTION ? true : false, process.env.NEXT_PUBLIC_SITE_URL ?? "localhost" ); - console.log("Robots.txt generated."); + console.log("Robots.txt generated"); }; run(); diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 29b3c4dd..58e589bd 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,21 +1,18 @@ -import { useEffect } from "react"; -import { useRouter } from "next/router"; +import { ReactNode, useEffect } from "react"; import type { AppProps } from "next/app"; +import Head from "next/head"; import Link from "next/link"; +import { useRouter } from "next/router"; -import { fr } from "@codegouvfr/react-dsfr"; -import { createNextDsfrIntegrationApi } from "@codegouvfr/react-dsfr/next-pagesdir"; -import { MuiDsfrThemeProvider } from "@codegouvfr/react-dsfr/mui"; import { createEmotionSsrAdvancedApproach } from "tss-react/next"; -import { useStyles } from "tss-react/dsfr"; -import { - Display, - headerFooterDisplayItem, -} from "@codegouvfr/react-dsfr/Display"; -import { Header } from "@codegouvfr/react-dsfr/Header"; +import { createNextDsfrIntegrationApi } from "@codegouvfr/react-dsfr/next-pagesdir"; import { Footer } from "@codegouvfr/react-dsfr/Footer"; +import { fr } from "@codegouvfr/react-dsfr"; +import { Header } from "@codegouvfr/react-dsfr/Header"; +import { headerFooterDisplayItem } from "@codegouvfr/react-dsfr/Display"; import { init } from "@socialgouv/matomo-next"; -import Head from "next/head"; +import { MuiDsfrThemeProvider } from "@codegouvfr/react-dsfr/mui"; +import { useStyles } from "tss-react/dsfr"; declare module "@codegouvfr/react-dsfr/next-pagesdir" { interface RegisterLink { @@ -23,7 +20,6 @@ declare module "@codegouvfr/react-dsfr/next-pagesdir" { } } -// Only in TypeScript projects declare module "@codegouvfr/react-dsfr" { interface RegisterLink { Link: typeof Link; @@ -108,95 +104,106 @@ const bottomLinks = [ }, ]; -function App({ Component, pageProps }: AppProps) { +const Layout = ({ children }: { children: ReactNode }) => { const { css } = useStyles(); - const router = useRouter(); const contentSecurityPolicy = process.env.CONTENT_SECURITY_POLICY; - - useEffect(() => { - init({ - url: process.env.NEXT_PUBLIC_MATOMO_URL ?? "", - siteId: process.env.NEXT_PUBLIC_MATOMO_SITE_ID ?? "", - }); - }, []); - return ( - <> - - - Template SocialGouv - {contentSecurityPolicy && ( - - )} - + + + Template SocialGouv + {contentSecurityPolicy && ( - -
+ )} + + + +
-
- -
-