From b165e1576d2834719245db4b1e0814b0fa732635 Mon Sep 17 00:00:00 2001 From: Desmond Howard Date: Wed, 26 Jul 2023 21:42:56 -0700 Subject: [PATCH 1/2] add /spotless command for auto-formatting --- .github/workflows/auto-format.yml | 80 +++++++++++++++++++++++++++++++ webapp/package.json | 2 +- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/auto-format.yml diff --git a/.github/workflows/auto-format.yml b/.github/workflows/auto-format.yml new file mode 100644 index 000000000..00bd90448 --- /dev/null +++ b/.github/workflows/auto-format.yml @@ -0,0 +1,80 @@ +name: Prettier format automation +on: + issue_comment: + types: [created] + +jobs: + comment-driven-automation: + if: | + github.event.issue.pull_request && + ( + startsWith(github.event.comment.body, '/spotless') || + startsWith(github.event.comment.body, '/help') + ) + + runs-on: ubuntu-latest + + permissions: + issues: write + pull-requests: write + + steps: + - name: Check for command + id: command + uses: xt0rted/slash-command-action@v2 + continue-on-error: true + with: + command: spotless + reaction-type: "eyes" + + - name: Get command + env: + BODY: ${{ github.event.comment.body }} + run: | + # intentionally only looking at the first line of the body + command=$(echo "$BODY" | head -1 | sed "s;^/;;") + echo "COMMAND=$command" >> $GITHUB_ENV + + - uses: actions/checkout@v3 + + - name: Check out PR branch + env: + NUMBER: ${{ github.event.issue.number }} + GH_TOKEN: ${{ github.token }} + run: | + gh pr checkout $NUMBER + if: env.COMMAND == 'spotless' + + - name: Set git user + run: | + git config user.name github-actions[bot] + git config user.email github-action[bot]@users.noreply.github.com + if: env.COMMAND == 'spotless' + + - name: Run command + env: + NUMBER: ${{ github.event.issue.number }} + GH_TOKEN: ${{ github.token }} + run: | + available_commands="Available commands: + * \`/spotless\` - runs \`yarn format\` + * \`/help\` - displays available commands + " + if [[ "$COMMAND" == "spotless" ]]; then + yarn format + if git diff --quiet; then + gh pr comment $NUMBER --body "Already up-to-date" + exit 0 # success + fi + git commit -a -m "yarn format" + git push + elif [[ "$COMMAND" == "help" ]]; then + gh pr comment $NUMBER --body "$available_commands" + else + body="Unknown command: \`$COMMAND\` + + $available_commands + " + gh pr comment $NUMBER --body "$body" + fi + working-directory: webapp diff --git a/webapp/package.json b/webapp/package.json index a527c01ad..86bf37efc 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -7,9 +7,9 @@ "auth": "vsts-npm-auth -config .npmrc", "auth:mac": "better-vsts-npm-auth -config .npmrc", "depcheck": "depcheck --ignores=\"@types/*,typescript\" --ignore-dirs=\".vscode,.vs,.git,node_modules\" --skip-missing", + "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,scss,css,html,svg}\"", "lint": "eslint src", "lint:fix": "eslint src --fix", - "prettify": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,scss,css,html,svg}\"", "serve": "serve -s build", "start": "react-scripts start", "build": "react-scripts build", From b75f6f694c5e4c1d3548d2a713138d27bf4769ea Mon Sep 17 00:00:00 2001 From: Desmond Howard Date: Wed, 26 Jul 2023 21:50:16 -0700 Subject: [PATCH 2/2] commit to test github format workflow --- webapp/src/components/chat/ChatWindow.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/webapp/src/components/chat/ChatWindow.tsx b/webapp/src/components/chat/ChatWindow.tsx index 0f688631e..97e80664d 100644 --- a/webapp/src/components/chat/ChatWindow.tsx +++ b/webapp/src/components/chat/ChatWindow.tsx @@ -17,7 +17,7 @@ import { TabList, TabValue, tokens, - Tooltip + Tooltip, } from '@fluentui/react-components'; import { Edit24Filled, EditRegular } from '@fluentui/react-icons'; import React, { useEffect, useState } from 'react'; @@ -98,6 +98,8 @@ export const ChatWindow: React.FC = () => { const { instance, inProgress } = useMsal(); const chatService = new ChatService(process.env.REACT_APP_BACKEND_URI as string); + console.log('fake change to test github workflow'); + const { conversations, selectedId } = useAppSelector((state: RootState) => state.conversations); const chatName = conversations[selectedId].title; @@ -207,17 +209,22 @@ export const ChatWindow: React.FC = () => {
-
+
-
+
+ {' '} + +
{selectedTab === 'chat' && } {selectedTab === 'documents' && } - {selectedTab !== 'chat' &&
- -
} + {selectedTab !== 'chat' && ( +
+ +
+ )} ); };