Skip to content

Commit

Permalink
Add ci script to check examples (#28009)
Browse files Browse the repository at this point in the history
* Add ci script to check examples

* Install moreutils for `sponge` command.

It's not very pretty, but I'm not sure how to replace sponge in a good way in the shell script

* Prettier names in the workflow

* Move "check-examples" into build_test_deploy workflow

* Start breaking the jq script into multiple lines

* Add checks for cleanups in #27121

* Run the `check-examples.sh` script to cleanup all remaining examples.
  • Loading branch information
oBusk committed Aug 14, 2021
1 parent 077097b commit 971b17f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build_test_deploy.yml
Expand Up @@ -8,6 +8,16 @@ on:
name: Build, test, and deploy

jobs:
check-examples:
name: Check examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install moreutils
run: sudo apt install moreutils
- name: Check examples
run: ./scripts/check-examples.sh

build:
runs-on: ubuntu-latest
env:
Expand Down
2 changes: 0 additions & 2 deletions examples/with-cypress/package.json
@@ -1,6 +1,4 @@
{
"name": "with-cypress",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
3 changes: 0 additions & 3 deletions examples/with-fauna/package.json
@@ -1,8 +1,5 @@
{
"private": true,
"name": "with-fauna",
"version": "1.0.0",
"description": "Guestbook example with Next.js and Fauna.",
"scripts": {
"dev": "next",
"build": "yarn setup && next build",
Expand Down
3 changes: 3 additions & 0 deletions examples/with-jotai/next-env.d.ts
@@ -1,3 +1,6 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
1 change: 0 additions & 1 deletion examples/with-jotai/package.json
@@ -1,5 +1,4 @@
{
"name": "with-jotai",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
5 changes: 4 additions & 1 deletion scripts/check-examples.sh
Expand Up @@ -3,7 +3,10 @@
for folder in examples/* ; do
if [ -f "$folder/package.json" ]; then
cp -n packages/create-next-app/templates/default/gitignore $folder/.gitignore;
cat $folder/package.json | jq 'del(.license) | .private = true' | sponge $folder/package.json
cat $folder/package.json | jq '
.private = true |
del(.license, .version, .name, .author, .description)
' | sponge $folder/package.json
fi
if [ -f "$folder/tsconfig.json" ]; then
cp packages/create-next-app/templates/typescript/next-env.d.ts $folder/next-env.d.ts
Expand Down

0 comments on commit 971b17f

Please sign in to comment.