Giter Club home page Giter Club logo

templatecontrol's Introduction

TemplateControl

This is an internal script to update the Play managed example templates, to automate version management.

For the given templates in application.conf, it will:

  • Clone the given template
  • Create a new branch based off upstream version (i.e. upstream/2.6.x)
  • Search and replace text to ensure that the relevant Play settings are correct, i.e. sbt-plugin, scalaVersion, sbt version, libraries etc.
  • Git add and push the branch, and create a pull request against the upstream repo.

Because this is new, it is still up to a human to identify the pull request as passing the build hooks and merging it against the template.

Prerequisites

Hub

You need to have hub installed, see https://hub.github.com/.

Project forks

You need to have forks for each of the repositories in your personal GitHub account.

For that you can use the scripts scripts/create-forks-play.sh and scripts/create-forks-lagom.sh.

See scripts/README.md for more details.

Personal Access Token

You will need to configure Github with a personal access token to get this working, because it does push branches into your personal fork of the templates in order to create the pull request.

You want a personal access token with "repo" scope.

https://help.github.com/articles/creating-an-access-token-for-command-line-use/

Then you need to create a script with your settings:

export TCONTROL_GITHUB_REMOTE=wsargent
export TCONTROL_GITHUB_USER=wsargent
export TCONTROL_GITHUB_OAUTH=<personal access token>

Public Key for SSL access

Template control will use https when interacting with the upstream repos and git protocol when interacting with your own forks. When using git protocol it relies on your public ssh key as expected, but for unknown reasons, this will only work if your pub key was not generated with a passphrase.

WebHook

As part of the whole process, the program will check the existence of a webhook to publish content in Lightbend TechHub. This will fail if you are not an owner on Playframework organisation in GitHub.

Running

Once you've got the credentials, you can run it:

sbt run

or

sbt run --no-push

You will be presented if a few options to choose from. Choose the main method you would like to run:

Multiple main classes detected, select one to run:

 [1] templatecontrol.RunPlay
 [2] templatecontrol.RunPlay26
 [3] templatecontrol.RunPlay27

Enter number:

When using flag --no-push, no branch will be pushed and no PRs will be created on GitHub. You can then inspect the modified projects.

Skipping lines

If you need to skip a line, you can add a tc-skip comment on the line you don't want to be replaced. For example, in case you have a giter8 template with variables, you may want to leave them untouched.

The following line contains a giter8 variable, $play_version$,...

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "$play_version$")

this will be replaced by

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.19")

and that breaks the giter8 template.

If the line contains a tc-skip, it won't be touched, for example:

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "$play_version$") // tc-skip

License

This software is licensed under the Apache 2 license, quoted below.

Copyright (C) 2016 Lightbend Inc. (https://www.lightbend.com).

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

templatecontrol's People

Contributors

wsargent avatar dwijnand avatar octonato avatar marcospereira avatar gmethvin avatar ignasi35 avatar mergify[bot] avatar

Stargazers

Seth Tisue avatar  avatar PB avatar

Watchers

Jonas Bonér avatar  avatar Michael Nash avatar ebaker avatar Matthias Kurz avatar  avatar Derek Henninger avatar James Cloos avatar Gerard Maas avatar Paul Craddick avatar Hugh McKee avatar Richard Summerhayes avatar Alan Ngai avatar David Brinegar avatar Duncan DeVore avatar  avatar Srikanth Koneru avatar Kenan Zuabi avatar  avatar Danny Wei avatar Karl Wehden avatar PB avatar  avatar

templatecontrol's Issues

Investigate solution for g8

Template control is to intrusive with g8 templates. It removes the g8 variables.

We should investigate the possibility to exclude some replacements for g8 templates.

Add insert lines function

Right now, templatecontrol can replace existing lines, but cannot insert new lines.

This is a prerequisite to batching changes overall.

Add the playframework.com repo

Having updated the playframework.com repo, we should put this under templatecontrol.

Blockers:

  • no LICENSE file: playframework.com isn't distributed software, so it's not licensed, and it's definitely not CC0 licensed
  • different .travis.yml: also because it's not distributed software, there's no testing of it on AdoptOpenJDK 11 and Gradle

WebHook should be optional

The program is checking if TechHub webhook is present and if not it adds it.

This has a few drawbacks:

  1. not all projects should have a webhook, for instance, the play-webgoat should not be in TechHub. It makes no sense.
  2. to check and add webhooks, we must be an owner of playframework org. Not an big issue, but it's unnecessary. It your not an owner, you can't use templatecontrol.

My take on the webhook is that it's very useful to check, but I'm on the fence about the idea to add it automatically.

I think this check should not make part of a whole process and should not block us to update the template. Ideally, we should have to tasks that are run on demand only.

  1. checkWebhook - only checks if they are in place
  2. addWebhook - add if absent and don't fail the process on individual failure. It must just keep going.

Customized templates

All templates should have customized READMEs that detail what they do and how they work, rather than the generic welcome page. This can be reworked from the README or tutorial/index.html page.

Add PR validation

We should start to validate templatecontrol PRs before merging them and add it as a condition to .mergify.yml.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.