Skip to content

Commit

Permalink
HackParser integration (#413)
Browse files Browse the repository at this point in the history
* feat/wip: Add basic structure for getting signed S3 URLs

* test: Add PDF file input

* fix: Revert to older pnpm changes

* fix: Get the correct lock file version

* fix: Add pdf identifier to test

* fix: Remove updated Slack message for tests

* test: Add pdf uploading and fix tests

* test: Add putS3Object mock

* rix: Remove all the test requirements

* fix: Add example.pdf in app root as well

* fix: Add more pdfs everywhere

* test: Remove everything of practical use

* refactor: Add in slackbot pdfssssssssssssssssssssssssssssssssssss

* Update PDF downloading code, added debug log of response

Temporarily disable test coverage threshold

* Add tests for requesting reviews with a PDF

Re-enable testing threshold
Remove uncessary node-fetch

* Add PDF & files to updated message on review accept

Add logging of errors to console.

* Break text up into multiple blocks to avoid 3001 character limit

* Make HackParser integration togglable

Add error handling to HackParser integration
Fix edge case around code results block being added when there are just plain results
Add remaining tests
Revert getReviewByThreadId addition

* Cleanup test PDFs, restore coverage thresholds, cleanup comments

* Move HackParser specific logic into HackParserService

Improve cleanup of environment variable changes during testing

* Cleanup tests

Normalize style of requestReview test to reduce uncessary duplicate executions
Add assertion helper to acceptRequestReview
Remove duplicagte test from acceptRequestReview

* Add additional acceptReviewRequest error tests

* Bump line coverage coverage threshold

* Infer type from @smithy/type instead of using it directly

* Update presigned URL expiration to 7 days

---------

Co-authored-by: Charlie Hall <[email protected]>
  • Loading branch information
jsmilliken and charlie-map authored Oct 21, 2024
1 parent 791ef53 commit 2b318eb
Show file tree
Hide file tree
Showing 26 changed files with 3,665 additions and 1,393 deletions.
1 change: 1 addition & 0 deletions .aws/bin/HackerRankQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ new HackerRankQueueStack(app, 'HackerRankQueueStack', {
ENCRYPTED_GOOGLE_SERVICE_ACCOUNT_EMAIL: modeConfig.ENCRYPTED_GOOGLE_SERVICE_ACCOUNT_EMAIL,
WORKDAY_START_HOUR: modeConfig.WORKDAY_START_HOUR,
WORKDAY_END_HOUR: modeConfig.WORKDAY_END_HOUR,
HACK_PARSER_BUCKET_NAME: modeConfig.HACK_PARSER_BUCKET_NAME,
TZ: 'America/Chicago',
},
});
Expand Down
6 changes: 4 additions & 2 deletions .aws/cdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"ENCRYPTED_GOOGLE_PRIVATE_KEY": "AQICAHgmK7RLzJGLsX027nGL/3YoG67Jh4Mxgt5hOhZTg/kH0AHEr+SbFFY945kYFwnuo4kWAAAHEDCCBwwGCSqGSIb3DQEHBqCCBv0wggb5AgEAMIIG8gYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAxt2Sue9xubIZWoLekCARCAggbD0uwuAHJ3wCHirHsU90OweETVU4S+ek4jN6D0BH3xvRPLWLWBJredL3Ln7p4udHkYSsOYlSId/3TqeraNKjtoz+xdUnL5XE59OwIxC9qXzZu/E1WRLYKDcEthze4mWm+xlPgutYnZk6QQOLVE/HiMqK+4Xr0zfr0o9o8hOA9t6Z3ZIjb/Xea/AAg7Cnt0AikQW/TKj6ET470rfDHNbYHzF4tioj+PyebXICA+1xurWNHB9t0I3dzbe3BM0per3bzxjDUuCTh37JKd7+t+peH4hSs315TeWe2GLgFA/3stqcD6Fi6w1Ruo26RFwQn8DEhZc1i5x2CC0NRc76xoqYLhuMIjC+ZROE0XsuPCv6gmiVTTmrHDuLStTtsvcH7F7fesq2LZPvB/4Ox1qIR2+aU70Otuxemq047JaL/DPZUhG6n7QT61RvWsLaWfmsrfYcguO5d9mYzznJyApkzqUhDY9QcdAeq5HwZ2vSMlaVAWKcm8VuEfHfmyCpM8Y+sPLLwDEr2DiSkhKW72jz186zRagp9BLc/0ngWl2U+m1AtiCVQaTpwAwN+B6hrKgJklr1EyXRxyya8SHBsr7z/p6hEbo7SKYglteegsjwFeWfdZQkjdE5Tc5vwBpYBxQoXGCEvSrK1BZBRGi4bNr7X2+IjhdJ7ZVVK54TlWU5RUHlH08mPWtDdvZyVg4g3YtqFFmbRT7WVXhS0K6g3a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Mj4L5NJa0eba8As8uXLEYvR4+TyTeqXchQbQ2K5e4VQu9e47CkD8CmmtmVRS9FBKSJgrKs0+FlDuiZ7aX3mtYmLl2C5R5xR+YxOrgJD0i0VlxXDW2Yj2XyPIy49aL/8ShI+zkcLFIPLJ3YsCa3/hHQp7bcEZcRukWd/OpOWYQcNsq9H+rsZ9tXLoBHpMd1vZXk0o22ZGma8oAVasTO/CcJEQY5tP0m5jDM8wwO+OB87UzHCqD52IUdWXYIM1CMv0Z9BxTy7sG6ZA2Yw8evcsYclH/XSAsDkPJtOUUA53rSTrMUoUyem+QB0bIyZYMqFY9QNGj+ExiyWaR/x05mwqb7ShdZk3LP1RCkvHYZK0lFcTHfqilHRZO5foUdubMPNuIbB/FGpYlCUXvKDwcbPTqISmpz8qW2VjEJvj0rnzHpC/DaqjdharMv4AK59Fae2AW99WKb8rVxQKFezXtaEMtQnfMViqfW0H85HxOu0z6lcFz",
"ENCRYPTED_GOOGLE_SERVICE_ACCOUNT_EMAIL": "AQICAHgmK7RLzJGLsX027nGL/3YoG67Jh4Mxgt5hOhZTg/kH0AEaRVPWlX2aVKL8w/25FRmuAAAAlDCBkQYJKoZIhvcNAQcGoIGDMIGAAgEAMHsGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMKzMqXyLoCKEizJLXAgEQgE6KG7oJcvvJDkhnvxOR5Z2blZ0UH/ib7FTXBaDDQUASqASjyQhOyIVB+V7boljYMTgVhcUWZprkgMvS2hFbiS7gaRlC59KLgkPFP5+VmaE=",
"WORKDAY_START_HOUR": "8",
"WORKDAY_END_HOUR": "17"
"WORKDAY_END_HOUR": "17",
"HACK_PARSER_BUCKET_NAME": "hack-parser-dev"
},
"prod": {
"HOSTED_ZONE": "sourceallies.com",
Expand All @@ -27,7 +28,8 @@
"ENCRYPTED_GOOGLE_PRIVATE_KEY": "AQICAHj0rd9+A15pncr1JrWCjeFtR4hrNnZnqKAX0mW97lZXPAGSmRSjKiVg8BK+dJI5+inyAAAHEDCCB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R0oZ4OmcKSsm6u0cBqesfuLFu/kL27gCbpMXQrBQ/qTsRmLljZWndUkHHyoMYLjZXmWOz5w47AobAPgG9MXlzN/WclZgNnrfAmUPUETWgjTwFMsu1n2Xi96zSYxF6vMHCQCFXfthEgEsgst81zbQTW24RGzawtZpVu8AXxWSvKOSH7WDQeOmx2wvqq74KR7s+4c3L6PMgkp55IvqOncgaD8hzgM+UnDZXYpt1N3GsJYbY6V6wgGCs+/VwSbvAVx",
"ENCRYPTED_GOOGLE_SERVICE_ACCOUNT_EMAIL": "AQICAHj0rd9+A15pncr1JrWCjeFtR4hrNnZnqKAX0mW97lZXPAGr0HRhl9Anq+UoyGhRYnZbAAAAlDCBkQYJKoZIhvcNAQcGoIGDMIGAAgEAMHsGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMHkGZcyEuoE5kdC9CAgEQgE5bFFe7hRWHrVDO9J90X2izrLD8fbLGAzU0gHtoSQwHvfg6YxEgpu5R4bnEH61AgkjkhsSKndMtyjZWnvc2yT+cRPFX8THuOiwt4zKtm+Y=",
"WORKDAY_START_HOUR": "8",
"WORKDAY_END_HOUR": "17"
"WORKDAY_END_HOUR": "17",
"HACK_PARSER_BUCKET_NAME": ""
}
}
}
1 change: 1 addition & 0 deletions .aws/lib/HackerRankQueueStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface HackerRankQueueStackProps extends StackProps {
ENCRYPTED_GOOGLE_SERVICE_ACCOUNT_EMAIL: string;
WORKDAY_START_HOUR: string;
WORKDAY_END_HOUR: string;
HACK_PARSER_BUCKET_NAME: string;
TZ: string;
};
}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ On feature branches, don't worry about doing conventional commits. Instead, just
```

- `INTERVIEWING_CHANNEL_ID`, `ERRORS_CHANNEL_ID`, and `SPREADSHEET_ID` can be found in [`cdk.json`](.aws/cdk.json)
- `HACK_PARSER_BUCKET_NAME` can be found in [`cdk.json`](.aws/cdk.json)
- If provided as an empty string, the [HackParser](https://github.com/sourceallies/hack-parser) integration will be disabled.
- `SLACK_BOT_TOKEN`, `SLACK_SIGNING_SECRET`, `GOOGLE_SERVICE_ACCOUNT_EMAIL`, and `GOOGLE_PRIVATE_KEY` come from AWS Secrets Manager
- The `GOOGLE_PRIVATE_KEY` multi-line variable needs to be turned into a single line wrapped in quotes.
- `GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIEvQ\n-----END PRIVATE KEY-----"`
Expand Down
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ module.exports = {
coverageDirectory: 'coverage',
coverageThreshold: {
global: {
branches: 50,
functions: 70,
lines: 75,
statements: 70,
branches: 55,
functions: 75,
lines: 80,
statements: 75,
},
},
coveragePathIgnorePatterns: ['src/utils/log.ts'],
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
"preinstall": "npx only-allow pnpm"
},
"devDependencies": {
"@slack/types": "2.12.0",
"@types/chance": "1.1.6",
"@types/google-spreadsheet": "3.3.2",
"@types/jest": "29.5.12",
"@types/node": "18.19.34",
"@types/node-cron": "3.0.11",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"@slack/types": "2.12.0",
"chance": "1.1.11",
"eslint": "8.57.0",
"eslint-plugin-only-warn": "1.1.0",
Expand All @@ -47,6 +47,8 @@
"typescript": "5.4.5"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.665.0",
"@aws-sdk/s3-request-presigner": "^3.665.0",
"@slack/bolt": "3.18.0",
"dotenv": "16.4.5",
"google-spreadsheet": "3.3.0",
Expand Down
Loading

0 comments on commit 2b318eb

Please sign in to comment.