diff --git a/roles/ci/tasks/main.yml b/roles/ci/tasks/main.yml index 5a4d902..21b68b6 100644 --- a/roles/ci/tasks/main.yml +++ b/roles/ci/tasks/main.yml @@ -1,65 +1,65 @@ --- # Jenkins configuration - name: Jenkins configuration template: src: config.xml dest: "/var/lib/jenkins/config.xml" owner: jenkins group: jenkins notify: restart jenkins - name: Jenkins Location configuration template: src: jenkins.model.JenkinsLocationConfiguration.xml dest: "/var/lib/jenkins/jenkins.model.JenkinsLocationConfiguration.xml" owner: jenkins group: jenkins notify: restart jenkins - name: Configure Jenkins session duration lineinfile: dest: /etc/sysconfig/jenkins regexp: ^JENKINS_ARGS= line: "JENKINS_ARGS=\"--prefix={{ jenkins_prefix }} --sessionTimeout=43200\"" notify: restart jenkins - name: Create admin user shell: echo 'hpsr=new hudson.security.HudsonPrivateSecurityRealm(false); hpsr.createAccount("{{ jenkins_admin_user }}", "{{ jenkins_admin_pass }}")' | java -jar /opt/jenkins/jenkins-cli.jar -s http://localhost:8080 groovy = args: creates: /var/lib/jenkins/users/admin/config.xml notify: restart jenkins # Install Phabricator CLI - name: Clone phabricator library repo git: - repo: https://github.com/phacility/libphutil.git + repo: https://secure.phabricator.com/source/libphutil.git dest: /opt/libphutil version: stable - name: Permissions for libphutil file: state: directory path: /opt/libphutil owner: jenkins group: jenkins recurse: yes - name: Clone arcanist repo git: - repo: https://github.com/phacility/arcanist.git + repo: https://secure.phabricator.com/diffusion/ARC/arcanist.git dest: /opt/arcanist version: stable - name: Permissions for arcanist file: state: directory path: /opt/arcanist owner: jenkins group: jenkins recurse: yes - name: Create symlink for arc file: path: /usr/local/bin/arc src: /opt/arcanist/bin/arc state: link diff --git a/roles/ci/templates/jenkins-slave-centos.docker b/roles/ci/templates/jenkins-slave-centos.docker index 494aef1..85c0172 100644 --- a/roles/ci/templates/jenkins-slave-centos.docker +++ b/roles/ci/templates/jenkins-slave-centos.docker @@ -1,62 +1,62 @@ # This Dockerfile is used to build an image containing basic stuff to be used as a Jenkins slave build node. FROM centos:7 MAINTAINER Jean-Baptiste Aubort # Make sure the package repository is up to date. RUN yum update -y # Install need packages RUN yum install -y \ sudo \ gcc \ gcc-c++ \ gcc-gfortran \ make \ cmake \ openssl-devel \ git \ subversion \ mercurial \ php-cli \ php-curl \ epel-release \ libffi-devel \ openssl-devel \ python-devel \ maven RUN yum update -y && yum install -y python2-pip # Install a basic SSH server RUN yum install -y openssh-server RUN ssh-keygen -A RUN sed -i 's|session required pam_loginuid.so|session optional pam_loginuid.so|g' /etc/pam.d/sshd RUN mkdir -p /var/run/sshd # Install JDK 7 (latest edition) RUN yum install -y java-1.7.0-openjdk # Add user jenkins to the image RUN adduser jenkins RUN usermod -a -G wheel jenkins RUN echo "jenkins:jenkins" | chpasswd RUN sed -i -e 's/# %wheel/%wheel/g' /etc/sudoers # Jenkins RUN mkdir /home/jenkins/workspace RUN chown jenkins.jenkins /home/jenkins/workspace # Phabricator API RUN cd /opt; \ - git clone https://github.com/phacility/arcanist.git; \ - git clone https://github.com/phacility/libphutil.git; \ + git clone https://secure.phabricator.com/diffusion/ARC/arcanist.git; \ + git clone https://secure.phabricator.com/source/libphutil.git; \ ln -s /opt/arcanist/bin/arc /usr/local/bin/arc # Clean RUN yum clean all # Standard SSH port EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"] diff --git a/roles/ci/templates/jenkins-slave-ubuntu.docker b/roles/ci/templates/jenkins-slave-ubuntu.docker index 1afe4e1..621b896 100644 --- a/roles/ci/templates/jenkins-slave-ubuntu.docker +++ b/roles/ci/templates/jenkins-slave-ubuntu.docker @@ -1,60 +1,60 @@ # This Dockerfile is used to build an image containing basic stuff to be used as a Jenkins slave build node. FROM ubuntu:trusty MAINTAINER Jean-Baptiste Aubort # Make sure the package repository is up to date. RUN apt-get update RUN apt-get -y upgrade # Install need packages RUN apt-get update && apt-get -y install \ bash-completion \ build-essential \ gfortran \ cmake \ git \ subversion \ mercurial \ php5-cli \ php5-curl \ python-pip \ python-dev \ libffi-dev \ libssl-dev \ maven # Remove uneeded packages RUN apt-get -y purge libgl1-mesa-dri # Install a basic SSH server RUN apt-get update && apt-get -y install openssh-server RUN sed -i 's|session required pam_loginuid.so|session optional pam_loginuid.so|g' /etc/pam.d/sshd RUN mkdir -p /var/run/sshd # Install JDK 7 (latest edition) RUN apt-get update && apt-get -y install openjdk-7-jdk # Add user jenkins to the image RUN adduser --quiet jenkins RUN adduser --quiet jenkins sudo RUN echo "jenkins:jenkins" | chpasswd RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers # Jenkins RUN mkdir /home/jenkins/workspace RUN chown jenkins.jenkins /home/jenkins/workspace # Phabricator API RUN cd /opt; \ - git clone https://github.com/phacility/arcanist.git; \ - git clone https://github.com/phacility/libphutil.git; \ + git clone https://secure.phabricator.com/diffusion/ARC/arcanist.git; \ + git clone https://secure.phabricator.com/source/libphutil.git; \ ln -s /opt/arcanist/bin/arc /usr/local/bin/arc # Clean RUN apt-get clean RUN rm -rf /var/lib/apt/lists/* # Standard SSH port EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"] diff --git a/roles/phabricator/files/DiffusionPreCommitContentSizeHeraldField.php b/roles/phabricator/files/DiffusionPreCommitContentSizeHeraldField.php deleted file mode 100644 index cca1814..0000000 --- a/roles/phabricator/files/DiffusionPreCommitContentSizeHeraldField.php +++ /dev/null @@ -1,48 +0,0 @@ -getAdapter(); - $hook = $adapter->getHookEngine(); - $repository = $hook->getRepository(); - $vcs = $repository->getVersionControlSystem(); - - if($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT) { - - $ref = $adapter->getObject()->getRefNew(); - $changesets = $hook->loadChangesetsForCommit($ref); - - $total_size = 0; - foreach($changesets as $change){ - $size = exec("git cat-file -s $ref:" . $change->getFileName()); - $total_size += (int) $size; - } - - if($total_size >= self::MAX_SIZE) { - return true; - } - - } - - return false; - } - - protected function getHeraldFieldStandardType() { - return HeraldField::STANDARD_BOOL; - } - -} diff --git a/roles/phabricator/files/PhabricatorAuthProviderShibboleth.php b/roles/phabricator/files/PhabricatorAuthProviderShibboleth.php deleted file mode 100644 index 7d25100..0000000 --- a/roles/phabricator/files/PhabricatorAuthProviderShibboleth.php +++ /dev/null @@ -1,470 +0,0 @@ -adapter) { - $conf = $this->getProviderConfig(); - - - $adapter = id(new PhutilAuthAdapterShibboleth()) - ->setShibSessionIdField( - $conf->getProperty(self::KEY_SHIB_SESSION_ID_FIELD)) - ->setShibApplicationIdField( - $conf->getProperty(self::KEY_SHIB_APPLICATION_ID_FIELD)) - ->setUseridField( - $conf->getProperty(self::KEY_USERID_FIELD)) - ->setUsernameField( - $conf->getProperty(self::KEY_USERNAME_FIELD)) - ->setRealnameField( - $conf->getProperty(self::KEY_REALNAME_FIELD)) - ->setFirstnameField( - $conf->getProperty(self::KEY_FIRSTNAME_FIELD)) - ->setLastnameField( - $conf->getProperty(self::KEY_LASTNAME_FIELD)) - ->setEmailField( - $conf->getProperty(self::KEY_EMAIL_FIELD)) - ->setPageURIPattern( - $conf->getProperty(self::KEY_PAGE_URI_PATTERN)) - ->setImageURIPattern( - $conf->getProperty(self::KEY_IMAGE_URI_PATTERN)) - ->setAddUserToProject( - $conf->getProperty(self::KEY_ADD_USER_TO_PROJECT)) - ->setUserProject( - $conf->getProperty(self::KEY_USER_PROJECT)) - ->setIsGeneratedUsername( - $conf->getProperty(self::KEY_USERNAME_FROM_REALNAME)) - ->setOrgField( - $conf->getProperty(self::KEY_ORG_FIELD)) - ->setOrgCustomField( - $conf->getProperty(self::KEY_ORG_CUSTOM_FIELD)) - ->setOrgTypeField( - $conf->getProperty(self::KEY_ORG_TYPE_FIELD)); - $this->adapter = $adapter; - } - return $this->adapter; - } - - protected function renderLoginForm(AphrontRequest $request, $mode) { - $viewer = $request->getUser(); - $dialog = id(new AphrontDialogView()) - ->setSubmitURI($this->getLoginURI()) - ->setUser($viewer) - ->setTitle(pht('Login for Swiss Universities')) - ->addSubmitButton(pht('Login or Register')); - $remarkup = new PHUIRemarkupView($viewer, pht(<<addPadding(PHUI::PADDING_LARGE) - ->appendChild($remarkup); - $dialog->appendChild($frame); - return $dialog; - } - - public function isLoginFormAButton() { - return false; - } - - private function populateAdapter() { - $adapter = $this->getAdapter(); - $env = array(); - $env_names = $adapter->getEnvNames(); - foreach ($env_names as $h) { - if(array_key_exists($h, $_SERVER)) { - $env[$h] = $_SERVER[$h]; - } - } - return $adapter->setUserDataFromRequest($env); - } - - public function processLoginRequest( - PhabricatorAuthLoginController $controller) { - - $adapter = $this->getAdapter(); - $request = $controller->getRequest(); - $response = null; - $account = null; - - if (!$this->populateAdapter()) { - $response = $controller->buildProviderPageResponse( - $this, - id(new PHUIInfoView()) - ->setErrors(array(pht('Invalid Shibboleth session.'))) - ->addButton(id(new PHUIButtonView()) - ->setTag('a') - ->setText(pht('Return to home')) - ->setHref('/') - ) - ); - return array($account, $response); - } - - $account_id = $adapter->getAccountID(); - - return array($this->loadOrCreateAccount_custom($account_id, $request), $response); - } - - private function updateOrganization($userPHID, $adapter) { - $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); - if($adapter == null){ - $adapter = $this->getAdapter(); - } - if(strlen($adapter->getOrg()) && - strlen($adapter->getOrgType()) && - strlen($adapter->getOrgCustom()) - ) { - - $user = id(new PhabricatorUser()) - ->loadOneWhere('phid = %s', $userPHID); - - $field_list = PhabricatorCustomField::getObjectFields( - $user, PhabricatorCustomField::ROLE_VIEW); - $field_list->readFieldsFromStorage($user); - - $orgvalue = null; - foreach($field_list->getFields() as $field){ - try { - if($field->getFieldKey()=='std:user:' . $adapter->getOrgCustom()){ - $orgvalue = $field->getValueForStorage(); - break; - } - } catch (Exception $e) { - } - } - - if(empty($orgvalue)) { - $xactions = array(); - $xactions[] = id(new PhabricatorUserTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD) - ->setMetadataValue('customfield:key', 'std:user:' . $adapter->getOrgCustom()) - ->setOldValue('') - ->setNewValue($adapter->getOrg() . ' (' . $adapter->getOrgType() . ')'); - $xactions[] = id(new PhabricatorUserTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD) - ->setMetadataValue('customfield:key', 'user:title') - ->setOldValue('') - ->setNewValue(' '); - $xactions[] = id(new PhabricatorUserTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD) - ->setMetadataValue('customfield:key', 'user:blurb') - ->setOldValue('') - ->setNewValue(' '); - - id(new PhabricatorUserProfileEditor()) - ->setActor($user) - ->setContentSource(PhabricatorContentSource::newForSource('console')) - ->setContinueOnNoEffect(true) - ->applyTransactions($user, $xactions); - } - } - unset($unguarded); - } - - private function updateProjects($userPHID, $adapter) { - $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); - if($adapter == null){ - $adapter = $this->getAdapter(); - } - $projects = $adapter->getUserProject(); - if(count($projects)) { - - $admin = id(new PhabricatorUser()) - ->loadOneWhere('isAdmin = 1'); - - $user_projects = id(new PhabricatorProjectQuery()) - ->setViewer($admin) - ->withMemberPHIDs(array($userPHID)) - ->withPHIDs($projects) - ->execute(); - - $check_proj = array(); - foreach($user_projects as $r){ - $check_proj[] = $r->getPHID(); - } - - $results = id(new PhabricatorProjectQuery()) - ->setViewer($admin) - ->withPHIDs($projects) - ->execute(); - - // Add user to project - foreach($results as $project) { - if(in_array($project->getPHID(), $check_proj)){ - continue; - } - $spec = array( - '+' => array($userPHID => $userPHID), - ); - $edge_type = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; - $xactions = array(); - $xactions[] = id(new PhabricatorProjectTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) - ->setMetadataValue('edge:type', $edge_type) - ->setNewValue($spec); - $editor = id(new PhabricatorProjectTransactionEditor()) - ->setActor($admin) - ->setContentSource(new PhabricatorConsoleContentSource()) - ->setContinueOnNoEffect(true) - ->applyTransactions($project, $xactions); - } - } - unset($unguarded); - } - - protected function loadOrCreateAccount_custom($account_id, $request) { - $account = parent::loadOrCreateAccount($account_id); - $adapter = $this->getAdapter(); - - if(!$adapter) { - return $account; - } - - if(!$account->getUserPHID()){ - if ($account instanceof PhabricatorExternalAccount - && $request->getViewer()->getPHID()) { - $this->updateProjects($request->getViewer()->getPHID(), $adapter); - } - // User account not yet created - return $account; - } - - $this->updateOrganization($account->getUserPHID(), $adapter); - $this->updateProjects($account->getUserPHID(), $adapter); - - return $account; - } - - public function willRegisterAccount(PhabricatorExternalAccount $account) { - parent::willRegisterAccount($account); - //$this->updateOrganization($account); // no shib env variables here :/ - $this->updateProjects($account->getUserPHID(), null); - } - - const KEY_SHIB_SESSION_ID_FIELD = 'shibboleth:session_id_field'; - const KEY_SHIB_APPLICATION_ID_FIELD = 'shibboleth:application_id_field'; - const KEY_USERID_FIELD = 'shibboleth:userid_field'; - const KEY_USERNAME_FIELD = 'shibboleth:username_field'; - const KEY_REALNAME_FIELD = 'shibboleth:realname_field'; - const KEY_FIRSTNAME_FIELD = 'shibboleth:firstname_field'; - const KEY_LASTNAME_FIELD = 'shibboleth:lastname_field'; - const KEY_EMAIL_FIELD = 'shibboleth:email_field'; - const KEY_ORG_FIELD = 'shibboleth:org'; - const KEY_ORG_TYPE_FIELD = 'shibboleth:org_type'; - const KEY_ORG_CUSTOM_FIELD = 'shibboleth:org_custom'; - const KEY_PAGE_URI_PATTERN = 'shibboleth:page_uri_pattern'; - const KEY_IMAGE_URI_PATTERN = 'shibboleth:image_uri_pattern'; - const KEY_USERNAME_FROM_REALNAME = 'shibboleth:username_from_realname'; - const KEY_ADD_USER_TO_PROJECT = 'shibboleth:add_user_to_project'; - const KEY_USER_PROJECT = 'shibboleth:user_project'; - - private function getPropertyKeys() { - return array( - self::KEY_SHIB_SESSION_ID_FIELD, - self::KEY_SHIB_APPLICATION_ID_FIELD, - self::KEY_USERID_FIELD, - self::KEY_USERNAME_FIELD, - self::KEY_REALNAME_FIELD, - self::KEY_FIRSTNAME_FIELD, - self::KEY_LASTNAME_FIELD, - self::KEY_EMAIL_FIELD, - self::KEY_ORG_FIELD, - self::KEY_ORG_CUSTOM_FIELD, - self::KEY_ORG_TYPE_FIELD, - self::KEY_PAGE_URI_PATTERN, - self::KEY_IMAGE_URI_PATTERN, - self::KEY_USERNAME_FROM_REALNAME, - self::KEY_ADD_USER_TO_PROJECT, - self::KEY_USER_PROJECT - ); - } - - private function getPropertyLabels() { - return array( - self::KEY_SHIB_SESSION_ID_FIELD => pht('Session ID'), - self::KEY_SHIB_APPLICATION_ID_FIELD => pht('Application ID'), - self::KEY_USERID_FIELD => pht('User ID'), - self::KEY_USERNAME_FIELD => pht('Username'), - self::KEY_REALNAME_FIELD => pht('Real name'), - self::KEY_FIRSTNAME_FIELD => pht('Firstname'), - self::KEY_LASTNAME_FIELD => pht('Lastname'), - self::KEY_EMAIL_FIELD => pht('User emailname'), - self::KEY_ORG_FIELD => pht('Organization'), - self::KEY_ORG_CUSTOM_FIELD => pht('Organization custom field'), - self::KEY_ORG_TYPE_FIELD => pht('Organization type'), - self::KEY_PAGE_URI_PATTERN => pht('User page URI pattern'), - self::KEY_IMAGE_URI_PATTERN => pht('User image URI pattern'), - ); - } - - public function readFormValuesFromProvider() { - $properties = array(); - foreach ($this->getPropertyKeys() as $key) { - $properties[$key] = $this->getProviderConfig()->getProperty($key); - } - return $properties; - } - - public function readFormValuesFromRequest(AphrontRequest $request) { - $values = array(); - foreach ($this->getPropertyKeys() as $key) { - if($key == self::KEY_USER_PROJECT) { - $values[$key] = $request->getArr($key); - } else { - $values[$key] = $request->getStr($key); - } - } - return $values; - } - - public function processEditForm( - AphrontRequest $request, - array $values) { - $errors = array(); - $issues = array(); - return array($errors, $issues, $values); - } - - public function extendEditForm( - AphrontRequest $request, - AphrontFormView $form, - array $values, - array $issues) { - - $labels = $this->getPropertyLabels(); - - $captions = array( - self::KEY_SHIB_SESSION_ID_FIELD => pht('Shibboleth Session ID, e.g.: Shib-Session-ID'), - self::KEY_SHIB_APPLICATION_ID_FIELD => pht('Shibboleth application id, e.g.: Shib-Application-ID'), - self::KEY_USERID_FIELD => pht('Unique user id for internal Phabricator use. e.g.: uniqueID'), - self::KEY_USERNAME_FIELD => pht('Visible username, can be left empty if you choose to autogenerate it. e.g.: username'), - self::KEY_REALNAME_FIELD => pht('Visible in the user profile. e.g.: displayName'), - self::KEY_FIRSTNAME_FIELD => pht('Use this only when you autogenerate username. e.g.: givenName'), - self::KEY_LASTNAME_FIELD => pht('Use this only when you autogenerate username. e.g.: surname'), - self::KEY_EMAIL_FIELD => pht('Unique email address. e.g.: email'), - self::KEY_ORG_FIELD => pht('Organization name. e.g.: homeOrganization'), - self::KEY_ORG_CUSTOM_FIELD => pht('Organization name custom field in Phabricator. e.g.: mycompany:org'), - self::KEY_ORG_TYPE_FIELD => pht('Organization type. e.g.: homeOrganizationType'), - self::KEY_PAGE_URI_PATTERN => pht('URI pattern to a user pag. Add %%s for replacement with the username'), - self::KEY_IMAGE_URI_PATTERN => pht('URI pattern to an image for the user. Add %%s for replacement with the username'), - self::KEY_USER_PROJECT => pht('Project ID to add the user to. e.g.: PHID-PROJ-itwdg3fgxutsrdnqjklb'), - ); - - // Text fields - foreach ($labels as $key => $label) { - $caption = idx($captions, $key); - $value = idx($values, $key); - - $control = null; - $control = id(new AphrontFormTextControl()) - ->setName($key) - ->setLabel($label) - ->setCaption($caption) - ->setValue($value); - - $form->appendChild($control); - } - - // Add to project - $form->appendChild( - id(new AphrontFormCheckboxControl()) - ->addCheckbox( - self::KEY_ADD_USER_TO_PROJECT, - 1, - hsprintf('%s: %s', "Add to default Project", - "Automatically add the new user to a default project"), - idx($values, self::KEY_ADD_USER_TO_PROJECT)) - ); - $projects = idx($values, self::KEY_USER_PROJECT, array()); - $viewer = $request->getViewer(); - $form->appendChild( - id(new AphrontFormTokenizerControl()) - ->setLabel(pht('Projects')) - ->setName(self::KEY_USER_PROJECT) - ->setValue($projects) - ->setUser($viewer) - //->setDisabled(!idx($values, self::KEY_ADD_USER_TO_PROJECT)) - ->setDatasource(new PhabricatorProjectDatasource()) - ); - - // Generate username - $form->appendChild( - id(new AphrontFormCheckboxControl()) - ->addCheckbox( - self::KEY_USERNAME_FROM_REALNAME, - 1, - hsprintf('%s: %s', "Generated username", - "Create a unique username from the surname and firstname which complies with Phabricator policies."), - idx($values, self::KEY_USERNAME_FROM_REALNAME)) - ); - } - - public function renderConfigPropertyTransactionTitle( - PhabricatorAuthProviderConfigTransaction $xaction) { - - $author_phid = $xaction->getAuthorPHID(); - $old = $xaction->getOldValue(); - $new = $xaction->getNewValue(); - $key = $xaction->getMetadataValue( - PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY); - - $labels = $this->getPropertyLabels(); - if (isset($labels[$key])) { - $label = $labels[$key]; - - if (!strlen($old)) { - return pht( - '%s set the "%s" value to "%s".', - $xaction->renderHandleLink($author_phid), - $label, - $new); - } else { - return pht( - '%s changed the "%s" value from "%s" to "%s".', - $xaction->renderHandleLink($author_phid), - $label, - $old, - $new); - } - } - - return parent::renderConfigPropertyTransactionTitle($xaction); - } - - public static function getShibbolethProvider() { - $providers = self::getAllEnabledProviders(); - - foreach ($providers as $provider) { - if ($provider instanceof PhabricatorAuthProviderShibboleth) { - return $provider; - } - } - - return null; - } - -} diff --git a/roles/phabricator/files/PhabricatorC4scienceApplication.php b/roles/phabricator/files/PhabricatorC4scienceApplication.php deleted file mode 100644 index 983e3a3..0000000 --- a/roles/phabricator/files/PhabricatorC4scienceApplication.php +++ /dev/null @@ -1,37 +0,0 @@ - 'PhabricatorSitemapsController', - '/project/wiki/' => 'PhabricatorProjectWikiCreate', - '/project/wiki/create/(?P[1-9]\d*)/' => 'PhabricatorProjectWikiCreate', - '/project/wiki/view/(?P[1-9]\d*)/' => 'PhabricatorProjectWikiView', - ); - } - -} diff --git a/roles/phabricator/files/PhabricatorCustomRobotsController.php b/roles/phabricator/files/PhabricatorCustomRobotsController.php deleted file mode 100644 index 60ac79a..0000000 --- a/roles/phabricator/files/PhabricatorCustomRobotsController.php +++ /dev/null @@ -1,26 +0,0 @@ -setContent($content) - ->setCacheDurationInSeconds(phutil_units('2 hours in seconds')) - ->setCanCDN(true); - } -} diff --git a/roles/phabricator/files/PhabricatorDashboardC4sciencePanelType.php b/roles/phabricator/files/PhabricatorDashboardC4sciencePanelType.php deleted file mode 100644 index 470f786..0000000 --- a/roles/phabricator/files/PhabricatorDashboardC4sciencePanelType.php +++ /dev/null @@ -1,75 +0,0 @@ -additem( - id(new PHUIObjectItemView()) - ->setHeader(pht('Create a Project')) - ->setSubHead(pht('Project tags define everything. ' . - 'Create them for teams, tags, or actual projects.')) - ->setImageIcon('fa-briefcase') - ->setHref('/project/edit/form/default/') - ); - - $list->additem( - id(new PHUIObjectItemView()) - ->setHeader(pht('Create a GIT Repository')) - ->setSubHead(pht('If you are here for code review, ' . - 'let\'s set up your first repository.')) - ->setImageIcon('fa-code') - ->setHref('/diffusion/edit/form/default/?vcs=git') - ); - - $list->additem( - id(new PHUIObjectItemView()) - ->setHeader(pht('Report a bug / Give feedback')) - ->setSubHead(pht('We can only make c4science better with you.')) - ->setImageIcon('fa-bug') - ->setHref('/maniphest/task/edit/form/8/') - ); - - $list->additem( - id(new PHUIObjectItemView()) - ->setHeader(pht('Read the Documentation')) - ->setSubHead(pht('Reading is a common way to learn about things.')) - ->setImageIcon('fa-book') - ->setHref('/w/c4science') - ); - - $box = id(new PHUIObjectBoxView()) - ->setObjectlist($list); - - return $box; - - } - -} diff --git a/roles/phabricator/files/PhabricatorProjectWikiCreate.php b/roles/phabricator/files/PhabricatorProjectWikiCreate.php deleted file mode 100644 index a5275df..0000000 --- a/roles/phabricator/files/PhabricatorProjectWikiCreate.php +++ /dev/null @@ -1,138 +0,0 @@ -getViewer(); - $id = (int)$request->getURIData('id'); - - $project = id(new PhabricatorProjectQuery()) - ->withIDs(array($id)) - ->setViewer($viewer) - ->needSlugs(true) - ->executeOne(); - - if(!$project) { - return new Aphront404Response(); - } - - $project_slug = PhabricatorProjectWikiCreate::getAllSlugs($project); - - if ($request->isFormPost()) { - $slug = $project_slug . PhabricatorSlug::normalize($request->getStr('slug')); - try { - $this->createDocument($slug, $viewer, $project); - } catch(PhabricatorApplicationTransactionValidationException $ex) { - return id(new PhabricatorApplicationTransactionValidationResponse()) - ->setCancelURI('/project/view/' . $id) - ->setException($ex); - } catch(AphrontDuplicateKeyQueryException $ex) { - } - return id(new AphrontRedirectResponse()) - ->setURI('/phriction/edit/?slug='. $slug); - } - - $wiki_document = id(new PhrictionDocumentQuery()) - ->setViewer($viewer) - ->withStatus(PhrictionDocumentQuery::STATUS_NONSTUB) - ->withSlugPrefix($project_slug) - ->execute(); - - if(!$wiki_document){ - $view = id(new PHUIFormLayoutView()) - ->appendChild(phutil_tag( - 'p', - array(), - pht('/w/' . $project_slug))); - } else { - $view = id(new PHUIFormLayoutView()) - ->appendChild(id(new AphrontFormTextControl()) - ->setLabel('Name') - ->setValue('') - ->setName('slug')); - } - - return $this->newDialog() - ->setTitle(pht('New Document')) - ->setSubmitURI('/project/wiki/create/' . $id . '/') - ->appendChild(phutil_tag('p', - array(), - pht('Create a new document'))) - ->appendChild($view) - ->addSubmitButton(pht('Create')) - ->addCancelButton('/project/view/' . $id); - - } - - protected function buildApplicationCrumbs() { - $crumbs = parent::buildApplicationCrumbs(); - - id(new AlmanacServiceEditEngine()) - ->setViewer($this->getViewer()) - ->addActionToCrumbs($crumbs); - - return $crumbs; - } - - private function createDocument($slugs, $viewer, $project) { - // Get admin user - $admin = id(new PhabricatorUser()) - ->loadOneWhere('isAdmin = 1'); - - // Taken from conduit/PhrictionCreateConduitAPIMethod.php - $doc = PhrictionDocument::initializeNewDocument($viewer, $slugs); - - $xactions = array(); - $xactions[] = id(new PhrictionTransaction()) - ->setTransactionType(PhrictionTransaction::TYPE_TITLE) - ->setNewValue(PhabricatorSlug::getDefaultTitle($slugs)); - $xactions[] = id(new PhrictionTransaction()) - ->setTransactionType(PhrictionTransaction::TYPE_CONTENT) - ->setNewValue(' '); - $xactions[] = id(new PhrictionTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) - ->setNewValue($project->getPHID()); - $xactions[] = id(new PhrictionTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) - ->setNewValue($project->getPHID()); - - $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; - $xactions[] = id(new PhrictionTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) - ->setMetadataValue('edge:type', $proj_edge_type) - ->setNewValue(array('=' => array_fuse(array($project->getPHID())))); - - $editor = id(new PhrictionTransactionEditor()) - ->setActor($admin) - ->setActingAsPHID($viewer->getPHID()) - ->setContentSource(PhabricatorContentSource::newForSource('web')) - ->applyTransactions($doc, $xactions); - - } - - static function getParentSlug($project, $slug_stack=NULL) { - if(!$slug_stack){ - $slug_stack = array($project->getPrimarySlug()); - } - $parent = $project->getParentProject(); - if($parent) { - $slug = $parent->getPrimarySlug(); - $slug_stack[] = $slug; - return PhabricatorProjectWikiCreate::getParentSlug($parent, $slug_stack); - } - return $slug_stack; - } - - static function getAllSlugs($project){ - $slug = PhabricatorProjectWikiCreate::getParentSlug($project); - $slug = array_reverse($slug); - $slug = implode('/', $slug) . '/'; - return $slug; - } - -} diff --git a/roles/phabricator/files/PhabricatorProjectWikiProfilePanel.php b/roles/phabricator/files/PhabricatorProjectWikiProfilePanel.php deleted file mode 100644 index f974aca..0000000 --- a/roles/phabricator/files/PhabricatorProjectWikiProfilePanel.php +++ /dev/null @@ -1,66 +0,0 @@ -getMenuItemProperty('name'); - - if (strlen($name)) { - return $name; - } - - return $this->getDefaultName(); - } - - public function buildEditEngineFields( - PhabricatorProfileMenuItemConfiguration $config) { - return array( - id(new PhabricatorTextEditField()) - ->setKey('name') - ->setLabel(pht('Name')) - ->setPlaceholder($this->getDefaultName()) - ->setValue($config->getMenuItemProperty('name')), - ); - } - - protected function newNavigationMenuItems( - PhabricatorProfileMenuItemConfiguration $config) { - - $project = $config->getProfileObject(); - - $id = $project->getID(); - - $name = $this->getDisplayName($config); - $icon = 'fa-book'; - $href = "/project/wiki/view/{$id}/"; - - $item = $this->newItem() - ->setHref($href) - ->setName($name) - ->setIcon($icon); - - return array( - $item, - ); - } - -} - diff --git a/roles/phabricator/files/PhabricatorProjectWikiView.php b/roles/phabricator/files/PhabricatorProjectWikiView.php deleted file mode 100644 index 09bcea5..0000000 --- a/roles/phabricator/files/PhabricatorProjectWikiView.php +++ /dev/null @@ -1,106 +0,0 @@ -getViewer(); - $id = $request->getURIData('id'); - - $project = id(new PhabricatorProjectQuery()) - ->setViewer($viewer) - ->withIDs(array($id)) - ->needImages(true) - ->executeOne(); - if (!$project) { - return new Aphront404Response(); - } - - $this->setProject($project); - $title = pht('Wiki pages'); - - $curtain = $this->buildCurtainView($project); - - $query = id(new PhrictionDocumentQuery()) - ->setViewer($viewer) - ->needContent(true) - ->withStatus(PhrictionDocumentQuery::STATUS_OPEN) - ->withSlugPrefix(PhabricatorProjectWikiCreate::getAllSlugs($project)) - ->execute(); - - $wiki_list = new PHUIObjectItemListView(); - foreach($query as $w){ - $wiki_list->addItem( - id(new PHUIObjectItemView()) - ->setHeader($w->getContent()->getTitle()) - ->addAttribute($w->getSlug()) - ->setHref($w->getSlugURI($w->getSlug()))); - } - - $nav = $this->getProfileMenu(); - $nav->selectFilter(PhabricatorProjectWikiProfileMenuItem::MENUITEM_WIKI); - - $crumbs = $this->buildApplicationCrumbs(); - $crumbs->addCrumb( - id(new PHUICrumbView()) - ->setHref("/project/view/${id}") - ->setName($project->getName()) - ); - $crumbs->addTextCrumb(pht('Wiki')); - $crumbs->setBorder(true); - - $header = id(new PHUIHeaderView()) - ->setHeader($title) - ->setHeaderIcon('fa-book'); - - $view = id(new PHUITwoColumnView()) - ->setHeader($header) - ->setCurtain($curtain) - ->setMainColumn(array( - $wiki_list, - )); - - - return $this->newPage() - ->setNavigation($nav) - ->setCrumbs($crumbs) - ->setTitle(array($project->getName(), $title)) - ->appendChild($view); - } - - private function buildCurtainView(PhabricatorProject $project) { - $viewer = $this->getViewer(); - $id = $project->getID(); - - $curtain = $this->newCurtainView($project); - - $can_edit = PhabricatorPolicyFilter::hasCapability( - $viewer, - $project, - PhabricatorPolicyCapability::CAN_EDIT); - - if($can_edit) { - $curtain->addAction( - id(new PhabricatorActionView()) - ->setName('Create wiki page') - ->setIcon('fa-plus') - ->setHref("/project/wiki/create/{$id}/") - ->setWorkflow(true)); - } - - return $curtain; - } - - - protected function buildApplicationCrumbs() { - $view = new PHUICrumbsView(); - $view->addCrumb( - id(new PHUICrumbView()) - ->setHref('/project/') - ->setName(pht('Projects')) - ->setIcon('fa-briefcase') - ); - return $view; - } - -} diff --git a/roles/phabricator/files/PhabricatorSitemapsController.php b/roles/phabricator/files/PhabricatorSitemapsController.php deleted file mode 100644 index b253cc8..0000000 --- a/roles/phabricator/files/PhabricatorSitemapsController.php +++ /dev/null @@ -1,111 +0,0 @@ -getViewer(); - $out = array(); - - // headers - $out[] = ''; - $out[] = ''; - - // Static pages - $today = date("Y-m-d"); - $out[] = $this->url('/', $today, 'daily', '1.0'); - $out[] = $this->url('/diffusion/', $today, 'daily', '0.9'); - $out[] = $this->url('/phriction/', $today, 'daily', '0.9'); - $out[] = $this->url('/project/', $today, 'daily', '0.9'); - $out[] = $this->url('/audit/', $today, 'weekly', '0.5'); - $out[] = $this->url('/differential/', $today, 'weekly', '0.5'); - $out[] = $this->url('/maniphest/', $today, 'weekly', '0.5'); - $out[] = $this->url('/paste/', $today, 'weekly', '0.5'); - $out[] = $this->url('/feed/', $today, 'weekly', '0.4'); - $out[] = $this->url('/calendar/', $today, 'monthly', '0.1'); - $out[] = $this->url('/conpherence/', $today, 'monthly', '0.1'); - //$out[] = $this->url('/dashboard/', $today, 'monthly', '0.1'); - $out[] = $this->url('/people/', $today, 'monthly', '0.1'); - $out[] = $this->url('/phurl/', $today, 'monthly', '0.1'); - $out[] = $this->url('/badges/', $today, 'monthly', '0.1'); - $out[] = $this->url('/countdown/', $today, 'monthly', '0.1'); - $out[] = $this->url('/diviner/', $today, 'monthly', '0.1'); - $out[] = $this->url('/file/', $today, 'monthly', '0.1'); - $out[] = $this->url('/flag/', $today, 'monthly', '0.1'); - $out[] = $this->url('/harbormaster/', $today, 'monthly', '0.1'); - //$out[] = $this->url('/herald/', $today, 'monthly', '0.1'); - $out[] = $this->url('/legalpad/', $today, 'monthly', '0.1'); - $out[] = $this->url('/macro/', $today, 'monthly', '0.1'); - //$out[] = $this->url('/passphrase/', $today, 'monthly', '0.1'); - $out[] = $this->url('/applications/', $today, 'yearly', '0.0'); - $out[] = $this->url('/auth/', $today, 'never', '0.0'); - $out[] = $this->url('/config/', $today, 'never', '0.0'); - $out[] = $this->url('/daemon/', $today, 'never', '0.0'); - $out[] = $this->url('/mail/', $today, 'never', '0.0'); - //$out[] = $this->url('/conduit/', $today, 'never', '0.0'); - - // Repositories - $repo = id(new PhabricatorRepositoryQuery()) - ->setViewer($user) - ->withStatus(PhabricatorRepositoryQuery::STATUS_OPEN) - ->execute(); - foreach($repo as $r) { - $out[] = $this->url( - $r->getURI(), - date('c', $r->getDateModified()), - 'weekly', '0.8' - ); - } - - // Projects - $project = id(new PhabricatorProjectQuery()) - ->setViewer($user) - ->execute(); - foreach($project as $p) { - $out[] = $this->url( - $p->getURI(), - date('c', $p->getDateModified()), - 'weekly', '0.8' - ); - } - - // Wiki - $wiki = id(new PhrictionDocumentQuery()) - ->setViewer($user) - ->needContent(true) - ->withStatus(PhrictionDocumentQuery::STATUS_OPEN) - ->execute(); - foreach($wiki as $w) { - $out[] = $this->url( - $w->getSlugURI($w->getSlug()), - date('c', $w->getContent()->getDateModified()), - 'weekly', '0.8' - ); - } - - // Footer - $out[] = ''; - - $content = implode("\n", $out)."\n"; - - return id(new AphrontFileResponse()) - ->setContent($content) - ->setMimeType('text/xml') - ->setCacheDurationInSeconds(phutil_units('10 minutes in seconds')) - ->setCanCDN(true); - } - - private function url($loc, $mod, $freq, $priority) { - $uri = PhabricatorEnv::getURI($loc); - return - "" - . " ${uri}" - . " ${mod}" - . " ${freq}" - . " ${priority}" - . ""; - } -} diff --git a/roles/phabricator/files/PhabricatorUserOmnipotent.patch b/roles/phabricator/files/PhabricatorUserOmnipotent.patch deleted file mode 100644 index aab0456..0000000 --- a/roles/phabricator/files/PhabricatorUserOmnipotent.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/p ---- a/src/applications/people/storage/PhabricatorUser.php -+++ b/src/applications/people/storage/PhabricatorUser.php -@@ -357,7 +357,7 @@ final class PhabricatorUser - } - - public function getCSRFToken() { -- if ($this->isOmnipotent()) { -+ if ($this->isOmnipotent() && !$this->getIsAdmin()) { - // We may end up here when called from the daemons. The omnipotent user - // has no meaningful CSRF token, so just return `null`. - return null; -@@ -1113,6 +1113,11 @@ final class PhabricatorUser - * @return bool True if the user bypasses policy checks. - */ - public function isOmnipotent() { -+ // Allow administrators to bypass all policies. -+ if ($this->getIsAdmin()) { -+ return true; -+ } -+ - return $this->omnipotent; - } - diff --git a/roles/phabricator/files/RepositoryAuthorPolicyRule.php b/roles/phabricator/files/RepositoryAuthorPolicyRule.php deleted file mode 100644 index 03a4f61..0000000 --- a/roles/phabricator/files/RepositoryAuthorPolicyRule.php +++ /dev/null @@ -1,81 +0,0 @@ -getPHID(); - if (!$viewer_phid) { - return false; - } - - // Get repo phid when accessing a commit - if($object instanceof PhabricatorRepository){ - $repo_phid = $object->getPHID(); - } else if($object instanceof HarbormasterBuildable) { - $repo_phid = $object->getHarbormasterContainerPHID(); - } else if($object instanceof HarbormasterBuild) { - $repo_phid = $object->getBuildable()->getHarbormasterContainerPHID(); - } else { - $repo_phid = $object->getRepository()->getPHID(); - } - - // If the repository doesn't exist, we allow the user to create it - if(!$repo_phid){ - return true; - } - - // Get all repositories the user has created - $repo_transaction = id(new PhabricatorRepositoryTransactionQuery()) - ->setViewer(PhabricatorUser::getOmnipotentUser()) - ->withAuthorPHIDs(array($viewer_phid)) - ->withObjectPHIDs(array($repo_phid)) - ->withTransactionTypes(array(PhabricatorTransactions::TYPE_CREATE)) - ->executeOne(); - - if(!empty($repo_transaction)) { - return true; - } - return false; - } - - public function getValueControlType() { - return self::CONTROL_TYPE_NONE; - } - -} - diff --git a/roles/phabricator/files/RevisionAuthorPolicyRule.php b/roles/phabricator/files/RevisionAuthorPolicyRule.php deleted file mode 100644 index 8d5a4e0..0000000 --- a/roles/phabricator/files/RevisionAuthorPolicyRule.php +++ /dev/null @@ -1,55 +0,0 @@ -getPHID(); - if (!$viewer_phid) { - return false; - } - - // Get the revision author - $rev = id(new DifferentialRevisionQuery()) - ->setViewer(PhabricatorUser::getOmnipotentUser()) - ->withPHIDs(array($object->getPHID())) - ->executeOne(); - - // Allow the author - if($rev && $rev->getAuthorPHID() === $viewer->getPHID()){ - return true; - } - - return false; - } - - public function getValueControlType() { - return self::CONTROL_TYPE_NONE; - } - -} - diff --git a/roles/phabricator/files/RevisionReviewerPolicyRule.php b/roles/phabricator/files/RevisionReviewerPolicyRule.php deleted file mode 100644 index ada1128..0000000 --- a/roles/phabricator/files/RevisionReviewerPolicyRule.php +++ /dev/null @@ -1,92 +0,0 @@ -getPHID(); - if (!$viewer_phid) { - return false; - } - - // Get revision phid - if($object instanceof DifferentialRevision){ - $rev_phid = $object->getPHID(); - } else if($object instanceof DifferentialDiff) { - $diff_phid = $object->getPHID(); - $diff = id(new DifferentialDiffQuery()) - ->setViewer(PhabricatorUser::getOmnipotentUser()) - ->withPHIDs(array($diff_phid)) - ->executeOne(); - if($diff && $diff->hasRevision()){ - $rev_phid = $diff->getRevision()->getPHID(); - } else { - return false; - } - } - - // Get the revision reviewer - $rev = id(new DifferentialRevisionQuery()) - ->setViewer(PhabricatorUser::getOmnipotentUser()) - ->withPHIDs(array($rev_phid)) - ->needRelationships(true) - ->executeOne(); - - // Allow the reviewers - if($rev){ - $reviewers = $rev->getReviewers(); - if(in_array($viewer_phid, $reviewers)){ - return true; - } else { - // Check group reviewer - $projects = id(new PhabricatorProjectQuery()) - ->setViewer($viewer) - ->withMemberPHIDs(array($viewer_phid)) - ->execute(); - if($projects) { - $proj_phids = mpull($projects, 'getPHID'); - foreach($reviewers as $rev){ - if(in_array($rev, $proj_phids)){ - return true; - } - } - } - } - } - - return false; - } - - public function getValueControlType() { - return self::CONTROL_TYPE_NONE; - } - -} - diff --git a/roles/phabricator/files/delete_repo.patch b/roles/phabricator/files/delete_repo.patch deleted file mode 100644 index 455a40d..0000000 --- a/roles/phabricator/files/delete_repo.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel -index 6a2f70d..f3d09d2 100644 ---- a/src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php -+++ b/src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php -@@ -92,12 +92,12 @@ final class DiffusionRepositoryBasicsManagementPanel - ->setName($activate_label) - ->setDisabled(!$can_edit) - ->setWorkflow(true), -- id(new PhabricatorActionView()) -- ->setName(pht('Delete Repository')) -- ->setIcon('fa-times') -- ->setHref($delete_uri) -- ->setDisabled(true) -- ->setWorkflow(true), -+ //id(new PhabricatorActionView()) -+ // ->setName(pht('Delete Repository')) -+ // ->setIcon('fa-times') -+ // ->setHref($delete_uri) -+ // ->setDisabled(true) -+ // ->setWorkflow(true), - ); - } - diff --git a/roles/phabricator/files/feed_hide_group.patch b/roles/phabricator/files/feed_hide_group.patch deleted file mode 100644 index ceae1d1..0000000 --- a/roles/phabricator/files/feed_hide_group.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/src/applications/feed/query/PhabricatorFeedQuery.php -+++ b/src/applications/feed/query/PhabricatorFeedQuery.php -@@ -4,6 +4,7 @@ - extends PhabricatorCursorPagedPolicyAwareQuery { - - private $filterPHIDs; -+ private $filterOutPHIDs; - private $chronologicalKeys; - - public function setFilterPHIDs(array $phids) { -@@ -11,6 +12,11 @@ - return $this; - } - -+ public function setFilterOutPHIDs(array $phids) { -+ $this->filterOutPHIDs = $phids; -+ return $this; -+ } -+ - public function withChronologicalKeys(array $keys) { - $this->chronologicalKeys = $keys; - return $this; -@@ -59,6 +65,13 @@ - $this->filterPHIDs); - } - -+ if ($this->filterOutPHIDs) { -+ $where[] = qsprintf( -+ $conn_r, -+ 'ref.objectPHID NOT IN (%Ls)', -+ $this->filterOutPHIDs); -+ } -+ - if ($this->chronologicalKeys) { - // NOTE: We want to use integers in the query so we can take advantage - // of keys, but can't use %d on 32-bit systems. Make sure all the keys ---- a/src/applications/feed/query/PhabricatorFeedSearchEngine.php -+++ b/src/applications/feed/query/PhabricatorFeedSearchEngine.php -@@ -59,6 +59,16 @@ - $query->setFilterPHIDs($phids); - } - -+ // Get Shibboleth groups -+ $provider = PhabricatorAuthProviderShibboleth::getShibbolethProvider(); -+ $adapter = $provider->getAdapter(); -+ $projects = $adapter->getUserProject(); -+ -+ // Filter Shibboleth groups from feeds -+ if($projects){ -+ $query->setFilterOutPHIDs($projects); -+ } -+ - return $query; - } - diff --git a/roles/phabricator/files/harbormaster.patch b/roles/phabricator/files/harbormaster.patch deleted file mode 100644 index 3d3df7e..0000000 --- a/roles/phabricator/files/harbormaster.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/src/applications/harbormaster/stepgroup/HarbormasterDrydockBuildStepGroup.php b/src/applications/harbormaster/stepgroup/HarbormasterDrydockBuildStepGroup.p -index 606a47a..67cb9f0 100644 ---- a/src/applications/harbormaster/stepgroup/HarbormasterDrydockBuildStepGroup.php -+++ b/src/applications/harbormaster/stepgroup/HarbormasterDrydockBuildStepGroup.php -@@ -14,8 +14,9 @@ final class HarbormasterDrydockBuildStepGroup - } - - public function isEnabled() { -- $drydock_class = 'PhabricatorDrydockApplication'; -- return PhabricatorApplication::isClassInstalled($drydock_class); -+ return false; -+ //$drydock_class = 'PhabricatorDrydockApplication'; -+ //return PhabricatorApplication::isClassInstalled($drydock_class); - } - - public function shouldShowIfEmpty() { -diff --git a/src/applications/harbormaster/stepgroup/HarbormasterPrototypeBuildStepGroup.php b/src/applications/harbormaster/stepgroup/HarbormasterPrototypeBuildStepGro -index fb15764..c67fe38 100644 ---- a/src/applications/harbormaster/stepgroup/HarbormasterPrototypeBuildStepGroup.php -+++ b/src/applications/harbormaster/stepgroup/HarbormasterPrototypeBuildStepGroup.php -@@ -14,7 +14,8 @@ final class HarbormasterPrototypeBuildStepGroup - } - - public function isEnabled() { -- return PhabricatorEnv::getEnvConfig('phabricator.show-prototypes'); -+ return false; -+ //return PhabricatorEnv::getEnvConfig('phabricator.show-prototypes'); - } - - public function shouldShowIfEmpty() { diff --git a/roles/phabricator/files/home_public_dashboard.patch b/roles/phabricator/files/home_public_dashboard.patch deleted file mode 100644 index 617045f..0000000 --- a/roles/phabricator/files/home_public_dashboard.patch +++ /dev/null @@ -1,69 +0,0 @@ ---- a/src/applications/home/controller/PhabricatorHomeMainController.php -+++ b/src/applications/home/controller/PhabricatorHomeMainController.php -@@ -2,6 +2,8 @@ - - final class PhabricatorHomeMainController extends PhabricatorHomeController { - -+ const DASHBOARD_DEFAULT_LOGGEDIN = 'dashboard:default_loggedin'; -+ - public function shouldAllowPublic() { - return true; - } -@@ -19,10 +21,17 @@ - get_class($this->getCurrentApplication())); - - if (!$dashboard) { -- $dashboard = PhabricatorDashboardInstall::getDashboard( -- $viewer, -- PhabricatorHomeApplication::DASHBOARD_DEFAULT, -- get_class($this->getCurrentApplication())); -+ if($viewer->isLoggedIn()) { -+ $dashboard = PhabricatorDashboardInstall::getDashboard( -+ $viewer, -+ PhabricatorHomeMainController::DASHBOARD_DEFAULT_LOGGEDIN, -+ get_class($this->getCurrentApplication())); -+ } else { -+ $dashboard = PhabricatorDashboardInstall::getDashboard( -+ $viewer, -+ PhabricatorHomeApplication::DASHBOARD_DEFAULT, -+ get_class($this->getCurrentApplication())); -+ } - } - - if ($dashboard) { -@@ -202,35 +211,6 @@ - $pager->setPageSize(40); - $results = $engine->executeQuery($query, $pager); - $view = $engine->renderResults($results, $saved); -- // Low tech NUX. -- if (!$results && ($viewer->getIsAdmin() == 1)) { -- $instance = PhabricatorEnv::getEnvConfig('cluster.instance'); -- if (!$instance) { -- $content = pht(<<setObjectList($list); -- $view->setNoDataString($welcome); -- } - - $title = pht('Recent Activity'); - $href = '/feed/'; diff --git a/roles/phabricator/files/password_provider_button.patch b/roles/phabricator/files/password_provider_button.patch deleted file mode 100644 index 83b049d..0000000 --- a/roles/phabricator/files/password_provider_button.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- a/src/applications/auth/provider/PhabricatorPasswordAuthProvider.php -+++ b/src/applications/auth/provider/PhabricatorPasswordAuthProvider.php -@@ -5,7 +5,7 @@ - private $adapter; - - public function getProviderName() { -- return pht('Username/Password'); -+ return pht('Local Username/Password'); - } - - public function getConfigurationHelp() { -@@ -133,7 +133,11 @@ - public function buildLoginForm( - PhabricatorAuthStartController $controller) { - $request = $controller->getRequest(); -- return $this->renderPasswordLoginForm($request); -+ $attributes = array( -+ 'method' => 'GET', -+ 'uri' => '/auth/login/password:self/', -+ ); -+ return $this->renderStandardLoginButton($request, 'login', $attributes); - } - - public function buildInviteForm( -@@ -174,7 +178,7 @@ - $dialog = id(new AphrontDialogView()) - ->setSubmitURI($this->getLoginURI()) - ->setUser($viewer) -- ->setTitle(pht('Login to Phabricator')) -+ ->setTitle(pht('Login as external user')) - ->addSubmitButton(pht('Login')); - - if ($this->shouldAllowRegistration()) { -@@ -377,4 +381,8 @@ - public function shouldAllowEmailTrustConfiguration() { - return false; - } -+ -+ public function isLoginFormAButton() { -+ return true; -+ } - } diff --git a/roles/phabricator/files/project_panels.patch b/roles/phabricator/files/project_panels.patch deleted file mode 100644 index 4fe64bc..0000000 --- a/roles/phabricator/files/project_panels.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/src/applications/project/engine/PhabricatorProjectProfileMenuEngine.php -+++ b/src/applications/project/engine/PhabricatorProjectProfileMenuEngine.php -@@ -26,7 +26,8 @@ final class PhabricatorProjectProfileMenuEngine - - $items[] = $this->newItem() - ->setBuiltinKey(PhabricatorProject::ITEM_WORKBOARD) -- ->setMenuItemKey(PhabricatorProjectWorkboardProfileMenuItem::MENUITEMKEY); -+ ->setMenuItemKey(PhabricatorProjectWorkboardProfileMenuItem::MENUITEMKEY) -+ ->setVisibility(PhabricatorProfileMenuItemConfiguration::VISIBILITY_DISABLED); - - $items[] = $this->newItem() - ->setBuiltinKey(PhabricatorProject::ITEM_MEMBERS) -@@ -35,7 +36,22 @@ final class PhabricatorProjectProfileMenuEngine - $items[] = $this->newItem() - ->setBuiltinKey(PhabricatorProject::ITEM_SUBPROJECTS) - ->setMenuItemKey( -- PhabricatorProjectSubprojectsProfileMenuItem::MENUITEMKEY); -+ PhabricatorProjectSubprojectsProfileMenuItem::MENUITEMKEY) -+ ->setVisibility(PhabricatorProfileMenuItemConfiguration::VISIBILITY_DISABLED); -+ -+ $project = $this->getProfileObject(); -+ $items[] = $this->newItem() -+ ->setBuiltinKey('project.repo') -+ ->setMenuItemKey(PhabricatorLinkProfileMenuItem::MENUITEMKEY) -+ ->setMenuItemProperty('icon', 'diffusion') -+ ->setMenuItemProperty('name', pht('Repositories')) -+ ->setMenuItemProperty('uri', '/diffusion/?status=open&projectPHIDs=' -+ . $project->getPHID() . '#R'); -+ -+ $items[] = $this->newItem() -+ ->setBuiltinKey(PhabricatorProjectWikiProfileMenuItem::MENUITEM_WIKI) -+ ->setMenuItemKey(PhabricatorProjectWikiProfileMenuItem::MENUITEMKEY) -+ ->setVisibility(PhabricatorProfileMenuItemConfiguration::VISIBILITY_DISABLED); - - $items[] = $this->newItem() - ->setBuiltinKey(PhabricatorProject::ITEM_MANAGE) diff --git a/roles/phabricator/files/project_wiki_panel.patch b/roles/phabricator/files/project_wiki_panel.patch deleted file mode 100644 index 26ed807..0000000 --- a/roles/phabricator/files/project_wiki_panel.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/src/applications/project/controller/PhabricatorProjectViewController.php -+++ b/src/applications/project/controller/PhabricatorProjectViewController.php -@@ -21,6 +21,9 @@ final class PhabricatorProjectViewController - $default = $engine->getDefaultItem(); - - switch ($default->getBuiltinKey()) { -+ case PhabricatorProjectWikiProfileMenuItem::MENUITEM_WIKI: -+ $controller_object = new PhabricatorProjectWikiView(); -+ break; - case PhabricatorProject::ITEM_WORKBOARD: - $controller_object = new PhabricatorProjectBoardViewController(); - break; diff --git a/roles/phabricator/files/remarkup_latex.patch b/roles/phabricator/files/remarkup_latex.patch deleted file mode 100644 index 138798f..0000000 --- a/roles/phabricator/files/remarkup_latex.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/webroot/rsrc/css/core/remarkup.css -+++ b/webroot/rsrc/css/core/remarkup.css -@@ -1,5 +1,6 @@ - /** - * @provides phabricator-remarkup-css -+ * @requires katex-css - */ - - .phabricator-remarkup { ---- a/webroot/rsrc/css/phui/phui-document.css -+++ b/webroot/rsrc/css/phui/phui-document.css -@@ -1,5 +1,6 @@ - /** - * @provides phui-document-view-css -+ * @requires katex-css - */ - - .phui-document-view { diff --git a/roles/phabricator/files/remarkup_nowrap.patch b/roles/phabricator/files/remarkup_nowrap.patch deleted file mode 100644 index 7ff5c42..0000000 --- a/roles/phabricator/files/remarkup_nowrap.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/webroot/rsrc/css/core/remarkup.css -+++ b/webroot/rsrc/css/core/remarkup.css -@@ -782,3 +783,13 @@ var.remarkup-assist-textarea { - .remarkup-assist-pinned-spacer { - position: relative; - } -+ -+.phabricator-remarkup .remarkup-code-block pre { -+ white-space: pre; -+} -+ -+.phui-feed-story-body .remarkup-code-block pre, -+.phabricator-inline-summary-table .phabricator-remarkup .remarkup-code-block pre { -+ white-space: pre-wrap; -+} -+ diff --git a/roles/phabricator/files/repo_search_author.patch b/roles/phabricator/files/repo_search_author.patch deleted file mode 100644 index 7a72898..0000000 --- a/roles/phabricator/files/repo_search_author.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- a/src/applications/repository/query/PhabricatorRepositorySearchEngine.php -+++ b/src/applications/repository/query/PhabricatorRepositorySearchEngine.php -@@ -43,12 +43,39 @@ final class PhabricatorRepositorySearchEngine - ->setKey('uris') - ->setDescription( - pht('Search for repositories by clone/checkout URI.')), -+ id(new PhabricatorUsersSearchField()) -+ ->setLabel(pht('Author')) -+ ->setKey('authorPHIDs') -+ ->setAliases(array('author', 'authors')), - ); - } - - protected function buildQueryFromParameters(array $map) { - $query = $this->newQuery(); - -+ if ($map['authorPHIDs']) { -+ $viewer = $this->requireViewer(); -+ -+ $repo_transaction = id(new PhabricatorRepositoryTransactionQuery()) -+ ->setViewer($viewer) -+ ->withAuthorPHIDs($map['authorPHIDs']) -+ ->withTransactionTypes(array(PhabricatorTransactions::TYPE_CREATE)) -+ ->execute(); -+ -+ if(!empty($repo_transaction)) { -+ $repo_phids = mpull($repo_transaction, 'getObjectPHID'); -+ } -+ -+ if(!empty($repo_phids)) { -+ $query->withPHIDs($repo_phids); -+ } else { -+ // Force the query to have no result -+ $query->withPHIDs(array(NULL)); -+ // If there's no result here, no point of continuing to filter -+ return $query; -+ } -+ } -+ - if ($map['callsigns']) { - $query->withCallsigns($map['callsigns']); - } diff --git a/roles/phabricator/files/subproject.patch b/roles/phabricator/files/subproject.patch deleted file mode 100644 index a5c9fec..0000000 --- a/roles/phabricator/files/subproject.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/src/applications/project/controller/PhabricatorProjectSubprojectsControll -index 1232d40..05f4ab6 100644 ---- a/src/applications/project/controller/PhabricatorProjectSubprojectsController.php -+++ b/src/applications/project/controller/PhabricatorProjectSubprojectsController.php -@@ -127,12 +127,12 @@ final class PhabricatorProjectSubprojectsController - $view = id(new PHUIPropertyListView()) - ->setUser($viewer); - -- $view->addProperty( -- pht('Prototype'), -- $this->renderStatus( -- 'fa-exclamation-triangle red', -- pht('Warning'), -- pht('Subprojects and milestones are only partially implemented.'))); -+ //$view->addProperty( -+ // pht('Prototype'), -+ // $this->renderStatus( -+ // 'fa-exclamation-triangle red', -+ // pht('Warning'), -+ // pht('Subprojects and milestones are only partially implemented.'))); - - if (!$project->supportsMilestones()) { - $milestone_status = $this->renderStatus( diff --git a/roles/phabricator/files/wikirepo_people.patch b/roles/phabricator/files/wikirepo_people.patch deleted file mode 100644 index 9d0444f..0000000 --- a/roles/phabricator/files/wikirepo_people.patch +++ /dev/null @@ -1,119 +0,0 @@ ---- a/src/applications/people/controller/PhabricatorPeopleProfileViewController.php -+++ b/src/applications/people/controller/PhabricatorPeopleProfileViewController.php -@@ -58,8 +58,9 @@ - ->appendChild($feed); - - $projects = $this->buildProjectsView($user); -- $calendar = $this->buildCalendarDayView($user); -+ $repo = $this->buildrepoView($user); - $badges = $this->buildBadgesView($user); -+ $calendar = $this->buildCalendarDayView($user); - require_celerity_resource('project-view-css'); - - $home = id(new PHUITwoColumnView()) -@@ -73,8 +74,9 @@ - ->setSideColumn( - array( - $projects, -- $calendar, -+ $repo, - $badges, -+ $calendar, - )); - - $nav = $this->getProfileMenu(); -@@ -125,10 +127,8 @@ - ->setViewer($viewer) - ->withMemberPHIDs(array($user->getPHID())) - ->needImages(true) -- ->withStatuses( -- array( -- PhabricatorProjectStatus::STATUS_ACTIVE, -- )) -+ ->withStatuses(array(PhabricatorProjectStatus::STATUS_ACTIVE)) -+ ->withIcons(array('project')) - ->execute(); - - $header = id(new PHUIHeaderView()) -@@ -153,7 +153,7 @@ - ->setTag('a') - ->setIcon('fa-list-ul') - ->setText(pht('View All')) -- ->setHref('/project/?member='.$user->getPHID())); -+ ->setHref('/project/?member='.$user->getPHID().'#R')); - - } - -@@ -174,6 +174,72 @@ - return $box; - } - -+ private function buildRepoView( -+ PhabricatorUser $user) { -+ -+ $viewer = $this->getViewer(); -+ -+ $repo_transaction = id(new PhabricatorRepositoryTransactionQuery()) -+ ->setViewer($viewer) -+ ->withAuthorPHIDs(array($user->getPHID())) -+ ->withTransactionTypes(array(PhabricatorTransactions::TYPE_CREATE)) -+ ->execute(); -+ -+ if(!empty($repo_transaction)) { -+ $repo_phids = mpull($repo_transaction, 'getObjectPHID'); -+ $repo = id(new PhabricatorRepositoryQuery()) -+ ->setViewer($viewer) -+ ->withPHIDs($repo_phids) -+ ->setOrder('committed') -+ ->execute(); -+ } -+ -+ $header = id(new PHUIHeaderView()); -+ -+ if (!empty($repo)) { -+ $nb = count($repo); -+ $limit = 5; -+ $repo = array_slice($repo, 0, $limit); -+ $list = new PHUIObjectItemListView(); -+ foreach($repo as $r){ -+ $list->addItem( -+ id(new PHUIObjectItemView()) -+ ->setHeader($r->getName()) -+ ->addAttribute($r->getDisplayName()) -+ ->setHref($r->getURI())); -+ } -+ -+ $header_text = pht('Repositories (%s)', $nb); -+ -+ if($nb > $limit) { -+ $header->addActionLink( -+ id(new PHUIButtonView()) -+ ->setTag('a') -+ ->setIcon('fa-list-ul') -+ ->setText(pht('View All')) -+ ->setHref('/diffusion/?author=' . $user->getPHID() . '#R')); -+ } -+ -+ } else { -+ $header_text = pht('Repositories'); -+ $error = id(new PHUIBoxView()) -+ ->addClass('mlb') -+ ->appendChild(pht('User does not have any repository.')); -+ $list = id(new PHUIInfoView()) -+ ->setSeverity(PHUIInfoView::SEVERITY_NODATA) -+ ->appendChild($error); -+ } -+ -+ $header->setHeader($header_text); -+ -+ $box = id(new PHUIObjectBoxView()) -+ ->setHeader($header) -+ ->appendChild($list) -+ ->setBackground(PHUIObjectBoxView::GREY); -+ -+ return $box; -+ } -+ - private function buildCalendarDayView(PhabricatorUser $user) { - $viewer = $this->getViewer(); - $class = 'PhabricatorCalendarApplication'; diff --git a/roles/phabricator/files/wikirepo_project.patch b/roles/phabricator/files/wikirepo_project.patch deleted file mode 100644 index f95331f..0000000 --- a/roles/phabricator/files/wikirepo_project.patch +++ /dev/null @@ -1,154 +0,0 @@ ---- a/src/applications/project/controller/PhabricatorProjectProfileController.php -+++ b/src/applications/project/controller/PhabricatorProjectProfileController.php -@@ -52,6 +52,13 @@ - $watch_action = $this->renderWatchAction($project); - $header->addActionLink($watch_action); - -+ if($can_edit){ -+ $wiki_action = $this->renderWikiAction($project); -+ $header->addActionLink($wiki_action); -+ } -+ -+ $repo_list = $this->buildRepoList($project); -+ $wiki_list = $this->buildWikiList($project); - $milestone_list = $this->buildMilestoneList($project); - $subproject_list = $this->buildSubprojectList($project); - -@@ -99,6 +106,8 @@ - )) - ->setSideColumn( - array( -+ $repo_list, -+ $wiki_list, - $milestone_list, - $subproject_list, - $member_list, -@@ -197,6 +206,128 @@ - ->setDisabled($watch_disabled); - } - -+ private function renderWikiAction(PhabricatorProject $project) { -+ $viewer = $this->getViewer(); -+ $id = $project->getID(); -+ $viewer_phid = $viewer->getPHID(); -+ -+ $wiki_icon = 'fa-book'; -+ $wiki_text = pht('Create wiki page'); -+ $wiki_href = "/project/wiki/create/{$id}/?via=profile"; -+ -+ $wiki_icon = id(new PHUIIconView()) -+ ->setIcon($wiki_icon); -+ -+ return id(new PHUIButtonView()) -+ ->setTag('a') -+ ->setWorkflow(true) -+ ->setIcon($wiki_icon) -+ ->setText($wiki_text) -+ ->setHref($wiki_href); -+ } -+ -+ private function getHasWiki(PhabricatorProject $project) { -+ $viewer = $this->getViewer(); -+ $slug = PhabricatorProjectWikiCreate::getAllSlugs($project); -+ -+ return id(new PhrictionDocumentQuery()) -+ ->setViewer($viewer) -+ ->withStatus(PhrictionDocumentQuery::STATUS_OPEN) -+ ->withSlugPrefix($slug) -+ ->setLimit(1) -+ ->execute(); -+ } -+ -+ private function buildWikiList(PhabricatorProject $project) { -+ if (!$this->getHasWiki($project)) { -+ return null; -+ } -+ -+ $viewer = $this->getViewer(); -+ $id = $project->getID(); -+ $slug = PhabricatorProjectWikiCreate::getAllSlugs($project); -+ -+ $query = id(new PhrictionDocumentQuery()) -+ ->setViewer($viewer) -+ ->needContent(true) -+ ->withStatus(PhrictionDocumentQuery::STATUS_OPEN) -+ ->withSlugPrefix($slug) -+ ->setLimit(5) -+ ->execute(); -+ -+ $wiki_list = new PHUIObjectItemListView(); -+ foreach($query as $w){ -+ $wiki_list->addItem( -+ id(new PHUIObjectItemView()) -+ ->setHeader($w->getContent()->getTitle()) -+ ->addAttribute($w->getSlug()) -+ ->setHref($w->getSlugURI($w->getSlug()))); -+ } -+ -+ $view_all = id(new PHUIButtonView()) -+ ->setTag('a') -+ ->setIcon( -+ id(new PHUIIconView()) -+ ->setIcon('fa-list-ul')) -+ ->setText(pht('View All')) -+ ->setHref("/project/wiki/view/{$id}/"); -+ -+ $header = id(new PHUIHeaderView()) -+ ->setHeader(pht('Wiki pages')) -+ ->addActionLink($view_all); -+ -+ return id(new PHUIObjectBoxView()) -+ ->setHeader($header) -+ ->setBackground(PHUIObjectBoxView::GREY) -+ ->setObjectList($wiki_list); -+ } -+ -+ private function buildRepoList(PhabricatorProject $project) { -+ $viewer = $this->getViewer(); -+ $query = id(new PhabricatorRepositoryQuery()) -+ ->setViewer($viewer) -+ ->needProjectPHIDs(true) -+ ->withStatus(PhrictionDocumentQuery::STATUS_OPEN) -+ ->setOrder('committed') -+ ->execute(); -+ -+ $nb = 0; -+ $repo_list = new PHUIObjectItemListView(); -+ foreach($query as $r){ -+ if(in_array($project->getPHID(), $r->getProjectPHIDs()) && $nb < 5){ -+ $nb++; -+ $repo_list->addItem( -+ id(new PHUIObjectItemView()) -+ ->setHeader($r->getName()) -+ ->addAttribute($r->getDisplayName()) -+ ->setHref($r->getURI()) -+ ); -+ } -+ } -+ -+ if($nb == 0){ -+ return null; -+ } -+ -+ $view_all = id(new PHUIButtonView()) -+ ->setTag('a') -+ ->setIcon( -+ id(new PHUIIconView()) -+ ->setIcon('fa-list-ul')) -+ ->setText(pht('View All')) -+ ->setHref("/diffusion/?status=open&projectPHIDs=" . $project->getPHID() . '#R'); -+ -+ $header = id(new PHUIHeaderView()) -+ ->setHeader(pht('Repositories')) -+ ->addActionLink($view_all); -+ -+ return id(new PHUIObjectBoxView()) -+ ->setHeader($header) -+ ->setBackground(PHUIObjectBoxView::GREY) -+ ->setObjectList($repo_list); -+ } -+ -+ - private function buildMilestoneList(PhabricatorProject $project) { - if (!$project->getHasMilestones()) { - return null; diff --git a/roles/phabricator/tasks/customize.yml b/roles/phabricator/tasks/customize.yml index e6b1d06..84c3602 100644 --- a/roles/phabricator/tasks/customize.yml +++ b/roles/phabricator/tasks/customize.yml @@ -1,106 +1,46 @@ --- - name: Custom classes from Phutil copy: src: "{{ item }}" dest: "{{ phabricator_path }}libphutil/src/extensions/{{ item }}" notify: reload apache with_items: - PhutilAuthAdapterShibboleth.php -- name: Custom classes for Phabricator - copy: - src: "{{ item }}" - dest: "{{ phabricator_path }}phabricator/src/extensions/{{ item }}" - notify: reload apache - with_items: - # Custom - - PhabricatorAuthProviderShibboleth.php - - PhabricatorC4scienceApplication.php - - PhabricatorCustomRobotsController.php - - PhabricatorSitemapsController.php - # Policy for repository - - RepositoryAuthorPolicyRule.php - # Herald rule for commit size - - DiffusionPreCommitContentSizeHeraldField.php - # Wiki in project page - - PhabricatorProjectWikiCreate.php - - PhabricatorProjectWikiProfilePanel.php - - PhabricatorProjectWikiView.php - # Quickstart Dashboard Panel - - PhabricatorDashboardC4sciencePanelType.php - #- RevisionAuthorPolicyRule.php - #- RevisionReviewerPolicyRule.php - -#- name: Custom class for Phabricator using templates -# template: -# src: "{{ item }}" -# dest: "{{ phabricator_path }}phabricator/src/extensions/{{ item }}" -# notify: reload apache -# with_items: -# - HarbormasterJenkinsBuildStepImplementation.php - -- name: Patch Phabricator - patch: - src: "{{ item }}" - basedir: "{{ phabricator_path }}phabricator/" - strip: 1 - notify: reload apache - with_items: - - PhabricatorUserOmnipotent.patch - - harbormaster.patch - - subproject.patch - - delete_repo.patch - - remarkup_latex.patch - - remarkup_nowrap.patch - # Filter out shib group - - feed_hide_group.patch - # Default dashboard for logged in user - - home_public_dashboard.patch - # Local login as a button instead of form - - password_provider_button.patch - # Add wiki and repo list to Project - - wikirepo_people.patch - - wikirepo_project.patch - # Hide subproject and add repo link on project page - - project_panels.patch - - project_wiki_panel.patch - # Search repo by author - - repo_search_author.patch - - name: Update repo script template: src: phab_update_repo.sh dest: /root/scripts/phab_update_repo.sh mode: 0750 # LaTeX support - git: repo=https://github.com/ProfFan/render2katex.git dest=/opt/render2katex update=false # FIXME: handle updates in update-phab - git: repo=https://github.com/ProfFan/phabritex.git dest=/opt/phabritex update=false #FIXME: handle updates in update-phab - shell: "rsync -a /opt/phabritex/src/ {{ phabricator_path }}phabricator/src/" args: creates: "{{ phabricator_path }}phabricator/src/extensions/render2katex.php" notify: reload apache - replace: dest: "{{ phabricator_path }}phabricator/src/extensions/render2katex.php" regexp: '\/var\/www\/render2katex\/index\.js' replace: '/opt/render2katex/index.js' - replace: dest: "{{ phabricator_path }}phabricator/src/extensions/katexinline.php" regexp: '\/var\/www\/render2katex\/index\.js' replace: '/opt/render2katex/index.js' - shell: "rsync -a /opt/phabritex/webroot/ {{ phabricator_path }}phabricator/webroot/" args: creates: "{{ phabricator_path }}phabricator/webroot/rsrc/externals/font/katex" notify: rebuild celerity diff --git a/roles/phabricator/tasks/install.yml b/roles/phabricator/tasks/install.yml index 1b2484d..2ff42b4 100644 --- a/roles/phabricator/tasks/install.yml +++ b/roles/phabricator/tasks/install.yml @@ -1,88 +1,88 @@ --- ## Install Phabricator # Source: https://github.com/relrod/phabricator-ansible - name: Create log directory file: state=directory path=/var/log/phabricator owner="{{ phd_user }}" group="{{ phd_user }}" - name: Create directory - file: state=directory path=/srv/www owner="{{ phd_user }}" + file: state=directory path=/srv owner="{{ phd_user }}" - name: Create tmp directory file: state=directory path=/var/tmp/phd/ owner="{{ phd_user }}" - name: Clone phacility/libphutil git: - repo: https://github.com/phacility/libphutil + repo: https://secure.phabricator.com/source/libphutil.git dest: "{{ phabricator_path }}libphutil" version: "{{ phabricator_branch }}" update: false sudo_user: "{{ phd_user }}" - name: Clone phacility/arcanist git: - repo: https://github.com/phacility/arcanist.git + repo: https://secure.phabricator.com/diffusion/ARC/arcanist.git dest: "{{ phabricator_path }}arcanist" version: "{{ phabricator_branch }}" update: false sudo_user: "{{ phd_user }}" - name: Create symlink for arc file: path: /usr/local/bin/arc src: "{{ phabricator_path }}arcanist/bin/arc" state: link - name: Clone phacility/phabricator git: - repo: https://github.com/phacility/phabricator.git + repo: https://c4science.ch/source/phab.git dest: "{{ phabricator_path }}phabricator" version: "{{ phabricator_branch }}" update: false sudo_user: "{{ phd_user }}" - name: Remove local configuration if present file: path="{{ phabricator_path }}phabricator/conf/local/local.json" state=absent - name: Create a conf/custom directory. file: state=directory path={{ phabricator_path }}phabricator/conf/custom sudo_user: "{{ phd_user }}" - name: Place a starting-point custom config in {{ phabricator_path }}phabricator/conf/custom/myconfig.conf.php template: src: "{{ myconfig }}" dest: "{{ phabricator_path }}phabricator/conf/custom/myconfig.conf.php" mode: 0644 owner: root group: "{{ phd_user }}" notify: reload apache - name: Include the config shell: echo 'custom/myconfig' > {{ phabricator_path }}phabricator/conf/local/ENVIRONMENT args: creates: "{{ phabricator_path }}phabricator/conf/local/ENVIRONMENT" sudo_user: "{{ phd_user }}" - name: Migrate the database command: chdir={{ phabricator_path }}phabricator ./bin/storage upgrade --force sudo_user: "{{ phd_user }}" run_once: yes when: "'app' in group_names" - name: Redirect phabricator inbound email using transport lineinfile: dest: /etc/postfix/main.cf line: "transport_maps = hash:/etc/postfix/transport" - name: Redirect phabricator inbound email locally lineinfile: dest: /etc/postfix/transport line: "phabricator@{{ domain }} local:" notify: reload transport - name: Email with postfix lineinfile: dest: /etc/aliases line: "{{ phd_user }}: |{{ phabricator_path }}phabricator/scripts/mail/mail_handler.php" when: "'app' in group_names" diff --git a/tasks/update_phab.yml b/tasks/update_phab.yml index 5aa2c44..a823f83 100644 --- a/tasks/update_phab.yml +++ b/tasks/update_phab.yml @@ -1,90 +1,90 @@ --- - name: Fix permission on phab git repo hosts: app, phd tags: ['conf-app', 'conf-phd'] user: centos sudo: yes vars_files: - "{{ var }}" tasks: - shell: "chown -R {{ phd_user }}.{{ phd_user }} {{ phabricator_path }}" - name: Phabricator in read-only mode hosts: app, phd tags: ['conf-app', 'conf-phd'] run_once: true user: centos sudo: yes vars_files: - "{{ var }}" tasks: - shell: "{{ phabricator_path }}/phabricator/bin/config set cluster.read-only true" - name: Update phabricator on app instances hosts: app, phd tags: ['conf-app', 'conf-phd'] serial: 1 user: centos sudo: yes sudo_user: "{{ phd_user }}" vars_files: - "{{ var }}" tasks: - name: Set git config shell: "git config --global user.email info@{{ domain }}; git config --global user.name ansible" - name: Clone phacility/libphutil git: - repo: https://github.com/phacility/libphutil + repo: https://secure.phabricator.com/source/libphutil.git dest: "{{ phabricator_path }}libphutil" - version: stable + version: "{{ phabricator_branch }}" update: true - name: Clone phacility/arcanist git: - repo: https://github.com/phacility/arcanist.git + repo: https://secure.phabricator.com/diffusion/ARC/arcanist.git dest: "{{ phabricator_path }}arcanist" - version: stable + version: "{{ phabricator_branch }}" update: true - name: Clone phacility/phabricator git: - repo: https://github.com/phacility/phabricator.git + repo: https://c4science.ch/source/phab.git dest: "{{ phabricator_path }}phabricator" - version: stable + version: "{{ phabricator_branch }}" update: true - name: Migrate the database command: chdir={{ phabricator_path }}phabricator ./bin/storage upgrade --force when: "'{{ inventory_hostname }}' == '{{ groups.app[0] }}'" - name: Restart httpd daemons hosts: app tags: ['conf-app'] serial: 1 user: centos sudo: yes vars_files: - "{{ var }}" tasks: - service: name=httpd state=restarted - name: Restart phd daemons hosts: phd tags: ['conf-phd'] user: centos sudo: yes vars_files: - "{{ var }}" tasks: - service: name=phd state=restarted - name: Phabricator in normal mode hosts: app, phd tags: ['conf-app', 'conf-phd'] run_once: true user: centos sudo: yes vars_files: - "{{ var }}" tasks: - shell: "{{ phabricator_path }}/phabricator/bin/config set cluster.read-only false" diff --git a/vars/main.yml.example b/vars/main.yml.example index b8e08ca..72ed737 100644 --- a/vars/main.yml.example +++ b/vars/main.yml.example @@ -1,115 +1,115 @@ --- env: prod project_name: "c4science" ansible_ssh_user: "centos" proxy: no http_proxy: "" https_proxy: "" no_proxy: "localhost" proxy_url: "{{ http_proxy }}" __no_proxy: "{{ no_proxy }}" user_pwd_root: "" user_pwd_centos: "" # OpenStack keypair_name: "" image_id: "" image_id_coreos: "" public_net: "" private_net: "" flavor_id_small: "" flavor_id_medium: "" flavor_id_large: "" flavor_id_small_backup: "" private_net_backup: "" image_id_backup: "" region_main: "" region_back: "" # Storage s3_access_key: "" s3_secret_key: "" s3_endpoint: "" s3_bucket: "" s3_region: "" # Lbs internal_ip: 0.0.0.0 external_ip: 0.0.0.0 backup_ip: 0.0.0.0 ip_range: "10.0.0.0/16" jenkins_port: 8080 stats_port: 8082 monit_port: 8081 monit_user: admin monit_pass: rolling_reboot_proxy_host: "{{ external_ip }}" rolling_reboot_pause: 30 rolling_reboot_wait_delay: 20 # App developer_mode: false http_scheme: 'http://' domain: example.com file_domain: "{{ http_scheme }}static.{{ domain }}/" phabricator_branch: stable -phabricator_path: /srv/www/facebook/ +phabricator_path: /srv/ repositories_path: /var/repo/ phd_user: phabricator www_user: apache vcs_user: git vcs_port_front: 22 vcs_port_back: 2222 jenkins_admin_user: admin jenkins_admin_password: jenkins_phab_url: "{{ http_scheme }}{{ domain }}/" jenkins_phab_id: "PHID-" jenkins_phab_secret: "" jenkins_prefix: "/" jenkins_url: "{{ http_scheme }}jenkins.{{ domain }}{{ jenkins_prefix }}" shib_metadata_file: "metadata.xml" shib_metadata_provider: "http://example.com/{{ shib_metadata_file }}" phabricator_domains: - "{{ domain }}" - 'example.com' google_webmaster_file: "googleXYZ.html" # Dbs mysql_repl_user: "repl" mysql_repl_pass: "" mysql_app_user: "" mysql_app_pass: "" mysql_shib_user: "" mysql_shib_pass: "" mysql_shib_db: "shibboleth" mysql_lbs_user: "haproxy" mysql_cluster_name: "" mysql_host: "10.0.0.0/255.255.0.0" # SSH ssh_keys: - "ssh-rsa mysuperkey1" - "ssh-rsa mysuperkey2" # Swap swap_path: "/swapfile" dd_bs_size_mb: 32 swap_count: 128 swappiness: 10 vfs_cache_pressure: 50 # Email configure_postfix: true enable_postfix_domain_rewrite: true enable_postfix_relayhost: true postfix_relayhost: "[{{ internal_ip }}]" postfix_rewrite_domain: "{{ domain }}" email_alias_phabricator: "" email_alias_postmaster: "" email_alias_admin: "" email_monitoring: ""