<?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: Matt Gaiser</title>
    <description>The latest articles on DEV Community by Matt Gaiser (@mattgaiser).</description>
    <link>https://dev.to/mattgaiser</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%2F343760%2F21cf8285-16d0-4470-bd95-dd4af25e9dc8.jpeg</url>
      <title>DEV Community: Matt Gaiser</title>
      <link>https://dev.to/mattgaiser</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mattgaiser"/>
    <language>en</language>
    <item>
      <title>Free Code Coverage for Pull Requests on GitHub. </title>
      <dc:creator>Matt Gaiser</dc:creator>
      <pubDate>Sat, 28 Aug 2021 19:17:47 +0000</pubDate>
      <link>https://dev.to/mattgaiser/free-code-coverage-for-pull-requests-on-github-2mgp</link>
      <guid>https://dev.to/mattgaiser/free-code-coverage-for-pull-requests-on-github-2mgp</guid>
      <description>&lt;p&gt;Say that you want some of the benefits of &lt;a href="https://about.codecov.io/"&gt;CodeCov&lt;/a&gt; but your company is too cheap to pay for it or you just don't want to have to go through the procurement process. What do you do? &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Generate a code coverage report in a text format.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I did this for an Angular project, it was just a matter of changing the test coverage reporters in &lt;code&gt;karma.conf.js&lt;/code&gt; to include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      reporters: [
        { type: 'text-summary',
          dir : '../../coverage',
          file : 'coverage.txt'
        },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives me a text file that I can read to get the lines of code coverage. Because code coverage reporting is highly framework and language specific, I am not going to go into detail here about it. Already having the code coverage numbers  is a prerequisite for the rest of the tasks. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Figure out the &lt;code&gt;grep&lt;/code&gt; or &lt;code&gt;awk&lt;/code&gt; bash command to read the text file.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My code coverage tool generates this as its text output. This image is from the console, but what it writes to the file is the same. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--59v0bJFX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3wbig0xodksqsa3omuqk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--59v0bJFX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3wbig0xodksqsa3omuqk.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It lives in the &lt;code&gt;coverage&lt;/code&gt; directory in a file called &lt;code&gt;coverage.txt.&lt;/code&gt; I want the percent of lines covered by tests, so I use this: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;awk '/^Lines/ { print $3 }' &amp;lt; coverage/coverage.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Have your Github Action generate the coverage report.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;I assume that you have already set up automated testing on Github Actions for each PR (but if not, the full code is at the bottom of the page), so all you must do is set up another Github Action that runs the coverage portion and generates the report. You can likely take the existing GitHub Action and just replace its &lt;code&gt;run&lt;/code&gt; with these lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - name: Run tests
   run: npm run test:coverage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Add &lt;code&gt;mshick/add-pr-comment@v1&lt;/code&gt; to your GitHub Action to add a comment.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/marketplace/actions/add-pr-comment"&gt;Add PR Comment&lt;/a&gt; is a GitHub Action that adds a comment to a PR (the name is pretty straightforward). It is what will post the coverage info to the PR. Each time a new push is made, it will make a new comment if the coverage has changed (it will not comment if the coverage has not changed).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- uses: mshick/add-pr-comment@v1
        with:
          message: | &amp;lt;Message goes here without arrows&amp;gt;
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
          allow-repeats: false # This is the default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Use your bash command to get the coverage value and insert it into the comment.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run the bash command and assign it to a variable. Add the variable to the string and have it printed out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      - name: Get coverage output
        id: get_coverage
        run: echo "::set-output name=coverage::$(awk '/^Lines/ { print $3 }' &amp;lt; coverage/coverage.txt)"

      - uses: mshick/add-pr-comment@v1
        with:
          message: |
            Lines Covered: ${{steps.get_coverage.outputs.coverage}}
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
          allow-repeats: false # This is the default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That lets you get this: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cq52JMFO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y78pddampiuizcx18mnz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cq52JMFO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y78pddampiuizcx18mnz.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full Example GitHub Action&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Report Code Coverage

on:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Use Node.js 12.x
        uses: actions/setup-node@v1
        with:
          node-version: 12.x

      - name: Install dependencies
        run: npm ci

      - name: Run tests
        run: npm run test:coverage

      - name: Get coverage output
        id: get_coverage
        run: echo "::set-output name=coverage::$(awk '/^Lines/ { print $3 }' &amp;lt; coverage/coverage.txt)"

      - uses: mshick/add-pr-comment@v1
        with:
          message: |
            Lines Covered: ${{steps.get_coverage.outputs.coverage}}
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
          allow-repeats: false # This is the default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>The Chrome Extension Deployment Checklist</title>
      <dc:creator>Matt Gaiser</dc:creator>
      <pubDate>Sat, 01 May 2021 07:59:48 +0000</pubDate>
      <link>https://dev.to/mattgaiser/the-chrome-extension-deployment-checklist-2dg5</link>
      <guid>https://dev.to/mattgaiser/the-chrome-extension-deployment-checklist-2dg5</guid>
      <description>&lt;p&gt;I always find it frustrating when the documents do not specify exactly what is required for deployment of something to an app store, something which has delayed my current team a few times. &lt;/p&gt;

&lt;p&gt;Here is what the Chrome Web Store requires for deployment of an extension: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Title from package&lt;/strong&gt;*: This is the title that you set in the &lt;code&gt;manifest.json&lt;/code&gt; as the value for &lt;code&gt;name&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary from package&lt;/strong&gt;: This is the sentence that you set in the &lt;code&gt;manifest.json&lt;/code&gt;under &lt;code&gt;description&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;*: An up to 16,000 character block of text that focuses on explaining what your extension does and why users should install it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Category&lt;/strong&gt;: This is a dropdown of several categories from which you must choose one. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Language&lt;/strong&gt;: This is a dropdown of many languages from which you must choose one. There is also a localization process for supporting multiple languages. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Store Icon&lt;/strong&gt;*: This is a 128 pixel by 128 pixel PNG (mandatory file format) image that should work well on both light and dark backgrounds. A 16 pixel margin should be included on all sides of the icon, so the actual icon size should be 96 pixels by 96 pixels.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global Promo Video&lt;/strong&gt;: This is intended to by a YouTube video link to whatever promotional video you have made for the extension. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Screenshots&lt;/strong&gt;*: Screenshots must be 1280 pixels by 800 pixels or 640 pixels by 400 pixels. They must either be JPEG files or 24-bit PNG files with no alpha. At least one is required, but a maximum of 5 are allowed. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Small Promo Tile&lt;/strong&gt;: This is a 440 pixel by 280 pixel image that must be either a JPEG or a 24-bit PNG file with no alpha. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Large Promo Tile&lt;/strong&gt;: This is a 920 pixel by 680 pixel image that must be either a JPEG or a 24-bit PNG file with no alpha. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Marquee Promo Tile&lt;/strong&gt;: This is a 1400 pixel by 560 pixel image that must be either a JPEG or a 24-bit PNG file with no alpha. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Official URL&lt;/strong&gt;: This is a website URL that needs to be added through the Google Search Console. Unfortunately, a URL cannot simply be pasted in. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Homepage URL&lt;/strong&gt;: This is another website URL. It can just be pasted in, unlike the &lt;strong&gt;Official URL&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Support URL&lt;/strong&gt;: This is intended to be a website URL. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single Purpose&lt;/strong&gt;*: This is the single purpose of the extension that is narrow in scope and easy to understand. It must be less than 1000 characters. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Permission Justifications&lt;/strong&gt;*: These are 1000 character explanations for why your extension requires certain functionality that can be used to harm extension users. Explain why that permission is specifically required for the purpose of your extension. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remote Code&lt;/strong&gt;: This is meant to justify why you are using code which is imported from a server through a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag or modules pointing to external files. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Usage&lt;/strong&gt;: These are a series of checkboxes that ask you about the data that you are collecting, if any. No explanations required, just binary answers. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Payments&lt;/strong&gt;: Whether your extension requires or can be enhanced by purchasing items, features, or subscriptions. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Visibility&lt;/strong&gt;: You can set it to &lt;code&gt;public&lt;/code&gt;, where it is placed in the Web Store. It can be set to &lt;code&gt;unlisted&lt;/code&gt;, where only those with a link see it. It can also be set to &lt;code&gt;private&lt;/code&gt; so that &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Distribution&lt;/strong&gt;: A checklist of countries where you might want to distribute the extension. &lt;/p&gt;

&lt;p&gt;Happy building! &lt;/p&gt;

</description>
      <category>chrome</category>
      <category>extension</category>
      <category>deployment</category>
      <category>checklist</category>
    </item>
    <item>
      <title>How to debug an Office.js Manifest File</title>
      <dc:creator>Matt Gaiser</dc:creator>
      <pubDate>Tue, 22 Dec 2020 08:47:11 +0000</pubDate>
      <link>https://dev.to/mattgaiser/how-to-debug-an-office-js-manifest-file-4bi9</link>
      <guid>https://dev.to/mattgaiser/how-to-debug-an-office-js-manifest-file-4bi9</guid>
      <description>&lt;p&gt;For the past couple of weeks, I have been developing Microsoft Word Add-in's using the &lt;a href="https://docs.microsoft.com/en-us/office/dev/add-ins/overview/learning-path-beginner"&gt;Office.js&lt;/a&gt; framework, which lets you create web applications that can interact directly with any Microsoft Office application.  &lt;/p&gt;

&lt;p&gt;One of the tasks that has taken me the most time so far has been understanding and debugging the &lt;code&gt;manifest.xml&lt;/code&gt; file, which is the file where UI components like labels and menus that integrate into the context menu (that box you get when you right-click) or the ribbon (the row of buttons at the top) are defined. &lt;/p&gt;

&lt;p&gt;Debugging a &lt;code&gt;manifest.xml&lt;/code&gt; file can mean two things. We will cover them both here. &lt;/p&gt;

&lt;h3&gt;
  
  
  1. Determining if it is valid XML for an Office Add-in
&lt;/h3&gt;

&lt;p&gt;Microsoft provides a tool to check whether your &lt;code&gt;manifest.xml&lt;/code&gt; is valid. You can read about it in &lt;a href="https://docs.microsoft.com/en-us/office/dev/add-ins/testing/troubleshoot-manifest"&gt;more detail here&lt;/a&gt;, but the basics are below.  &lt;/p&gt;

&lt;h4&gt;
  
  
  If you used the Yeoman generator
&lt;/h4&gt;

&lt;p&gt;If you used the Microsoft provided generator to set up the Office Add-in, it is as simple as running the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run validate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  If you did not use the Yeoman generator
&lt;/h4&gt;

&lt;p&gt;You need to take the extra step of installing &lt;a href="https://www.npmjs.com/package/office-addin-manifest"&gt;the validation package&lt;/a&gt; first.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g office-addin-manifest
npm run validate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This step is well covered in the Microsoft documentation and is mostly here for completeness. But it does not actually report runtime errors, the kind of errors that otherwise silently occur and lead to menus, icons, and buttons not showing up. &lt;/p&gt;

&lt;h3&gt;
  
  
  2. Determining what errors might be causing it not to render properly
&lt;/h3&gt;

&lt;p&gt;Unfortunately, when you Google for ways to debug the manifest file, it usually points you to the &lt;a href="https://docs.microsoft.com/en-us/office/dev/add-ins/testing/troubleshoot-manifest"&gt;aforementioned validator&lt;/a&gt;, which is helpful but does not come close to solving actual bugs in the manifest that might cause your desired UI components to just not appear. It took me several days to figure out how you debug a syntactically correct but broken manifest file, which was a motivation for writing this post. &lt;/p&gt;

&lt;p&gt;This debugging methof generates a runtime log for the &lt;code&gt;manifest.xml&lt;/code&gt; of the errors that it encountered: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;a href="https://support.microsoft.com/en-us/windows/how-to-open-registry-editor-in-windows-10-deab38e6-91d6-e0aa-4b7c-8878d9e07b11"&gt;the Registry Editor&lt;/a&gt; on Windows. You can just search for it in the search bar and the logo looks like that.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1xxxfZuv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qx4jou1da0shy0rl4c4t.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Navigate to &lt;code&gt;HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Wef\Developer\&lt;/code&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YPlFG4SI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2f2sa8z03hnhjg4y825v.PNG" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Add a key called &lt;code&gt;RuntimeLogging&lt;/code&gt; to &lt;code&gt;Developer&lt;/code&gt;. To do that, just right click on the &lt;code&gt;Developer&lt;/code&gt; folder and choose &lt;code&gt;New&lt;/code&gt; and then &lt;code&gt;Key&lt;/code&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KVcm02Ql--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aeclvujrmho1yhcr9yyv.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Click on &lt;code&gt;RuntimeLogging&lt;/code&gt; and then double click on (Default) in the box to the right. 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2DoqOVJD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h5wxkrc2rpwlwfn7ow11.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Add the path to the .txt file where you want the log messages to be written. If you have not created a file for that, go and create one. That path should include the file name.  &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BlUcqoEa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7naacjmlxki474vpe0ek.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Run the Add-in however you normally would in your development environment. As far as I know, it requires no special flags or parameters in any configuration. &lt;/li&gt;
&lt;li&gt;After the Add-in has loaded in Office, you can check the designated file for any useful log messages. &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UGqU48oi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/as7mru4afccfvzhbnu46.PNG" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Happy debugging! &lt;/p&gt;

</description>
      <category>office</category>
      <category>word</category>
      <category>microsoft</category>
      <category>addin</category>
    </item>
  </channel>
</rss>
