Skip to content

Commit

Permalink
ci(pr): validate code changes in pull requests (#194)
Browse files Browse the repository at this point in the history
* ci(pr): validate code changes in pull requests
  • Loading branch information
sladg authored Aug 28, 2023
1 parent a53781d commit 348349c
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 18 deletions.
20 changes: 20 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build Docs
description: Build docs pages inside /docs directory

runs:
using: 'composite'
steps:
- name: Install dependencies
run: pnpm install
shell: bash
working-directory: docs

- name: Build with Next.js
run: pnpm next build
shell: bash
working-directory: docs

- name: Export static HTML with Next.js
run: pnpm next export
shell: bash
working-directory: docs
15 changes: 15 additions & 0 deletions .github/actions/build-example/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build Example
description: Build example page inside /example directory, this is used for validation

runs:
using: 'composite'
steps:
- name: Install dependencies
run: pnpm install
shell: bash
working-directory: example

- name: Build with Next.js
run: pnpm next build
shell: bash
working-directory: example
13 changes: 13 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Lint codebase
description: Run eslint to lint codebase and ensure code quality

runs:
using: 'composite'
steps:
- name: Install dependencies
run: pnpm install
shell: bash

- name: Run eslint
run: pnpm lint
shell: bash
17 changes: 17 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Validate merge requests

on:
pull_request:
branches:
- main

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/pnpm-setup
- uses: ./.github/actions/lint
- uses: ./.github/actions/build-example
- uses: ./.github/actions/build-docs
3 changes: 2 additions & 1 deletion .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ name: Deploy Next.js site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ['main']
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shared-workspace-lockfile = true
auto-install-peers = true
1 change: 0 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"lint": "next lint"
},
"dependencies": {
"@next/font": "^13.4.12",
"@types/node": "18.11.9",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.9",
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import "../styles/normalize.css";
import "../styles/globals.css";

import { Open_Sans } from "@next/font/google";
import type { AppProps } from "next/app";
import { Open_Sans } from "next/font/google";

import Layout from "../components/Layout";

Expand Down
1 change: 0 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"deploy": "sst deploy"
},
"dependencies": {
"@next/font": "13.4.12",
"dayjs": "^1.11.9",
"gray-matter": "^4.0.3",
"next": "13.4.12",
Expand Down
4 changes: 2 additions & 2 deletions example/pages/font-next-font.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MuseoModerno } from "@next/font/google";
import { MuseoModerno } from "next/font/google";

import Layout from "../components/layout";

Expand All @@ -11,7 +11,7 @@ export default function Page() {
return (
<Layout>
<article>
<h1>Font — @next/font</h1>
<h1>Font — next/font</h1>
<p>
<b>Test 1:</b>
</p>
Expand Down
2 changes: 1 addition & 1 deletion example/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function Home({}) {
<br />
<Link href={`/font-css-font`}>Font — CSS Font</Link>
<br />
<Link href={`/font-next-font`}>Font — @next/font</Link>
<Link href={`/font-next-font`}>Font — next/font</Link>
<br />
<Link href={`/page-does-not-exist`}>404 Page not found</Link>
<br />
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"eslint": "^8.47.0"
},
"engines": {
"node": ">=16"
"node": ">=16",
"pnpm": ">=8"
}
}
10 changes: 0 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit 348349c

@vercel
Copy link

@vercel vercel bot commented on 348349c Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

open-next – ./

open-next-git-main-sst-dev.vercel.app
open-next.vercel.app
open-next-sst-dev.vercel.app

Please sign in to comment.