Saturday, May 15, 2021

JET - ESLint, Prettier & CI/CD with GitHub Actions

 JET - v10.1.0

Source: GitHub

This blog post is a guide to set up automated code style checks and build pipelines using GitHub Actions, for an Oracle JET CLI project.

Let's break down automated the build process:

ESLint - refer to the .eslintrc.json file in the repository. I have overridden a couple of rules for the demo purpose. e.g., no console.log statements and no unused variables.
NPM: npm i -D eslint


sample.js lint errors

eslint run results



Prettier - this is a dev-dependency that is widely used to enforce code styles. You can set up your own rules in the .prettierrc file. I have set up some of the commonly used ones.
NPM: npm i -D prettier

GitHub Actions - while setting up the pipeline, I have set up 3 stages: install, check and build.

GitHub Actions flow

The .yml file can be located inside .github/workflows folder in the repository.

The install step generates the node_modules and caches it for the subsequent steps.
The check step runs eslint and prettier commands.
The build step install ojet-cli and builds the project.

One important GOTCHA! On the build step, make sure you install the @oracle/ojet-cli globally on GitHub's node box, since, unfortunately, JET is still not available on the major CI/CD providers.

GitHub Actions build step


Hope this was useful :-)

Cheers!

No comments:

Must Watch YouTube Videos for Databricks Platform Administrators

  While written word is clearly the medium of choice for this platform, sometimes a picture or a video can be worth 1,000 words. Below are  ...