Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test GitHub format workflow #56

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/auto-format.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 13 additions & 6 deletions webapp/src/components/chat/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -207,17 +209,22 @@ export const ChatWindow: React.FC = () => {
</TabList>
</div>
<div className={classes.controls}>
<div data-testid='chatParticipantsView'>
<div data-testid="chatParticipantsView">
<ParticipantsList participants={conversations[selectedId].users} />
</div>
<div> <ShareBotMenu chatId={selectedId} chatTitle={title} /></div>
<div>
{' '}
<ShareBotMenu chatId={selectedId} chatTitle={title} />
</div>
</div>
</div>
{selectedTab === 'chat' && <ChatRoom />}
{selectedTab === 'documents' && <ChatResourceList />}
{selectedTab !== 'chat' && <div className={classes.alerts}>
<Alerts />
</div>}
{selectedTab !== 'chat' && (
<div className={classes.alerts}>
<Alerts />
</div>
)}
</div>
);
};