#DevHack: cross-platform testing your tool on GitHub Actions
Tags: github, webdev, documentation, devops
Published: 2020-12-22 09:33:29

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](https://www.eliostruyf.com/doctor-static-site-generator-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](https://www.eliostruyf.com/uploads/2020/12/github5.png)<figcaption>String replacement for Windows</figcaption>

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](https://www.eliostruyf.com/uploads/2020/12/github1.png)<figcaption>Builds running for each OS</figcaption>

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](https://www.eliostruyf.com/uploads/2020/12/github2.png)<figcaption>Completed builds and publish</figcaption>

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

![PR Tests](https://www.eliostruyf.com/uploads/2020/12/github3.png)<figcaption>PR Tests</figcaption>

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](https://www.eliostruyf.com/uploads/2020/12/github4.png)<figcaption>Completed PR Tests</figcaption>

You can find the code of this GitHub Action here: [Test Build and Publish](https://github.com/ValoIntranet/doctor/blob/main/.github/workflows/test-build.yml).

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/](https://www.eliostruyf.com/devhack-cross-platform-testing-tool-github-actions/)*