<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: GotPhoto</title>
    <description>The latest articles on DEV Community by GotPhoto (@gotphoto).</description>
    <link>https://dev.to/gotphoto</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F4699%2Ff97575ef-5881-4ba2-b274-06e9a7f257cd.jpg</url>
      <title>DEV Community: GotPhoto</title>
      <link>https://dev.to/gotphoto</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gotphoto"/>
    <language>en</language>
    <item>
      <title>Unleash test pipelines in your delivery workflow(s) </title>
      <dc:creator>Chris E.</dc:creator>
      <pubDate>Mon, 20 Sep 2021 13:18:10 +0000</pubDate>
      <link>https://dev.to/gotphoto/unleash-test-pipelines-in-your-delivery-workflow-s-4cji</link>
      <guid>https://dev.to/gotphoto/unleash-test-pipelines-in-your-delivery-workflow-s-4cji</guid>
      <description>&lt;h2&gt;
  
  
  If you run a separate repository for your test projects or you have tests or other projects unrelated to your main app in your code base or you simply just want to know some more on how to setup a test pipeline for your projects on Gitlab or any related CD platform. We’ve put together this article for you; a view study of how we do it at GotPhoto**
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Often than not you’d have any of the cases above where you’d want a&lt;br&gt;
modular test suite that’s accessible from different teams across your&lt;br&gt;
CI tool. In this article, I’ll go through some familiar steps that&lt;br&gt;
goes beyond having test schedules and pipeline jobs; being two of the&lt;br&gt;
most common ways to test in a deployment process.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;I’ll be using Gitlab as a main example but the approach here goes along with pretty much any .yml supported workflow and any version control system, in a web, javascript, cloud based setup.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s start by setting goals&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Enable access to tests from a requesting project to a source project&lt;/li&gt;
&lt;li&gt; Report all test status via Slack&lt;/li&gt;
&lt;li&gt; Report visual test results&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We’ll focus on the first 2 goals here and finish the 3rd in another “ticket”.&lt;/p&gt;

&lt;h2&gt;
  
  
  Goal 1: Enable access to tests from a requesting project to a source project
&lt;/h2&gt;

&lt;p&gt;Let’s assume your have 2 teams, primarily your source and target teams and Team “Testars” manage your test code while Team “Pigeons” manage other application code.&lt;/p&gt;

&lt;p&gt;In Team  “Testars”: ideally your tests can be triggered via commands which may or not contain required values in your pipeline environment to execute. Your workflow may be similar to: Test code is available on a folder in your project, your project contains necessary packages to install and run all tests and its dependencies in your CI, your test are triggered with commands and result is a status output in your deployment tree.&lt;/p&gt;

&lt;p&gt;Now let’s bring in the Team “Pigeons”, with a different code base in your VCS, you can leverage the multi-project pipeline trigger. The idea is pretty simple, Pigeons implement a delivery workflow that includes a test stage, this then invokes tests in your Team Testars project and makes results available to Team Pigeon.&lt;/p&gt;

&lt;p&gt;Here’s an illustration of what your project may look like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;pigeonsPipeline.yml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="na"&gt;variables&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="na"&gt;ENVIRONMENT&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;staging&lt;/span&gt;
&lt;span class="na"&gt;REQUESTING_TEAM&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pigeons&lt;/span&gt;
&lt;span class="na"&gt;TEST_COMMAND&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx...&lt;/span&gt;
&lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
&lt;span class="na"&gt;trigger&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;test_project_repository_here&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;testarsPipeline.yml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;.job_template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
&lt;span class="na"&gt;only&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="na"&gt;refs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;master&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;pipelines&lt;/span&gt;
&lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;$(npm bin)/${TEST_COMMAND}&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;bash ./notify.sh "$ENVIRONMENT" "$REQUESTING_TEAM" "$TEST_COMMAND"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few things to note here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;testarsPipeline&lt;/strong&gt;  requires a custom command, this allows you truly open up your tests as different teams may have different commands depending on their workflow&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;testarsPipeline&lt;/strong&gt;  also opens up test trigger sources to the  &lt;strong&gt;“pipelines”&lt;/strong&gt; tag. This ensures the test pipeline runs when triggered via a pipeline process.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;pigeonsPipeline&lt;/strong&gt;  is invoking tests by providing environment variable in the stage which is passed on to the triggered test project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And there you have it, Bob’s your uncle? Not yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Goal 2: Report all test status via Slack
&lt;/h2&gt;

&lt;p&gt;Test triggers in this workflow will eventually have a wider range of subscribers, this is good but you’d want to keep an eye on the activity, especially when working in a cross functional team. Slack allows you setup incoming webhooks for purposes like this. You can add a step to your test pipeline that sends a message to a predefined Slack channel, letting you and your team know when a test pipeline has been triggered, by who and whatever else information you gather and require on the go.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lets write it…&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Setup a Slack app and provision its support for incoming webhooks&lt;/li&gt;
&lt;li&gt; Create a Slack channel to report to&lt;/li&gt;
&lt;li&gt; Create a webhook for your Slack channel&lt;/li&gt;
&lt;li&gt; Write a bash script to send your notifications&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To setup a Slack app, the steps are quite straight forward using the Slack API UI on  &lt;a href="https://api.slack.com/messaging/webhooks"&gt;Slack API Documentation&lt;/a&gt;  and same case for setting up a new Slack Channel or you may want to reuse an existing one. Creating an incoming webhook can also be done via the Slack API and all you’d need is your Webhook URL address, this looks something like&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"&gt;https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you’ll need to setup a bash script to fulfil the last line of your  &lt;strong&gt;testarsPipeline&lt;/strong&gt; file. Remember we now have access to 3 environment variables provided via Pigeons, this will be passed to a custom shell script via the  &lt;strong&gt;testarsPipeline&lt;/strong&gt;, then we’d make a simple or formatted payload containing your variables and any other data you’ve added and finally make a curl request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;notify.sh&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;SLACK_PAY_LOAD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"
{
    'text': '&lt;/span&gt;&lt;span class="nv"&gt;$REQUESTING_TEAM&lt;/span&gt;&lt;span class="s2"&gt; triggered &lt;/span&gt;&lt;span class="nv"&gt;$TEST_COMMAND&lt;/span&gt;&lt;span class="s2"&gt; on &lt;/span&gt;&lt;span class="nv"&gt;$ENVIRONMENT&lt;/span&gt;&lt;span class="s2"&gt; environment'
}
"&lt;/span&gt;
curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s1"&gt;'Content-type: application/json'&lt;/span&gt; &lt;span class="nt"&gt;--data&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;SLACK_PAY_LOAD&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few things to note in the notify.sh file:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; To access your variables, you’d need to use single quotes, there might be cases where this breaks your payload if you have quotes in your variables. I recommend concatenation here.&lt;/li&gt;
&lt;li&gt; You should consider masking your payload URL as well as other improvements you find useful.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Have an idea on what to do with step 3? We are consideering building an API enabled dashboard using the Cypress test events.
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;If you found this interesting, you'd love working with us at GotPhoto&lt;br&gt;
where you have the opportunity to build with an amazing team. Consider&lt;br&gt;
joining us at &lt;a href="https://fotograf.de/"&gt;GotPhoto&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>testing</category>
      <category>delivery</category>
      <category>pipelines</category>
    </item>
    <item>
      <title>How to create a new SSH key</title>
      <dc:creator>Marco B.</dc:creator>
      <pubDate>Fri, 10 Sep 2021 09:19:51 +0000</pubDate>
      <link>https://dev.to/gotphoto/how-to-create-a-new-ssh-key-d9a</link>
      <guid>https://dev.to/gotphoto/how-to-create-a-new-ssh-key-d9a</guid>
      <description>&lt;p&gt;As a software developer it is common to connect to various services via SSH. Be it a remote SQL database or Git or a web server, we mostly use SSH to connect to the server.&lt;/p&gt;

&lt;p&gt;Password authentication is not up to date anymore and short SSH RSA keys do not provide the expected security.&lt;/p&gt;

&lt;p&gt;Good that there is ed25519 :)&lt;/p&gt;

&lt;p&gt;You can generate a key with the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen -t ed25519 -C "mail@example.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll be asked where to save the key. The default location is &lt;code&gt;~/.ssh/id_ed25519.pub&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then you can copy your public key to the server. To show it use following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat ~/.ssh/id_ed25519.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ssh</category>
      <category>key</category>
      <category>ed25519</category>
    </item>
  </channel>
</rss>
