Home  >  Article  >  Web Front-end  >  Making CI pipeline for Explainer.js

Making CI pipeline for Explainer.js

Barbara Streisand
Barbara StreisandOriginal
2024-11-13 16:30:02940browse

Making CI pipeline for Explainer.js

This week we I made a CI pipeline for my Explainer.js. Since I have different scripts set up over the last few weeks it was fairly simple.

Setting up CI in Explainer.js

First set to setting up CI pipeline is adding a YML file in the .github/workflows directory. I used the default version of the node.js CI template from GitHub but with some changes. First I made a draft PR with the default options. Then I pulled the branch and made several adjustments. I changed the name, broke the build job into three separate jobs. Build to install node and then lint-and-format and finally test to run the tests. I also used needs keyword to skip the next job so if the previous one fails it will skip the next one. So, if node set up fails it will not run lint-and-format and if lint-and-format fails it will not run tests. Which did happen a few times because my index.test.js was not set up properly so I had to make a small fix by passing the test-api-key via argv for it to run. It was running fine locally because I have a .toml and .env set up already. Setting up lint-and-format was fairly easy since I run the script when I try to commit locally so it automatically formats my files. I made changes to the default YML file according to my needs of my project. And It works pretty good! Check it out.

Working in DocBot

I worked on DocBot. Although the project is in JS, this project uses a different testing framework called vitest which is jest compatible. One thing I immediately noticed how fast it was compared to just jest. And the terminal output is super polished. Making working on the issue a quite enjoyable. I worked to make file.test.js test suite OS agnostic. I ran it in my WSL termial which ran fine but it did not run in cmd.exe. I immediately noticed now the expected path structure was different. Something I came across when I finished writing my tests in explainer.js last week. I use WSL by default but I rememebered not everyone has it so I ran it in cmd.exe and I had the same issue for the tests I wrote in FilePathResolver.test.js so I had to fix it. So, it is easy to overlook running the terminal in different os when using the default setup vscode terminal. So after some trial and error I fixed it and made my PR.

The above is the detailed content of Making CI pipeline for Explainer.js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn