@@ -32,15 +32,17 @@ jobs:
3232 uses : actions/setup-node@v4
3333 with :
3434 node-version : ${{ matrix.node-version }}
35- - name : Cache Node.js modules
35+ - name : Cache Node.js modules and Next.js build
3636 uses : actions/cache@v4
3737 with :
38- # npm cache files are stored in `~/.npm` on Linux/macOS
39- path : ~/.npm
40- key : ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
38+ path : |
39+ ~/.npm
40+ ${{ github.workspace }}/.next/cache
41+ # Generate a new cache whenever packages or source files change
42+ key : ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
43+ # If source files changed but packages didn't, rebuild from a prior cache
4144 restore-keys : |
42- ${{ runner.OS }}-node-
43- ${{ runner.OS }}-
45+ ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
4446 - run : npm ci
4547 - name : Set up MySQL
4648 run : |
@@ -54,16 +56,27 @@ jobs:
5456 LOG_LEVEL : warn
5557 PORT : 3001
5658
59+ - name : Setup E2E database
60+ run : node cypress/setup.js
61+ env :
62+ DB_PASSWORD :
63+ DB_NAME : bm_e2e_tests
64+
65+ - name : Build for E2E
66+ run : npm run build
67+ env :
68+ DB_PASSWORD :
69+ DB_NAME : bm_e2e_tests
70+ NODE_ENV : production
71+
5772 - name : Cypress run
58- uses : cypress-io/github-action@v2
73+ uses : cypress-io/github-action@v6
5974 env :
6075 DB_PASSWORD :
6176 DB_NAME : bm_e2e_tests
6277 LOG_LEVEL : warn
6378 PORT : 3000
6479 NODE_ENV : production
65- ADMIN_USERNAME : " admin@banmanagement.com"
66- ADMIN_PASSWORD : " P%@#fjdVJ3Y%pdGR" # Keep this as is to avoid HIBP failing checks
6780 CYPRESS_RECORD_KEY : ${{ secrets.CYPRESS_RECORD_KEY }}
6881 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6982 CYPRESS_PROJECT_ID : ${{ secrets.PROJECT_ID }}
7285 NOTIFICATION_VAPID_PRIVATE_KEY : ${{ secrets.NOTIFICATION_VAPID_PRIVATE_KEY }}
7386 with :
7487 install : false
75- build : npm run e2e:build
7688 start : npm start
7789 wait-on : " http://127.0.0.1:3000"
7890 record : true
0 commit comments