# Day 14 : Integrate SonarQube, Linting, and Tests in GitHub Actions CI

Daily Tasks :&#x20;

* update jira
* Set up SonarQube locally (via Docker) and integrate it with GitHub Actions.
* Add linting (ESLint, Checkstyle, Flake8, golangci-lint) and unit tests for all services.
* Update the CI pipeline to include SonarQube and quality gates.
* Troubleshoot Jenkins Docker issue for future use.
* Update GitHub repo, Jira, and README.md.

**Why Linting and Tests?**

* **Linting**: Enforces coding standards (e.g., consistent formatting, error prevention), improving maintainability. Tools like ESLint catch issues early, as you saw in real-world pipelines.
* **Unit Tests**: Validate individual components (e.g., User Service CRUD), ensuring reliability before deployment.
* **CD Prep**: Clean, tested code is a prerequisite for automated deployments to dev, staging, pre-prod, and prod, mirroring enterprise workflows you explored

Add linting :&#x20;

* **ESLint** for Product Service (Node.js).
* **Checkstyle** for User and Recommend Services (Java).
* **Flake8** for Order Service (Python)

Go to product-service and run&#x20;

```bash
npm install --save-dev eslint
npx eslint --init
```

**SonarQube**: A tool for static code analysis, catching bugs, vulnerabilities, and code smells across Java, JavaScript, Python, and Go (your services’ languages). It’s perfect for ensuring your code is clean before deployment to dev, staging, pre-prod, or prod, as you explored in real-world pipelines

let's run sonarqube as a docker container once it is spin up we can access it by visiting `http://localhost:9000`&#x20;

```
docker run -d \
  --name sonarqube \
  -p 9000:9000 \
  --restart unless-stopped \
  sonarqube:lts-community
```

<figure><img src="/files/GquVc47o02c2m2CHXNvc" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/9YB4R37hvhU6A0JiIEWf" alt=""><figcaption></figcaption></figure>

Initial username and password are `admin` and `admin` later it will ask you to change password

<figure><img src="/files/ckkvywQnE5W6N3x4T7Hn" alt=""><figcaption></figcaption></figure>

* we have choice to either import our project from anyof the source code management tools or we can create project on our own. I am going with manual project creation
*

```
<figure><img src="/files/m2EOh9ymbPw0FCYsZfek" alt=""><figcaption></figcaption></figure>
```

* once we completed project setup, sonar asks us with which CI tool you wanted to use sonarqube

let's say i chose githubactions

<figure><img src="/files/au0aUnjKNVd6mCuAm58a" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/hqIJvJTAhkRmihm8GKkE" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2wbD5X4jgEV6jzJLIfst" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://charan-techjourney.gitbook.io/charan-techjournal/50-days-of-devops-ecommerce-microservices/project-daily-tasks/day-14-integrate-sonarqube-linting-and-tests-in-github-actions-ci.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
