简体   繁体   English

良好的Phing工作流程是什么样的?

[英]What does a good Phing workflow look like?

I'm trying to get into the mindset of CI and have been playing with Phing this weekend. 我正试图进入CI的心态,本周末一直在和Phing一起玩。 It all seems straight forward enough to use and have many examples going already. 这一切看起来都很直接,并且已经有很多例子。

However something that still puzzles me is how people actually use it. 然而,令我困惑的是人们如何实际使用它。 That is, I'm not looking for what tests you do, but instead a suggested work flow using Phing, at what stage do you activate it, at what stage in the development cycle is it actioned. 也就是说,我不是在寻找你做的测试,而是使用Phing建议的工作流程,在什么阶段你激活它,在开发周期的哪个阶段采取行动。

For example, we have several websites, currently we edit the source locally and on save upload to the live site (I know how bad this is...), we do some quick testing and make sure the code works as planned. 例如,我们有几个网站,目前我们在本地编辑源代码并保存上传到实际网站(我知道这有多糟糕......),我们做了一些快速测试并确保代码按计划运行。 If so we commit to the repos and carry on. 如果是这样,我们承诺回购并继续进行。 If not, we can roll back or edit undo and resave. 如果没有,我们可以回滚或编辑撤消和重新保存。 Whilst this now seems crazy the simplicity has worked well for us. 虽然这看起来很疯狂,但简单性对我们来说效果很好。

We now have a small team however, so I'm trying to push Phing into this process, to get all the added benefits of the linting/sniffing/mess detecting etc however I can't figure the best order of events. 我们现在有一个小团队,所以我试图将Phing推入这个过程,以获得linting / sniffing / mess检测等所有额外的好处,但是我无法确定事件的最佳顺序。

Would you suggest : 你会建议:

  • Edit the code locally. 在本地编辑代码。
  • On save upload the file to a test site. 在保存时将文件上载到测试站点。
  • Test the site on the staging server. 在登台服务器上测试站点。
  • All being well, commit the changes to the repos. 一切顺利,将更改提交到回购。 Then run phing. 然后运行phing。
  • Assess output of Phing, updating code as necessary, re-save, re-commit, re-run phing. 评估Phing的输出,根据需要更新代码,重新保存,重新提交,重新运行phing。
  • Assuming Phing passes, as I'm running phing on another server, do a svn export and start the deployment process. 假设Phing通过,当我在另一台服务器上运行phing时,执行svn导出并启动部署过程。

The above seems a bit long winded to me. 以上似乎有点长啰嗦。 Is it because it looks like I'm trying to merge a test deployment with a live deployment that's confusing me? 是不是因为看起来我试图将测试部署与实时部署合并,让我感到困惑?

Also it would seem a bit backwards to commit, then run Phing, then have to edit and possibly re-commit before trying again. 此外,它似乎有点倒退,然后运行Phing,然后必须编辑并可能重新提交再次尝试之前。

Hence would it make more sense to : 因此,它会更有意义:

  • Edit the code locally. 在本地编辑代码。
  • Save, action a test deployment build with Phing. 保存,使用Phing执行测试部署构建。
  • Make sure the code has passed all the code checks etc 确保代码已通过所有代码检查等
  • Using Phing make sure code is copied to the staging server. 使用Phing确保将代码复制到登台服务器。
  • Test the site on the staging server. 在登台服务器上测试站点。
  • All being well, commit the changes to the repos. 一切顺利,将更改提交到回购。
  • Then live deployment build with Phing. 然后用Phing进行实时部署。

The problem with the above is, let's say I just wanted to correct the spelling of a word hard-coded into an HTML page, seems overkill? 上面的问题是,假设我只是想纠正硬编码到HTML页面的单词的拼写,看起来有点过分了吗?

Finally, how do people set up their servers, do you have one server for the live site, one for the staging, and one to host Phing (and any CI software on)? 最后,人们如何设置他们的服务器,你有一个服务器用于实时站点,一个用于登台,还有一个用于托管Phing(以及任何CI软件)?

The point of tools like Phing is automation. 像Phing这样的工具就是自动化。 So, to answer this "what stage do you activate it, at what stage in the development cycle is it actioned", I would say you should bring it in as soon as you feel you will gain a benefit from using it. 因此,要回答这个“什么阶段,你激活它,在它是什么付诸行动阶段,在开发周期”,我会说你应该只要你觉得你会使用它获得的利益带来进去。

For example, if you have a process which takes multiple commands to complete, there would be a benefit of using Phing (or even just a shell script) to automate the steps, especially if there's more than one person who needs to do it or it's especially error-prone. 例如,如果您有一个需要完成多个命令的进程,那么使用Phing(甚至只是一个shell脚本)来自动执行这些步骤会有好处,特别是如果有多个人需要这样做或者它是特别容易出错。

So going with that, you should use phing to make your life easier, not harder. 因此,你应该使用phing来让你的生活更轻松,而不是更难。 Any task which involves more than one shell command, or always involves typing the same command with lots of hard to remember parameters, is usually something you could/should use phing to automate. 任何涉及多个shell命令的任务,或者总是涉及键入具有大量难以记忆的参数的相同命令,通常是您可以/应该使用phing来自动化的。

Considering the first list of steps you mention, it is indeed a bit longwinded. 考虑到你提到的第一个步骤列表,它确实有点长。 Instead, you should use phing earlier, to automate the steps: 相反,您应该提前使用phing来自动执行这些步骤:

  • If you have automated tests, use phing to run them 如果您有自动测试,请使用phing来运行它们
  • Commit to source control 致力于源代码控制
  • Use phing to deploy the code 使用phing来部署代码
  • Use phing to do the svn export or any other manual steps 使用phing进行svn导出或任何其他手动步骤

So basically I would do pretty much what you suggested in your second list. 所以基本上我会做你在第二个列表中建议的内容。

You probably should make phing commands for the separate steps, and make phing commands for running commonly run together commands in one shot (eg. tests and then deploy). 您可能应该为单独的步骤制作phing命令,并使用于运行的phing命令通常一次性运行命令(例如,测试然后部署)。

This would allow you to skip phases if you feel it's necessary, such as in the example you gave about changing just some text. 如果您认为有必要,这将允许您跳过阶段,例如在您给出的关于仅更改一些文本的示例中。

A typical approach to servers is having the live site on its own server, and then having the staging/testing server mirror it as closely as possible. 服务器的典型方法是在自己的服务器上安装实时站点,然后让登台/测试服务器尽可能地镜像它。 For CI or other utilities, you can usually host them on the staging server, proven they do not interfere with the main application you are developing. 对于CI或其他实用程序,您通常可以在登台服务器上托管它们,证明它们不会干扰您正在开发的主应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM