From 86af5a43dcfde09060de880233d4adcbd532cd15 Mon Sep 17 00:00:00 2001 From: George Herbert Date: Sun, 4 Feb 2024 20:37:26 +0000 Subject: [PATCH] feat: github action for PR --- .github/workflows/pull-request.yml | 8 ++++---- server/.eslintrc.json | 4 ++++ server/package.json | 4 ++-- ui/.eslintrc.json | 5 +++++ ui/src/pages/api/auth/[...nextauth].ts | 15 ++++++++++----- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b9e2f32..7dc2da2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,4 +1,4 @@ -name: Node.js CI +name: Pull Request on: [pull_request] @@ -9,9 +9,9 @@ jobs: matrix: project: [ui, server] steps: - - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v2 + - uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 with: node-version: '20' - name: Install dependencies diff --git a/server/.eslintrc.json b/server/.eslintrc.json index 117cfc9..8a3dae1 100644 --- a/server/.eslintrc.json +++ b/server/.eslintrc.json @@ -11,6 +11,10 @@ "deprecation", "unicorn" ], + "ignorePatterns": [ + "node_modules/", + "dist/" + ], "rules": { "unicorn/filename-case": "error", "indent": [ diff --git a/server/package.json b/server/package.json index 1398c55..3e74091 100644 --- a/server/package.json +++ b/server/package.json @@ -1,7 +1,7 @@ { - "name": "langtrace-ingest", + "name": "langtrace-server", "version": "1.0.0", - "main": "src/ingestor_server.ts", + "main": "src/ingestor-server.ts", "scripts": { "start:langtrace": "ts-node src/langtrace-server.ts", "start:ingestor": "ts-node src/ingest-server.ts", diff --git a/ui/.eslintrc.json b/ui/.eslintrc.json index b175a1f..c8f7d2b 100644 --- a/ui/.eslintrc.json +++ b/ui/.eslintrc.json @@ -3,6 +3,11 @@ "plugins": [ "unicorn" ], + "ignorePatterns": [ + "node_modules/", + ".next/", + "dist/" + ], "rules": { "unicorn/filename-case": [ "error", diff --git a/ui/src/pages/api/auth/[...nextauth].ts b/ui/src/pages/api/auth/[...nextauth].ts index 5ec8d65..c0c2c53 100644 --- a/ui/src/pages/api/auth/[...nextauth].ts +++ b/ui/src/pages/api/auth/[...nextauth].ts @@ -1,14 +1,19 @@ -import NextAuth, { NextAuthOptions } from 'next-auth'; +import NextAuth, { NextAuthOptions, Profile } from 'next-auth'; import GithubProvider from 'next-auth/providers/github'; import { NextApiRequest, NextApiResponse } from 'next'; const enableAuth = process.env.NEXTAUTH_ENABLE === 'true'; +interface GitHubProfile extends Profile { + login: string; + +} + const options = { providers: [ GithubProvider({ - clientId: process.env.NEXTAUTH_GITHUB_ID, - clientSecret: process.env.NEXTAUTH_GITHUB_SECRET, + clientId: process.env.NEXTAUTH_GITHUB_ID!, + clientSecret: process.env.NEXTAUTH_GITHUB_SECRET!, authorization: { params: { scope: 'read:user,user:email,read:org', @@ -20,10 +25,10 @@ const options = { async signIn({ account, profile }) { if (account?.provider === 'github' && (process.env.NEXTAUTH_GITHUB_ORGANISATION ?? '').trim() !== '') { - const orgName = process.env.NEXTAUTH_GITHUB_ORGANISATION; const token = account.access_token; - const url = `https://api.github.com/orgs/${orgName}/members/${profile?.login}`; + const url = + `https://api.github.com/orgs/${orgName}/members/${(profile as GitHubProfile).login}`; const response = await fetch(url, { headers: { Authorization: `token ${token}`,