From 0564c9b56108581a0494ff9c144d1770cf3dade0 Mon Sep 17 00:00:00 2001 From: Philip Date: Fri, 24 Jun 2022 10:43:32 +0100 Subject: [PATCH 1/5] Add example github actions for node project --- .github/workflows/node.js.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..05f5588 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm test From b212b6e356b0bc01f8f17660e0888d10a34f43f5 Mon Sep 17 00:00:00 2001 From: Philip Bruland Date: Fri, 24 Jun 2022 10:47:19 +0100 Subject: [PATCH 2/5] Change the nodejs workflow to just lint the project --- .github/workflows/node.js.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 05f5588..0cf5aa0 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -10,22 +10,13 @@ on: branches: [ "master" ] jobs: - build: - + lint: runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [12.x, 14.x, 16.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - steps: - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} + - name: Use Node.js 16.0 uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} + node-version: 16.0 cache: 'npm' - - run: npm ci - - run: npm run build --if-present - - run: npm test + - run: npm run lint From 3f305cec495d7af6d6b0efb333916dbdf5798c1e Mon Sep 17 00:00:00 2001 From: Philip Bruland Date: Fri, 24 Jun 2022 10:48:37 +0100 Subject: [PATCH 3/5] Add back in the ci for installing --- .github/workflows/node.js.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 0cf5aa0..084dbf9 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -19,4 +19,5 @@ jobs: with: node-version: 16.0 cache: 'npm' + - run: npm ci - run: npm run lint From 36c21b2d11d6d6219b6b15307e2cd87aa2e3e906 Mon Sep 17 00:00:00 2001 From: Philip Bruland Date: Fri, 24 Jun 2022 10:51:03 +0100 Subject: [PATCH 4/5] Rename workflow --- .github/workflows/{node.js.yml => base.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{node.js.yml => base.yml} (96%) diff --git a/.github/workflows/node.js.yml b/.github/workflows/base.yml similarity index 96% rename from .github/workflows/node.js.yml rename to .github/workflows/base.yml index 084dbf9..19db317 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/base.yml @@ -1,7 +1,7 @@ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions -name: Node.js CI +name: Validate Project on: push: From 020764b264af684b20fc250848c4b4719b6e2661 Mon Sep 17 00:00:00 2001 From: Philip Bruland Date: Fri, 24 Jun 2022 10:54:45 +0100 Subject: [PATCH 5/5] Fix linting issues --- components/Header.js | 3 +-- server.js | 2 +- utilities/GithubAPI.js | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/Header.js b/components/Header.js index b191bf3..7b33e03 100644 --- a/components/Header.js +++ b/components/Header.js @@ -37,13 +37,12 @@ function Header(props) { return { path, shortPath }; }); pathElement = formattedPaths.map( - path => , + (path) => , ); } else { pathElement = String(paths); } - return (

{githubRepo}

diff --git a/server.js b/server.js index 547192e..97787c2 100644 --- a/server.js +++ b/server.js @@ -2,7 +2,7 @@ const { createServer } = require('http'); const { parse } = require('url'); const next = require('next'); -const port = process.env.PORT || 3000 +const port = process.env.PORT || 3000; const dev = process.env.NODE_ENV !== 'production'; const app = next({ dev }); diff --git a/utilities/GithubAPI.js b/utilities/GithubAPI.js index 135af01..cfe1cb4 100644 --- a/utilities/GithubAPI.js +++ b/utilities/GithubAPI.js @@ -65,7 +65,7 @@ async function getDirectory(path) { if (!data || !Array.isArray(data) || !Object.prototype.hasOwnProperty.call(data[0], 'path')) { throw new Error('Failed to fetch tree.'); } - const pathArray = data.map(entry => entry.path); + const pathArray = data.map((entry) => entry.path); addCache(dirCache, path, pathArray); return pathArray; } catch (e) { @@ -88,7 +88,7 @@ async function getTree() { if (!data2.tree) { throw new Error('Unable to fetch tree'); } - const tree = data2.tree.map(branch => branch.path); + const tree = data2.tree.map((branch) => branch.path); addCache(treeCache, '/', tree); return tree; } catch (e) {