evennia/docs/1.0-dev/Coding/Continuous-Integration-TeamCity.html
Evennia docbuilder action 3165f49b4c Updated HTML docs
2022-02-06 18:34:09 +00:00

326 lines
No EOL
21 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Continuous Integration - TeamCity (linux) &#8212; Evennia 1.0-dev documentation</title>
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Setting up PyCharm with Evennia" href="Setting-up-PyCharm.html" />
<link rel="prev" title="Continuous integration with Travis" href="Continuous-Integration-Travis.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="Setting-up-PyCharm.html" title="Setting up PyCharm with Evennia"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Continuous-Integration-Travis.html" title="Continuous integration with Travis"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" >Coding and development help</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="Continuous-Integration.html" accesskey="U">Continuous Integration</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Continuous Integration - TeamCity (linux)</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="continuous-integration-teamcity-linux">
<h1>Continuous Integration - TeamCity (linux)<a class="headerlink" href="#continuous-integration-teamcity-linux" title="Permalink to this headline"></a></h1>
<p>This sets up a TeamCity build integration environment on Linux.</p>
<section id="prerequisites">
<h2>Prerequisites<a class="headerlink" href="#prerequisites" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Follow <a class="reference external" href="https://www.jetbrains.com/teamcity/">TeamCity</a> s in-depth
<a class="reference external" href="https://confluence.jetbrains.com/display/TCD8/Installing+and+Configuring+the+TeamCity+Server">Setup Guide</a>.</p></li>
<li><p>You need to use <a class="reference internal" href="Version-Control.html"><span class="doc std std-doc">Version Control</span></a>.</p></li>
</ul>
<p>After meeting the preparation steps for your specific environment, log on to your teamcity interface
at <code class="docutils literal notranslate"><span class="pre">http://&lt;your</span> <span class="pre">server&gt;:8111/</span></code>.</p>
<p>Create a new project named “Evennia” and in it construct a new template called <code class="docutils literal notranslate"><span class="pre">continuous-integration</span></code>.</p>
</section>
<section id="a-quick-overview">
<h2>A Quick Overview<a class="headerlink" href="#a-quick-overview" title="Permalink to this headline"></a></h2>
<p><em>Templates</em> are fancy objects in TeamCity that allow an administrator to define build steps that are
shared between one or more build projects. Assigning a VCS Root (Source Control) is unnecessary at
this stage, primarily youll be worrying about the build steps and your default parameters (both
visible on the tabs to the left.)</p>
</section>
<section id="template-setup">
<h2>Template Setup<a class="headerlink" href="#template-setup" title="Permalink to this headline"></a></h2>
<p>In this template, youll be outlining the steps necessary to build your specific game. (A number of
sample scripts are provided under this section below!) Click Build Steps and prepare your general
flow. For this example, we will be doing a few basic example steps:</p>
<ul class="simple">
<li><p>Transforming the <a class="reference external" href="http://Settings.py">Settings.py</a> file - We do this to update ports or other information that make your production
environment unique from your development environment.</p></li>
<li><p>Making migrations and migrating the game database.</p></li>
<li><p>Publishing the game files.</p></li>
<li><p>Reloading the server.</p></li>
</ul>
<p>For each step well being use the “Command Line Runner” (a fancy name for a shell script executor).</p>
<p>Create a build step with the name: “Transform Configuration” and add the script:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
<span class="c1"># Replaces the game configuration with one </span>
<span class="c1"># appropriate for this deployment.</span>
<span class="nv">CONFIG</span><span class="o">=</span><span class="s2">&quot;%system.teamcity.build.checkoutDir%/server/conf/settings.py&quot;</span>
<span class="nv">MYCONF</span><span class="o">=</span><span class="s2">&quot;%system.teamcity.build.checkoutDir%/server/conf/my.cnf&quot;</span>
sed -e <span class="s1">&#39;s/TELNET_PORTS = [4000]/TELNET_PORTS = [%game.ports%]/g&#39;</span> <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span> &gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>.tmp <span class="o">&amp;&amp;</span> mv
<span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>.tmp <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
sed -e <span class="s1">&#39;s/WEBSERVER_PORTS = [(4001, 4002)]/WEBSERVER_PORTS = [%game.webports%]/g&#39;</span> <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span> &gt;
<span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>.tmp <span class="o">&amp;&amp;</span> mv <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>.tmp <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
</pre></div>
</div>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># settings.py MySQL DB configuration</span>
<span class="nb">echo</span> Configuring Game Database...
<span class="nb">echo</span> <span class="s2">&quot;&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;######################################################################&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;# MySQL Database Configuration&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;######################################################################&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;DATABASES = {&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot; &#39;default&#39;: {&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot; &#39;ENGINE&#39;: &#39;django.db.backends.mysql&#39;,&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot; &#39;OPTIONS&#39;: {&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot; &#39;read_default_file&#39;: &#39;server/conf/my.cnf&#39;,&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot; },&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot; }&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;}&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$CONFIG</span><span class="s2">&quot;</span>
<span class="c1"># Create the My.CNF file.</span>
<span class="nb">echo</span> <span class="s2">&quot;[client]&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$MYCONF</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;database = %mysql.db%&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$MYCONF</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;user = %mysql.user%&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$MYCONF</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;password = %mysql.pass%&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$MYCONF</span><span class="s2">&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;default-character-set = utf8&quot;</span> &gt;&gt; <span class="s2">&quot;</span><span class="nv">$MYCONF</span><span class="s2">&quot;</span>
</pre></div>
</div>
<p>If you look at the parameters side of the page after saving this script, youll notice that some new
parameters have been populated for you. This is because weve included new teamcity configuration
parameters that are populated when the build itself is ran. When creating projects that inherit this
template, well be able to fill in or override those parameters for project-specific configuration.</p>
<p>Go ahead and create another build step called “Make Database Migration”
If youre using Sqlite3 for your game (default database), its prudent to change working directory on this
step to your game dir.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
<span class="c1"># Update the DB migration</span>
<span class="nv">LOGDIR</span><span class="o">=</span><span class="s2">&quot;server/logs&quot;</span>
. %evenv.dir%/bin/activate
<span class="c1"># Check that the logs directory exists.</span>
<span class="k">if</span> <span class="o">[</span> ! -d <span class="s2">&quot;</span><span class="nv">$LOGDIR</span><span class="s2">&quot;</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
<span class="c1"># Control will enter here if $LOGDIR doesn&#39;t exist.</span>
mkdir <span class="s2">&quot;</span><span class="nv">$LOGDIR</span><span class="s2">&quot;</span>
<span class="k">fi</span>
evennia makemigrations
</pre></div>
</div>
<p>Create yet another build step, this time named: “Execute Database Migration”:
If youre using Sqlite3 for your game (default database), its prudent to change working directory on this
step to your game dir.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
<span class="c1"># Apply the database migration.</span>
<span class="nv">LOGDIR</span><span class="o">=</span><span class="s2">&quot;server/logs&quot;</span>
. %evenv.dir%/bin/activate
<span class="c1"># Check that the logs directory exists.</span>
<span class="k">if</span> <span class="o">[</span> ! -d <span class="s2">&quot;</span><span class="nv">$LOGDIR</span><span class="s2">&quot;</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
<span class="c1"># Control will enter here if $LOGDIR doesn&#39;t exist.</span>
mkdir <span class="s2">&quot;</span><span class="nv">$LOGDIR</span><span class="s2">&quot;</span>
<span class="k">fi</span>
evennia migrate
</pre></div>
</div>
<p>Our next build step is where we actually publish our build. Up until now, all work on game has been
done in a work directory on TeamCitys build agent. From that directory we will now copy our files
to where our game actually exists on the local server.</p>
<p>Create a new build step called “Publish Build”. If youre using SQlite3 on your game, be sure to order this step ABOVE
the Database Migration steps. The build order will matter!</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
<span class="c1"># Publishes the build to the proper build directory.</span>
<span class="nv">DIRECTORY</span><span class="o">=</span><span class="s2">&quot;&lt;game_dir&gt;&quot;</span>
<span class="k">if</span> <span class="o">[</span> ! -d <span class="s2">&quot;</span><span class="nv">$DIRECTORY</span><span class="s2">&quot;</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
<span class="c1"># Control will enter here if $DIRECTORY doesn&#39;t exist.</span>
mkdir <span class="s2">&quot;</span><span class="nv">$DIRECTORY</span><span class="s2">&quot;</span>
<span class="k">fi</span>
<span class="c1"># Copy all the files.</span>
cp -ruv %teamcity.build.checkoutDir%/* <span class="s2">&quot;</span><span class="nv">$DIRECTORY</span><span class="s2">&quot;</span>
chmod -R <span class="m">775</span> <span class="s2">&quot;</span><span class="nv">$DIRECTORY</span><span class="s2">&quot;</span>
</pre></div>
</div>
<p>Finally the last script will reload our game for us.</p>
<p>Create a new script called “Reload Game”:
The working directory on this build step will be: <code class="docutils literal notranslate"><span class="pre">%game.dir%</span></code></p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
<span class="c1"># Apply the database migration.</span>
<span class="nv">LOGDIR</span><span class="o">=</span><span class="s2">&quot;server/logs&quot;</span>
<span class="nv">PIDDIR</span><span class="o">=</span><span class="s2">&quot;server/server.pid&quot;</span>
. %evenv.dir%/bin/activate
<span class="c1"># Check that the logs directory exists.</span>
<span class="k">if</span> <span class="o">[</span> ! -d <span class="s2">&quot;</span><span class="nv">$LOGDIR</span><span class="s2">&quot;</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
<span class="c1"># Control will enter here if $LOGDIR doesn&#39;t exist.</span>
mkdir <span class="s2">&quot;</span><span class="nv">$LOGDIR</span><span class="s2">&quot;</span>
<span class="k">fi</span>
<span class="c1"># Check that the server is running.</span>
<span class="k">if</span> <span class="o">[</span> -d <span class="s2">&quot;</span><span class="nv">$PIDDIR</span><span class="s2">&quot;</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
<span class="c1"># Control will enter here if the game is running.</span>
evennia reload
<span class="k">fi</span>
</pre></div>
</div>
<p>Now the template is ready for use! It would be useful this time to revisit the parameters page and
set the evenv parameter to the directory where your virtualenv exists: IE “/srv/mush/evenv”.</p>
<section id="creating-the-project">
<h3>Creating the Project<a class="headerlink" href="#creating-the-project" title="Permalink to this headline"></a></h3>
<p>Now its time for the last few steps to set up a CI environment.</p>
<ul class="simple">
<li><p>Return to the Evennia Project overview/administration page.</p></li>
<li><p>Create a new Sub-Project called “Production”. This will be the category that holds our actual game.</p></li>
<li><p>Create a new Build Configuration in Production with the name of your MUSH. Base this configuration off of the
continuous-integration template we made earlier.</p></li>
<li><p>In the build configuration, enter VCS roots and create a new VCS root that points to the
branch/version control that you are using.</p></li>
<li><p>Go to the parameters page and fill in the undefined parameters for your specific configuration.</p></li>
<li><p>If you wish for the CI to run every time a commit is made, go to the VCS triggers and add one for
“On Every Commit”.</p></li>
</ul>
<p>And youre done! At this point, you can return to the project overview page and queue a new build
for your game. If everything was set up correctly, the build will complete successfully. Additional
build steps could be added or removed at this point, adding some features like Unit Testing or more!</p>
</section>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
</a></p>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
<p><h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Continuous Integration - TeamCity (linux)</a><ul>
<li><a class="reference internal" href="#prerequisites">Prerequisites</a></li>
<li><a class="reference internal" href="#a-quick-overview">A Quick Overview</a></li>
<li><a class="reference internal" href="#template-setup">Template Setup</a><ul>
<li><a class="reference internal" href="#creating-the-project">Creating the Project</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Continuous-Integration-Travis.html"
title="previous chapter">Continuous integration with Travis</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Setting-up-PyCharm.html"
title="next chapter">Setting up PyCharm with Evennia</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Coding/Continuous-Integration-TeamCity.md.txt"
rel="nofollow">Show Page Source</a></li>
</ul>
</div><h3>Links</h3>
<ul>
<li><a href="https://www.evennia.com">Home page</a> </li>
<li><a href="https://github.com/evennia/evennia">Evennia Github</a> </li>
<li><a href="http://games.evennia.com">Game Index</a> </li>
<li>
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
<a href="https://evennia.blogspot.com/">Blog</a>
</li>
</ul>
<h3>Versions</h3>
<ul>
<li><a href="Continuous-Integration-TeamCity.html">1.0-dev (develop branch)</a></li>
<li><a href="../../0.9.5/index.html">0.9.5 (v0.9.5 branch)</a></li>
</ul>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="Setting-up-PyCharm.html" title="Setting up PyCharm with Evennia"
>next</a> |</li>
<li class="right" >
<a href="Continuous-Integration-Travis.html" title="Continuous integration with Travis"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" >Coding and development help</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="Continuous-Integration.html" >Continuous Integration</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Continuous Integration - TeamCity (linux)</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>