Skip to content
This repository was archived by the owner on Jan 2, 2022. It is now read-only.

Commit 5e07388

Browse files
committed
ci: run a local Netlify build to test plugin
Closes #53 Signed-off-by: Jonah Snider <[email protected]>
1 parent 21229be commit 5e07388

File tree

7 files changed

+3103
-96
lines changed

7 files changed

+3103
-96
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,43 @@ jobs:
6666
run: yarn install
6767
- name: Lint with XO
6868
run: yarn run lint
69+
e2e-local:
70+
name: Local end-to-end test
71+
72+
runs-on: ubuntu-latest
73+
74+
steps:
75+
- name: Checkout git repository
76+
uses: actions/checkout@v2
77+
- name: Setup Node.js for use with Actions
78+
uses: actions/setup-node@v1
79+
with:
80+
node-version: '12.16.2'
81+
- name: Install Yarn
82+
run: curl -o- -L https://yarnpkg.com/install.sh | bash
83+
- name: Get yarn cache directory path
84+
id: yarn-cache-dir-path
85+
run: echo "::set-output name=dir::$(yarn cache dir)"
86+
- name: Cache dependencies
87+
uses: actions/cache@v1
88+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
89+
with:
90+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
91+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
92+
restore-keys: |
93+
${{ runner.os }}-yarn-
94+
- name: Install dependencies with Yarn
95+
run: yarn install
96+
# Netlify uses the npm version of the plugin, so we replace it with our version
97+
- name: Prepare for local testing
98+
run: yarn link
99+
- name: Compile TypeScript
100+
run: yarn run build
101+
- name: Use built version instead of published version
102+
run: yarn link "netlify-plugin-cache-nextjs"
103+
- name: Overwrite downloaded plugin with this version
104+
- name: Run local Netlify build
105+
run: yarn run e2e:local
69106
style:
70107
name: Check style
71108

@@ -100,7 +137,7 @@ jobs:
100137

101138
runs-on: ubuntu-latest
102139

103-
needs: [lint, style]
140+
needs: [lint, style, e2e-local]
104141

105142
steps:
106143
- name: Checkout git repository

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,6 @@ $RECYCLE.BIN/
179179

180180
# TypeScript compiler output
181181
tsc_output
182+
183+
# Local Netlify folder
184+
.netlify

example/build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
now=$(date +"%T")
2+
currentDate=$(date +"%a")
3+
path="./.next/cache/$currentDate.txt"
4+
5+
rm $path
6+
7+
echo $now >> $path

example/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<title>Example page</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
</head>
9+
<body>
10+
<h1>hello</h1>
11+
</body>
12+
</html>

netlify.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[build]
2+
base = "./example"
3+
publish = "./example"
4+
command = "bash build.sh"
5+
6+
# Cache Next.js build folder between Netlify builds
7+
[[plugins]]
8+
package = "netlify-plugin-cache-nextjs"

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@netlify/cache-utils": "^0.4.1"
1212
},
1313
"devDependencies": {
14+
"netlify-cli": "^2.46.0",
1415
"prettier": "^2.0.4",
1516
"semantic-release": "^17.0.4",
1617
"type-fest": "^0.13.1",
@@ -35,6 +36,7 @@
3536
},
3637
"scripts": {
3738
"build": "tsc",
39+
"e2e:local": "netlify build",
3840
"lint": "xo",
3941
"prebuild": "rm -rf tsc_output",
4042
"style": "prettier --ignore-path .gitignore --check \"./**/*.{{j,t}{s,sx},flow,{sc,c,le}ss,json,m{d,dx},{y,ya}ml}\""

0 commit comments

Comments
 (0)