DEV Community

Cover image for #DevHack: cross-platform testing your tool on GitHub Actions
Elio Struyf
Elio Struyf

Posted on

1

#DevHack: cross-platform testing your tool on GitHub Actions

One of the Doctor’s objectives, a documentation tool that converts markdown to SharePoint pages, was to make it usable cross-platform. Initially, I created this as an internal tool for Valo and would only be used on Azure DevOps or GitHub Actions. In the first release, I focussed on making the tool available to others like you and seeing if there was any interest in it.

Info: Doctor - the static site generator for SharePoint

Once the first version was released, one of the first tasks was to get this cross-platform support in place. Each OS has its challenges, but Windows was the worst of all. As Doctor uses the CLI for Microsoft 365, the JSON data provided to the commands had to be formatted correctly. Where on macOS and Linux, it is relatively easy. On Windows, it took some time to get it right. For instance, the string replacement looks like for getting JSON within a JSON object to work.

String replacement for Windows
String replacement for Windows

There are also some differences between the standard command prompt and the PowerShell prompt. That is why I wanted to find a way to make sure that I can quickly check if it still works on each of them.

GitHub Actions

GitHub Actions is the perfect fit for this, as you can create various flows from build/release/testing. In Doctor’s case, I went for a flow that runs on each PR and validates if the project builds, retrieves the sample site repository, and checks if it can publish on Windows, Linux, and macOS.

Here is what it looks like:

Builds running for each OS
Builds running for each OS

In the actions, you can see that four builds are happening. Two of them are running in a matrix strategy. I took Windows out of the matrix strategy as I wanted to specify the shell to use. Setting the shell in a matrix is currently not possible, it seems.

Completed builds and publish
Completed builds and publish

When you would open a PR, it would start the flow of the same actions.

PR Tests
PR Tests

These actions make it easier to validate if the incoming PR is not breaking any of the logic which is currently in place.

Completed PR Tests
Completed PR Tests

You can find the code of this GitHub Action here: Test Build and Publish.

Can you still live without all these automation tools? I definitely cannot anymore. It will not take human testing away completely, but for sure, it makes things a lot easier and quality better.

Article was first published on https://www.eliostruyf.com/devhack-cross-platform-testing-tool-github-actions/

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay