@@ -113,11 +113,39 @@ jobs:
113113path :outfile.cjs
114114key :${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }}
115115 -name :Build the package on cache miss
116- if :steps.cache.outputs.cache-hit != 'true'
116+ if :steps.cache-restore .outputs.cache-hit != 'true'
117117run :pnpm install && pnpm build
118118env :
119+ # The main project doesn't need Cypress binaries
119120CYPRESS_INSTALL_BINARY :0
120121
122+ # https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml#L62
123+ # Install playwright's binary under custom directory to cache
124+ -name :Set Playwright & Cypress path
125+ if :runner.os != 'Windows'
126+ run :|
127+ echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
128+ echo "CYPRESS_CACHE_FOLDER=$HOME/.cache/cypress-bin" >> $GITHUB_ENV
129+ -name :Set Playwright & Cypress path (windows)
130+ if :runner.os == 'Windows'
131+ run :|
132+ echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
133+ echo "CYPRESS_CACHE_FOLDER=$HOME\.cache\cypress-bin" >> $env:GITHUB_ENV
134+
135+ -name :Cache Cypress binaries
136+ uses :actions/cache@v3
137+ with :
138+ key :${{ runner.os }}-cypress-bin
139+ path :${{ env.CYPRESS_CACHE_FOLDER }}
140+
141+ -name :Cache Playwright's binary
142+ uses :actions/cache@v3
143+ with :
144+ # Playwright removes unused browsers automatically
145+ # So does not need to add playwright version to key
146+ key :${{ runner.os }}-playwright-bin-v1
147+ path :${{ env.PLAYWRIGHT_BROWSERS_PATH }}
148+
121149 -if :${{ (contains(env.FEATURE_FLAGS, '--')) }}
122150name :Create the sample project with feature flags
123151run :node ./outfile.cjs sample-project ${{ env.FEATURE_FLAGS }}
@@ -142,6 +170,7 @@ jobs:
142170working-directory :../sample-project
143171run :pnpm build
144172
173+
145174 -if :${{ contains(matrix.flag-for-e2e, '--playwright') }}
146175name :Install Playwright dependencies
147176working-directory :../sample-project