<?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: jkorichneva</title>
    <description>The latest articles on DEV Community by jkorichneva (@jkorichneva).</description>
    <link>https://dev.to/jkorichneva</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%2Fuser%2Fprofile_image%2F1069259%2F6067e7ff-6903-4f16-88e5-ab8f86da2c1b.jpg</url>
      <title>DEV Community: jkorichneva</title>
      <link>https://dev.to/jkorichneva</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jkorichneva"/>
    <language>en</language>
    <item>
      <title>Is your PR really ready for review?</title>
      <dc:creator>jkorichneva</dc:creator>
      <pubDate>Fri, 26 May 2023 10:29:15 +0000</pubDate>
      <link>https://dev.to/jkorichneva/is-your-pr-really-ready-for-review-16c2</link>
      <guid>https://dev.to/jkorichneva/is-your-pr-really-ready-for-review-16c2</guid>
      <description>&lt;p&gt;When it comes to writing code, it's not just about making it work - it's also about making it &lt;strong&gt;readable&lt;/strong&gt; and &lt;strong&gt;maintainable&lt;/strong&gt;. Even though code review is a common practice, it is still a time-consuming and sometimes tiring process. It's important to reduce the amount of time needed for review and to make it easier for your colleagues. This way you have better chances for quick merge 🙂&lt;/p&gt;

&lt;p&gt;One effective way to do this is by checking your own PRs before asking for a review. But what exactly should you be checking in order to save everyone's time?&lt;/p&gt;

&lt;p&gt;While there are numerous articles and checklists on this topic, most of them cover common issues that can be fixed automatically, like alphabetical sorting of imports, typos and etc. Instead, this checklist focuses on aspects that cannot be automated:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variable names are &lt;strong&gt;clear&lt;/strong&gt; and &lt;strong&gt;descriptive&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Comments are added where necessary to clarify your changes.&lt;/li&gt;
&lt;li&gt;There are &lt;strong&gt;no out-of-scope&lt;/strong&gt; changes in the PR.&lt;/li&gt;
&lt;li&gt;PR focuses on &lt;strong&gt;one feature&lt;/strong&gt; and is relatively small.&lt;/li&gt;
&lt;li&gt;All functions and variables are in the right files and that there are &lt;strong&gt;no misplaced elements&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;There is a &lt;strong&gt;description&lt;/strong&gt; of the PR to give reviewers context.&lt;/li&gt;
&lt;li&gt;Docs are &lt;strong&gt;updated&lt;/strong&gt; to reflect any changes made in the PR.&lt;/li&gt;
&lt;li&gt;Any necessary &lt;strong&gt;cleanups&lt;/strong&gt; are done.&lt;/li&gt;
&lt;li&gt;Follow the &lt;strong&gt;single responsibility principle&lt;/strong&gt; in functions.&lt;/li&gt;
&lt;li&gt;Keep &lt;strong&gt;consistency&lt;/strong&gt; in mind throughout the PR.&lt;/li&gt;
&lt;li&gt;Follow the &lt;a href="https://www.oreilly.com/library/view/97-things-every/9780596809515/ch08.html"&gt;boyscout rule&lt;/a&gt;: 'Always leave the code better than you found it.'&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you check whether your PR complies with these rules, you will definitely get less comments on Code Review and save your colleagues a lot of time🙌&lt;/p&gt;

</description>
      <category>codereview</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How I re-wrote all my composite actions to workflows and why</title>
      <dc:creator>jkorichneva</dc:creator>
      <pubDate>Wed, 24 May 2023 16:54:35 +0000</pubDate>
      <link>https://dev.to/jkorichneva/how-i-re-wrote-all-my-composite-actions-to-workflows-and-why-14a5</link>
      <guid>https://dev.to/jkorichneva/how-i-re-wrote-all-my-composite-actions-to-workflows-and-why-14a5</guid>
      <description>&lt;h2&gt;
  
  
  What are composite actions and workflows?
&lt;/h2&gt;

&lt;p&gt;For one of my projects I used Github Actions for our CI/CD, which provided me with two fundamental ways of organizing our pipeline code - workflows and actions. What's the difference between them?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A workflow is a configurable automated process that will run one or more jobs.&lt;/p&gt;

&lt;p&gt;A composite action allows you to combine multiple workflow steps within one action.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In general, both approaches allow you to create reusable pipeline code, following the DRY (Do not repeat yourself) principle and combine related actions into one flow. From these quotes it is hard to determine which approach you should choose. If you want to get a quick overview - feel free to jump down to summary in a table and conclusion. Meanwhile, we will take a closer look.&lt;/p&gt;




&lt;p&gt;Let's take create a composite action and reusable workflow, then investigate the differences:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;You can copy these snippets or fork &lt;a href="https://github.com/jkorichneva/gh-actions"&gt;my repo&lt;/a&gt;. Let's run the trigger workflow from main branch:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tDwroR1f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c6g1jt0ghdxa4yrsl1gj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tDwroR1f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c6g1jt0ghdxa4yrsl1gj.png" alt="Image of github action steps completed" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Storage and folder structure
&lt;/h2&gt;

&lt;p&gt;Storage and folder structure differ for the two approaches. When using a composite action, you need to create a separate folder, and the action file must always be named &lt;code&gt;action.yml&lt;/code&gt;. On the other hand, workflows can be named freely and stored in the &lt;code&gt;workflows&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;If you aim to make actions or workflows reusable across multiple repositories, you have the option to publish them publicly. This allows other users to leverage your actions or workflows. However, if you have a Github Enterprise plan, you can create a private repository specifically for reusable actions or workflows, which will be shared only within your organization. This provides a more controlled and restricted sharing mechanism.&lt;/p&gt;

&lt;h3&gt;
  
  
  Calling
&lt;/h3&gt;

&lt;p&gt;We call a composite action as a step inside a job and we should always checkout from repo, otherwise there will be an error. &lt;br&gt;
When we call a reusable workflow, we "replace" the job in a workflow with this workflow and there is no need to check out.&lt;/p&gt;

&lt;h3&gt;
  
  
  Secret management
&lt;/h3&gt;

&lt;p&gt;Reusable workflows can inherit secrets from caller workflow, also &lt;code&gt;github&lt;/code&gt; context is shared between them. If you want to use secrets in composite action, you have to pass them as inputs or ENV-variables.&lt;/p&gt;

&lt;h3&gt;
  
  
  Jobs and paralleling
&lt;/h3&gt;

&lt;p&gt;You can parallel jobs in a reusable workflow, but you can parallel steps in a composite action. Composite action is a sequence of steps and can't use jobs inside.&lt;/p&gt;

&lt;h3&gt;
  
  
  Logging and timing
&lt;/h3&gt;

&lt;p&gt;Github Actions' interface shows you the sequence of steps executed and their timing. If you are using a resuable workflow, each step inside workflow is timed a displayed separately:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vtqYdDbP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2mnr1jjaw6j8hd9efm5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vtqYdDbP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2mnr1jjaw6j8hd9efm5.png" alt="Re-usable workflows logged separately" width="800" height="665"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Composite action is timed and displayed as one step, making tracking of pipeline's performance harder:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kzZIQsJg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xoyh68af1xzzydusvkgf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kzZIQsJg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xoyh68af1xzzydusvkgf.png" alt="Composition action logs are merged in one step" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you put importance in maintaining quick and transparent pipeline execution, this difference might be vital for you, as it was for me.&lt;/p&gt;




&lt;h2&gt;
  
  
  My story
&lt;/h2&gt;

&lt;p&gt;When I started refactoring the pipelines, I switched to composite actions, because mostly the code I extracted seemed to be like a complex step, rather then a job. Since the project's frontend resided in a monorepo, pipeline timing was an important metric. As the codebase grew with more applications, I encountered an issue when our pipeline execution time exceeded a critical threshold of eight minutes and started investigating, where the bottleneck was.&lt;/p&gt;

&lt;p&gt;As I dived into logs, Iunderstood, that wrapping steps into composite actions was a mistake. It was impossible to understand what is taking longer, unit tests or build time, when they are both timed as one step.&lt;/p&gt;

&lt;p&gt;I rewrote everything that was vital for timing and now I have a better understanding of where there is room for improvement in our pipeline because we are timing and collecting the stats for each step. There still are some composite actions, but they combine only lightweight steps.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summing up the differences:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AAFeWMjT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5ujjdkuxvvspa9w4msa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AAFeWMjT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5ujjdkuxvvspa9w4msa.png" alt="Table summary of differences" width="800" height="622"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In general, both reusable workflows and composite actions provide pretty much the same functionality. The main difference is in logging output, secret management and syntax, that you should keep in mind. If you know, that your pipeline might become a bottleneck you will need to improve, then go with reusable workflows for heavy tasks.&lt;/p&gt;

</description>
      <category>cicd</category>
      <category>githubactions</category>
      <category>devops</category>
    </item>
    <item>
      <title>Migrating single-spa monorepo to Vite with minimal changes in PR</title>
      <dc:creator>jkorichneva</dc:creator>
      <pubDate>Sat, 22 Apr 2023 09:22:21 +0000</pubDate>
      <link>https://dev.to/jkorichneva/migrating-single-spa-monorepo-to-vite-with-minimal-changes-in-pr-22l2</link>
      <guid>https://dev.to/jkorichneva/migrating-single-spa-monorepo-to-vite-with-minimal-changes-in-pr-22l2</guid>
      <description>&lt;p&gt;I have been with webpack for quite a long time, starting with version 3, then 4, and finally 5. It is familiar and incredibly customizable. Nevertheless, when you have to wait about 30 seconds to get your build done and then about 5 seconds for your changes to become interactive, love for webpack slowly vanishes.&lt;/p&gt;

&lt;p&gt;Usually there are three ways to deal with this tiring waiting:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Optimize webpack to make it faster (e.g. try &lt;a href="https://webpack.js.org/configuration/experiments/#experimentslazycompilation"&gt;lazy compilation&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Reduce bundle size (&lt;a href="https://www.npmjs.com/package/webpack-bundle-analyzer"&gt;webpack-bundle-analyzer&lt;/a&gt; is useful for this)&lt;/li&gt;
&lt;li&gt;Look for an alternative solution&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While I tried the second option, it didn't fully solve the issue. Vite has long been on everybody’s lips, promising quick builds and almost instant HMR. I decided to experiment with our single-spa monorepo and see the results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About migration&lt;/strong&gt;&lt;br&gt;
There are many migration guides available online, so I won't repeat them here,as they are easy to find. Generally, these are the steps to follow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install the necessary packages.&lt;/li&gt;
&lt;li&gt;Introduce an &lt;code&gt;index.html&lt;/code&gt; file in the root folder.&lt;/li&gt;
&lt;li&gt;Add the Vite config and customize it for your build.&lt;/li&gt;
&lt;li&gt;Change the commands to use Vite.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While going through these steps, I encountered following issues in adapting my configs of build into vite:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Env-variables&lt;/strong&gt;&lt;br&gt;
Vite requires all env variables to have the &lt;code&gt;VITE_&lt;/code&gt; prefix, but changing all references would have resulted in a large PR that would be difficult to review. I found a solution in &lt;a href="https://github.com/ElMassimo/vite-plugin-environment"&gt;vite-plugin-environment&lt;/a&gt;, which allowed me to keep all &lt;code&gt;process.env&lt;/code&gt; references untouched&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Absolute ts imports&lt;/strong&gt;&lt;br&gt;
Many of our imports, like &lt;code&gt;lib/exampleHook&lt;/code&gt;, were broken after switching to Vite. The issue was resolved just by adding &lt;a href="https://www.npmjs.com/package/vite-tsconfig-paths"&gt;vite-tsconfig-paths&lt;/a&gt; and all started working.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;License generation&lt;/strong&gt;&lt;br&gt;
Webpack creates license files out-of-the-box, while rollup that is inside vite, doesn’t. This can be fixed by &lt;a href="https://www.npmjs.com/package/rollup-plugin-license"&gt;rollup-plugin-license&lt;/a&gt;, it has a lot of customization, but in the end, I found the text files not so fancy as webpack. Maybe I just did not get it right.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Npm-package, that is not a module&lt;/strong&gt;&lt;br&gt;
We used &lt;a href="https://github.com/single-spa/single-spa-html"&gt;single-spa-html&lt;/a&gt; module for displaying some static errors, that was not a module, but a IIFE inside. I had to fork it and to put it inside my repo, changing it into a module.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single-spa complications&lt;/strong&gt;&lt;br&gt;
When developing locally, we loaded some scripts from test environment, that are transpiled into commonjs and that was a complication, as local modules should have been handled by vite, whereas those modules had to be registered via System Js. It lead to ugly if else that I won’t even add here.&lt;/p&gt;

&lt;p&gt;Another issue was that we had a module, that was used by all others externally. And again, the modules from test env needed commonjs version of sdk, while local needed es6 version, which also lead to pre-building it and serving from dist. I tried various configs, but didn’t succeed — vite was unstable when loading it and that sometimes affected the performance of the whole application.&lt;/p&gt;

&lt;p&gt;Results with vite actually working:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Local startup was about 30s, with vite about 3–4 seconds&lt;/li&gt;
&lt;li&gt;CI build time decreased by 30 seconds&lt;/li&gt;
&lt;li&gt;HMR was almost instant&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Vite is great, it really is a silver bullet for apps that take a long time building. However, if you have already codebase with customizations, the migration can be painful. As vite was working unstable with our external module and this issue required a lot of investigation, we decided to postpone the migration for now. Hopefully, after some other refactoring, we will get back to it.&lt;/p&gt;

</description>
      <category>vite</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
