mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #1057 from sharelatex/ja-update-git-ignore
Don't gitignore new module directories GitOrigin-RevId: f6c4a65af6fa98c879c0ceb952f3161d6f395dee
This commit is contained in:
parent
eecbbc045d
commit
3abfe36279
6 changed files with 0 additions and 311 deletions
4
services/web/.gitignore
vendored
4
services/web/.gitignore
vendored
|
@ -69,7 +69,6 @@ public/stylesheets/style.css
|
|||
public/stylesheets/ol-style.css
|
||||
public/stylesheets/ol-light-style.css
|
||||
public/stylesheets/*.map
|
||||
public/brand/
|
||||
public/minjs/
|
||||
|
||||
Gemfile.lock
|
||||
|
@ -82,9 +81,6 @@ public/js/libs/require*.js
|
|||
*.swp
|
||||
.DS_Store
|
||||
|
||||
app/views/external
|
||||
|
||||
modules
|
||||
docker-shared.yml
|
||||
|
||||
config/*.coffee
|
||||
|
|
215
services/web/Jenkinsfile
vendored
215
services/web/Jenkinsfile
vendored
|
@ -1,215 +0,0 @@
|
|||
String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
|
||||
|
||||
pipeline {
|
||||
|
||||
agent any
|
||||
|
||||
environment {
|
||||
HOME = "/tmp"
|
||||
GIT_PROJECT = "web-sharelatex-internal"
|
||||
JENKINS_WORKFLOW = "web-sharelatex-internal"
|
||||
TARGET_URL = "${env.JENKINS_URL}blue/organizations/jenkins/${JENKINS_WORKFLOW}/detail/$BRANCH_NAME/$BUILD_NUMBER/pipeline"
|
||||
GIT_API_URL = "https://api.github.com/repos/sharelatex/${GIT_PROJECT}/statuses/$GIT_COMMIT"
|
||||
}
|
||||
|
||||
triggers {
|
||||
pollSCM('* * * * *')
|
||||
cron(cron_string)
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Pre') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
|
||||
sh "curl $GIT_API_URL \
|
||||
--data '{ \
|
||||
\"state\" : \"pending\", \
|
||||
\"target_url\": \"$TARGET_URL\", \
|
||||
\"description\": \"Your build is underway\", \
|
||||
\"context\": \"ci/jenkins\" }' \
|
||||
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Copy external pages') {
|
||||
steps {
|
||||
sh 'bin/copy_external_pages'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Install') {
|
||||
agent {
|
||||
docker {
|
||||
image 'node:6.9.5'
|
||||
args "-v /var/lib/jenkins/.npm:/tmp/.npm"
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'git config --global core.logallrefupdates false'
|
||||
sh 'rm -rf node_modules/'
|
||||
sh 'npm install --quiet'
|
||||
sh 'npm rebuild'
|
||||
// It's too easy to end up shrinkwrapping to an outdated version of translations.
|
||||
// Ensure translations are always latest, regardless of shrinkwrap
|
||||
sh 'npm install git+https://github.com/sharelatex/translations-sharelatex.git#master'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Compile') {
|
||||
agent {
|
||||
docker {
|
||||
image 'node:6.9.5'
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'make clean compile_full'
|
||||
// replace the build number placeholder for sentry
|
||||
sh 'node_modules/.bin/grunt version'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Lint') {
|
||||
agent {
|
||||
docker {
|
||||
image 'node:6.9.5'
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'make --no-print-directory lint'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Test and Minify') {
|
||||
parallel {
|
||||
stage('Unit Test') {
|
||||
agent {
|
||||
docker {
|
||||
image 'node:6.9.5'
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'make --no-print-directory test_unit MOCHA_ARGS="--reporter tap"'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Acceptance Test') {
|
||||
steps {
|
||||
// Spawns its own docker containers
|
||||
sh 'make --no-print-directory test_acceptance MOCHA_ARGS="--reporter tap"'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Minify') {
|
||||
agent {
|
||||
docker {
|
||||
image 'node:6.9.5'
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'WEBPACK_ENV=production make minify'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Frontend Unit Test') {
|
||||
steps {
|
||||
// Spawns its own docker containers
|
||||
sh 'make --no-print-directory test_frontend'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Package') {
|
||||
steps {
|
||||
sh 'rm -rf ./node_modules/grunt*'
|
||||
sh 'echo ${BUILD_NUMBER} > build_number.txt'
|
||||
sh 'touch build.tar.gz' // Avoid tar warning about files changing during read
|
||||
sh 'tar -czf build.tar.gz --exclude=build.tar.gz --exclude-vcs .'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Publish') {
|
||||
steps {
|
||||
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
|
||||
s3Upload(file:'build.tar.gz', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/${BUILD_NUMBER}.tar.gz")
|
||||
// The deployment process uses this file to figure out the latest build
|
||||
s3Upload(file:'build_number.txt', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/latest")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Sync OSS') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
agent {
|
||||
docker {
|
||||
image 'sharelatex/copybara'
|
||||
args "-u 0:0 -v /tmp/copybara:/root/copybara/cache"
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sshagent (credentials: ['GIT_DEPLOY_KEY']) {
|
||||
sh 'git config --global user.name Copybot'
|
||||
sh 'git config --global user.email copybot@overleaf.com'
|
||||
sh 'mkdir -p /root/.ssh'
|
||||
sh 'ssh-keyscan github.com >> /root/.ssh/known_hosts'
|
||||
sh 'COPYBARA_CONFIG=./copybara/copy.bara.sky copybara --git-committer-email=copybot@overleaf.com --git-committer-name=Copybot || true'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
sh 'make clean_ci'
|
||||
}
|
||||
|
||||
success {
|
||||
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
|
||||
sh "curl $GIT_API_URL \
|
||||
--data '{ \
|
||||
\"state\" : \"success\", \
|
||||
\"target_url\": \"$TARGET_URL\", \
|
||||
\"description\": \"Your build succeeded!\", \
|
||||
\"context\": \"ci/jenkins\" }' \
|
||||
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
|
||||
}
|
||||
}
|
||||
|
||||
failure {
|
||||
mail(from: "${EMAIL_ALERT_FROM}",
|
||||
to: "${EMAIL_ALERT_TO}",
|
||||
subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
|
||||
body: "Build: ${BUILD_URL}")
|
||||
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
|
||||
sh "curl $GIT_API_URL \
|
||||
--data '{ \
|
||||
\"state\" : \"failure\", \
|
||||
\"target_url\": \"$TARGET_URL\", \
|
||||
\"description\": \"Your build failed\", \
|
||||
\"context\": \"ci/jenkins\" }' \
|
||||
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The options directive is for configuration that applies to the whole job.
|
||||
options {
|
||||
// Only build one at a time
|
||||
disableConcurrentBuilds()
|
||||
|
||||
// we'd like to make sure remove old builds, so we don't fill up our storage!
|
||||
buildDiscarder(logRotator(numToKeepStr:'50'))
|
||||
|
||||
// And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
|
||||
timeout(time: 30, unit: 'MINUTES')
|
||||
}
|
||||
}
|
2
services/web/copybara/.gitignore
vendored
2
services/web/copybara/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
.ssh/
|
||||
.cache/
|
|
@ -1,59 +0,0 @@
|
|||
# Copybara Overleaf sync
|
||||
|
||||
[Copybara](https://github.com/google/copybara) is a utility for syncing one
|
||||
git repository with another, while performing modifications, such as removing
|
||||
directories. We use this to keep a public OSS mirror of our web repo, but with
|
||||
the modules directory removed. The modules directory is where we place all of
|
||||
our proprietary code.
|
||||
|
||||
## Running a sync locally
|
||||
|
||||
You will need a copy of the `sharelatex/copybara` container, which can be pulled
|
||||
in, or built from the [copy.bara project](
|
||||
https://github.com/google/copybara#getting-started-using-copybara):
|
||||
|
||||
```bash
|
||||
> git clone git@github.com:google/copybara.git
|
||||
> cd copybara
|
||||
> docker build --rm -t sharelatex/copybara .
|
||||
```
|
||||
|
||||
There is a `docker-compose.yml` file in this directory which configures
|
||||
everything. We mount out the copybara cache directory so we don't need to do a
|
||||
full git clone each time.
|
||||
|
||||
The `.ssh` directory in this directory should have the private key of the
|
||||
`sharelatex-ci` GitHub account placed into it (can be retrieved from Jenkins),
|
||||
and have github.com pre-authorized:
|
||||
```bash
|
||||
> mkdir -p ./.ssh
|
||||
> ssh-keyscan github.com > ./.ssh/known_hosts
|
||||
> echo 'SHARELATEX_CI_PRIVATE_KEY' > ./.ssh/id_rsa
|
||||
```
|
||||
These are mounted into the container for use by copybara.
|
||||
|
||||
## Initializing or fixing a bad state
|
||||
|
||||
By default, copy.bara expects to find some metadata in the destination repo
|
||||
commits which it wrote on the last run. This tells it where to pick up syncing
|
||||
any new changes in the source repo. However, on the first run, or if things get
|
||||
in a bad state, you can provide with an explicit reference to a commit in the
|
||||
source repo to start replaying commits from. Add the following to the
|
||||
`docker-compose.yml` config:
|
||||
```yaml
|
||||
copybara:
|
||||
...
|
||||
environment:
|
||||
...
|
||||
COPYBARA_OPTIONS: "--last-rev=COMMIT_SHA_FROM_SOURCE_REPO"
|
||||
```
|
||||
|
||||
If the destination repo gets out of sync in some way, reset its master branch
|
||||
to a point when things were in a good state, and then do a re-sync as above,
|
||||
but with the last-rev set to the corresponding good commit in the source repo.
|
||||
|
||||
## Running a sync in CI
|
||||
|
||||
The same `sharelatex/copybara` image and copybara config files is used by
|
||||
Jenkins to perform the sync at the end of a successful CI build of master. See
|
||||
the `Jenkinsfile` in the top level directory for this.
|
|
@ -1,17 +0,0 @@
|
|||
core.workflow(
|
||||
name = "default",
|
||||
origin = git.origin(
|
||||
url = "git@github.com:sharelatex/web-sharelatex-internal.git",
|
||||
ref = "master"
|
||||
),
|
||||
destination = git.destination(
|
||||
url = "git@github.com:sharelatex/web-sharelatex.git",
|
||||
fetch = "master",
|
||||
push = "master"
|
||||
),
|
||||
# Exclude the modules directory
|
||||
origin_files = glob(["**"], exclude = ["modules/**", "app/views/external/**", "public/brand/**"]),
|
||||
mode="ITERATIVE",
|
||||
migrate_noop_changes=True,
|
||||
authoring = authoring.pass_thru("Copybot <copybot@overleaf.com>")
|
||||
)
|
|
@ -1,14 +0,0 @@
|
|||
version: '2'
|
||||
|
||||
services:
|
||||
copybara:
|
||||
image: sharelatex/copybara
|
||||
volumes:
|
||||
- ./.ssh:/root/.ssh
|
||||
- .:/usr/src/app
|
||||
- ./.cache/:/root/copybara/cache/
|
||||
- $HOME/.gitconfig:/root/.gitconfig
|
||||
# Uncomment this to force copybara to start syncing from a certain commit
|
||||
# environment:
|
||||
# COPYBARA_OPTIONS: "--last-rev=67edeed2c2d8c1d478c9a65d19020a301174cc8e"
|
||||
command: copybara
|
Loading…
Reference in a new issue