-
Notifications
You must be signed in to change notification settings - Fork 11
Feature: GitHub sync #27
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
Open
Musicminion
wants to merge
25
commits into
server-pro
Choose a base branch
from
feat-github-sync
base: server-pro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e6df30e
tmp: A naive github-sync framework
Musicminion fa29536
dev: update dev yml for github sync, also added with ldap test, Readm…
Musicminion a48fef0
web: update passport-ldapauth to 3.0.1
Musicminion 382d914
optimize: clean unused code and fix unauthorized github reminder
Musicminion 8ae6703
feat: support import and export for github
Musicminion 9d06105
github-sync: bug fix and new features:
Musicminion 76654fb
feature: support github sync with merge API, also frontend code
Musicminion 9c96646
fix: add clean up for github-sync
Musicminion e17d2c5
frontend: optimize import while loading
Musicminion 9094979
fix: use fast-forward to apply changes in overleaf if no update in gi…
Musicminion 5ababd6
ce: add github-sync to `server-ce`
Musicminion 370bf05
feat: add proxy for github sync
Musicminion 37f8b84
fix: proxy import from github-sync
Musicminion 7f1a7b7
fix: enhance GitHub sync Modal with need-auth modal for new user
Musicminion ff2527a
docs: update README
Musicminion dd03d8f
fix: refactor GitHub sync module imports to use dynamic loading
Musicminion edd28de
fix: add fetchJson import for GitHub sync in handler
Musicminion 17c0e85
github-sync: remove dev router
Musicminion 4511f94
ci: add `github-sync` to dev image
Musicminion 0886af2
fix: improve error handling in GitHub sync and optimize token storage
Musicminion bc23e17
fix: filter non-blob items in generateRespURL and update token validi…
Musicminion b0c869e
fix: enhance validation for GitHub sync state and improve error handling
Musicminion 34f0013
fix: update OLModal properties to disable initialFocus
Musicminion be50d34
fix: enhance error handling for GitHub branch diffing by checking res…
Musicminion 8745430
Add Star History section to README
Musicminion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 22.18.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # This file was auto-generated, do not edit it directly. | ||
| # Instead run bin/update_build_scripts from | ||
| # https://github.com/overleaf/internal/ | ||
|
|
||
| FROM node:22.18.0 AS base | ||
|
|
||
| WORKDIR /overleaf/services/github-sync | ||
|
|
||
| # Google Cloud Storage needs a writable $HOME/.config for resumable uploads | ||
| # (see https://googleapis.dev/nodejs/storage/latest/File.html#createWriteStream) | ||
| RUN mkdir /home/node/.config && chown node:node /home/node/.config | ||
|
|
||
| FROM base AS app | ||
|
|
||
| COPY package.json package-lock.json /overleaf/ | ||
| COPY libraries/access-token-encryptor/package.json /overleaf/libraries/access-token-encryptor/package.json | ||
| COPY libraries/fetch-utils/package.json /overleaf/libraries/fetch-utils/package.json | ||
| COPY libraries/logger/package.json /overleaf/libraries/logger/package.json | ||
| COPY libraries/metrics/package.json /overleaf/libraries/metrics/package.json | ||
| COPY libraries/mongo-utils/package.json /overleaf/libraries/mongo-utils/package.json | ||
| COPY libraries/o-error/package.json /overleaf/libraries/o-error/package.json | ||
| COPY libraries/promise-utils/package.json /overleaf/libraries/promise-utils/package.json | ||
| COPY libraries/settings/package.json /overleaf/libraries/settings/package.json | ||
| COPY libraries/stream-utils/package.json /overleaf/libraries/stream-utils/package.json | ||
| COPY services/github-sync/package.json /overleaf/services/github-sync/package.json | ||
| COPY tools/migrations/package.json /overleaf/tools/migrations/package.json | ||
| COPY patches/ /overleaf/patches/ | ||
| COPY tools/migrations/ /overleaf/tools/migrations/ | ||
|
|
||
| RUN cd /overleaf && npm ci --quiet | ||
| COPY libraries/access-token-encryptor/ /overleaf/libraries/access-token-encryptor/ | ||
| COPY libraries/fetch-utils/ /overleaf/libraries/fetch-utils/ | ||
| COPY libraries/logger/ /overleaf/libraries/logger/ | ||
| COPY libraries/metrics/ /overleaf/libraries/metrics/ | ||
| COPY libraries/mongo-utils/ /overleaf/libraries/mongo-utils/ | ||
| COPY libraries/o-error/ /overleaf/libraries/o-error/ | ||
| COPY libraries/promise-utils/ /overleaf/libraries/promise-utils/ | ||
| COPY libraries/settings/ /overleaf/libraries/settings/ | ||
| COPY libraries/stream-utils/ /overleaf/libraries/stream-utils/ | ||
| COPY services/github-sync/ /overleaf/services/github-sync/ | ||
| COPY tools/migrations/ /overleaf/tools/migrations/ | ||
|
|
||
| FROM app | ||
| USER node | ||
|
|
||
| CMD ["node", "--expose-gc", "app.js"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # GitHub Sync Service | ||
|
|
||
| Overleaf Github Sync Service, @Ayaka-notes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Metrics must be initialized before importing anything else | ||
| import '@overleaf/metrics/initialize.js' | ||
|
|
||
| import logger from '@overleaf/logger' | ||
| import Settings from '@overleaf/settings' | ||
| import { createServer } from './app/js/server.js' | ||
|
|
||
| const port = Settings.internal?.githubSync?.port | ||
| const host = Settings.internal?.githubSync?.host | ||
|
|
||
| const { server } = createServer() | ||
| server.listen(port, host, err => { | ||
| if (err) { | ||
| logger.fatal({ err }, `Cannot bind to ${host}:${port}. Exiting.`) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| logger.info({ host, port }, 'GitHub Sync service listening') | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // @ts-check | ||
|
|
||
| import Metrics from '@overleaf/metrics' | ||
| import Settings from '@overleaf/settings' | ||
| import MongoUtils from '@overleaf/mongo-utils' | ||
| import { MongoClient } from 'mongodb' | ||
|
|
||
| export { ObjectId } from 'mongodb' | ||
|
|
||
| export const mongoClient = new MongoClient( | ||
| Settings.mongo.url, | ||
| Settings.mongo.options | ||
| ) | ||
| const mongoDb = mongoClient.db() | ||
|
|
||
| export const db = { | ||
| githubSyncEntityVersions: mongoDb.collection('githubSyncEntityVersions'), | ||
| githubSyncProjectStates: mongoDb.collection('githubSyncProjectStates'), | ||
| githubSyncUserCredentials: mongoDb.collection('githubSyncUserCredentials'), | ||
| } | ||
|
|
||
| Metrics.mongodb.monitor(mongoClient) | ||
|
|
||
| export async function cleanupTestDatabase() { | ||
| await MongoUtils.cleanupTestDatabase(mongoClient) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import express from 'express' | ||
| import { db, ObjectId } from './mongodb.js' | ||
|
|
||
| export function createServer() { | ||
| const app = express() | ||
|
|
||
| app.get('/status', (_req, res) => { | ||
| res.status(200).json({ status: 'ok', service: 'github-sync' }) | ||
| }) | ||
|
|
||
| app.get('/healthz', (_req, res) => { | ||
| res.sendStatus(204) | ||
| }) | ||
|
|
||
| return { app, server: app } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| const http = require('node:http') | ||
| const https = require('node:https') | ||
|
|
||
| http.globalAgent.maxSockets = 300 | ||
| http.globalAgent.keepAlive = false | ||
| https.globalAgent.keepAlive = false | ||
|
|
||
| module.exports = { | ||
| internal: { | ||
| githubSync: { | ||
| host: process.env.GITHUB_SYNC_HOST || process.env.LISTEN_ADDRESS || '127.0.0.1', | ||
| port: 3022, | ||
| }, | ||
| }, | ||
|
|
||
| mongo: { | ||
| url: | ||
| process.env.MONGO_CONNECTION_STRING || | ||
| `mongodb://${process.env.MONGO_HOST || '127.0.0.1'}/sharelatex`, | ||
| options: { | ||
| monitorCommands: true, | ||
| }, | ||
| }, | ||
|
|
||
| apis: { | ||
| project_history: { | ||
| url: `http://${process.env.PROJECT_HISTORY_HOST || '127.0.0.1'}:3054`, | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| { | ||
| "name": "@overleaf/github-sync", | ||
| "description": "GitHub synchronization microservice for Overleaf", | ||
| "private": true, | ||
| "main": "app.js", | ||
| "type": "module", | ||
| "scripts": { | ||
| "start": "node app.js", | ||
| "nodemon": "node --watch app.js", | ||
| "lint": "eslint --max-warnings 0 --format unix .", | ||
| "format": "prettier --list-different $PWD/'**/{*.*js,*.ts}'", | ||
| "format:fix": "prettier --write $PWD/'**/{*.*js,*.ts}'", | ||
| "lint:fix": "eslint --fix .", | ||
| "types:check": "tsc --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "@octokit/request": "^9.2.2", | ||
| "@overleaf/access-token-encryptor": "*", | ||
| "@overleaf/fetch-utils": "*", | ||
| "@overleaf/logger": "*", | ||
| "@overleaf/metrics": "*", | ||
| "@overleaf/mongo-utils": "*", | ||
| "@overleaf/o-error": "*", | ||
| "@overleaf/promise-utils": "*", | ||
| "@overleaf/settings": "*", | ||
| "async": "^3.2.5", | ||
| "base64-stream": "^0.1.2", | ||
| "body-parser": "1.20.4", | ||
| "bunyan": "^1.8.15", | ||
| "express": "4.22.1", | ||
| "lodash": "^4.17.21", | ||
| "mongodb-legacy": "6.1.3", | ||
| "nock": "^13.5.6", | ||
| "octonode": "0.9.5", | ||
| "p-limit": "^2.2.0", | ||
| "randomstring": "^1.1.5", | ||
| "request": "2.88.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@overleaf/migrations": "*", | ||
| "@overleaf/stream-utils": "*", | ||
| "@pollyjs/adapter-node-http": "^6.0.6", | ||
| "@pollyjs/core": "^6.0.6", | ||
| "@pollyjs/persister-fs": "^6.0.6", | ||
| "chai": "^4.3.6", | ||
| "chai-as-promised": "^7.1.1", | ||
| "mocha": "^11.1.0", | ||
| "mocha-junit-reporter": "^2.2.1", | ||
| "mocha-multi-reporters": "^1.5.1", | ||
| "sandboxed-module": "^2.0.4", | ||
| "sinon": "^9.2.4", | ||
| "sinon-chai": "^3.7.0", | ||
| "timekeeper": "2.2.0", | ||
| "typescript": "^5.0.4" | ||
| }, | ||
| "version": "1.0.0", | ||
| "license": "AGPL-3.0" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
services/web/modules/github-sync/app/models/githubSyncUserCredentials.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import mongoose from "../../../../app/src/infrastructure/Mongoose.mjs" | ||
|
|
||
| const { Schema } = mongoose | ||
| const { ObjectId } = Schema | ||
|
|
||
| export const GitHubSyncUserCredentialsSchema = new Schema( | ||
| { | ||
| userId: { type: ObjectId, ref: 'User', required: true, unique: true }, | ||
| auth_token_encrypted: { type: String, required: true }, | ||
| }, | ||
| { collection: 'githubSyncUserCredentials', minimize: false } | ||
| ) | ||
|
|
||
| export const GitHubSyncUserCredentials = mongoose.model( | ||
| 'GitHubSyncUserCredentials', | ||
| GitHubSyncUserCredentialsSchema, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These module imports are always enabled in
overleafModuleImports, so GitHub UI surfaces even whenGITHUB_SYNC_ENABLEDis false. In that configuration the backend router is not mounted, so users still see GitHub actions but hit missing endpoints (for example status/auth routes), which breaks the intended disable switch for this feature.Useful? React with 👍 / 👎.