Change Impact Analysis

Using Foresight for Improved Observability in Jira

Foresight closes JSM’s test gaps, captures code changes, and reports test statuses, optimizing GitHub and JSM integration by ensuring monitoring transparency
Serkan Ozal
5 mins read

As someone working in the software field, you’re probably already familiar with Atlassian’s products. Atlassian offers a range of tools to help manage tasks (Jira), support developers’ collaboration on code (Bitbucket) or centralize software documents (Confluence). In 2020, they released Jira Service Management (JSM), which allows developers, administrators, and business owners to collaborate at high velocity.

Jira Service Management

JSM makes work visible and acts as a single source of truth, so that an entire IT team can view work processes and outstanding tasks in a single location, keeping everyone on the same page and allowing for efficient collaboration. Code reviewers can also use data provided by JSM to decide whether to merge pull requests from their software engineers; this determines whether new changes are applied to the existing software to improve customer experience. JSM offers important benefits to any DevOps team.

JSM’s Limitation; Foresight’s Solution

Despite having all these great features, JSM still lacks one important feature: It doesn’t display the status of the tests in the software project. Without test status observability, we cannot be certain whether the software works as expected.

This is where Foresight comes in handy. By combining Foresight tests’ data capture and JSM’s data, code reviewers can be certain about what has been changed in the code and where, and whether or not the changed code has already been checked using new tests.

Let’s explore how Foresight complements JSM using a real world example.

Demo Project: Applying Foresight to JSM

Let’s create a project demonstrating JSM and Foresight in a retail application. Our application will allow users to shop online. Its code can be found in this GitHub repository.

When we deploy the application, here’s what we see:

Figure 1: Home page of the retail application

The application is up and running, and already has a good number of users. After a few months, some customers report an error to the customer service team. A new JSM issue is created by the customer service team describing the bug.

Figure 2: A Jira Service Management bug report

When the users try to add a product to the cart, the default number of the products in the product page view is seven, instead of just one item as we would expect. Reporting this bug in the JSM board means that customer service staff, developers, and technical leads can track the updates about the bug simultaneously, enabling them to collaborate together efficiently.

Create a GitHub Action Workflow

We need to create a GitHub Action workflow for this project in order to apply every updated code change. This allows us to test the new code and check whether it introduces any errors. Here is the GitHub workflow file defined in yaml format:


name: Default

on:
  pull_request:
	branches:
  	- "main"

jobs:
  test:
	name: Test
	runs-on: ubuntu-latest
	strategy:
  	max-parallel: 1
  	matrix:
    	python-version: [ 3.8 ]
	steps:
  	- uses: actions/checkout@v3
  	- name: Set up Python ${{ matrix.python-version }}
    	uses: actions/setup-python@v1
    	with:
      	python-version: ${{ matrix.python-version }}
  	- name: Install Dependencies
    	run: |
      	python -m pip install --upgrade pip
      	pip install -r requirements.txt
  	- name: Run Tests'
    	run: |
      	pytest --junitxml=report.xml --cov-report xml:cov.xml --cov=core core/tests/

In this workflow, we first need to download the latest code from GitHub. Next, we’ll set up Python version 3.8, and finally, we’ll install dependencies to be able to run the test for the retail application.

When we push the workflow file to the GitHub repository and create a pull request in GitHub, we see that the GitHub Action is triggered automatically.

Figure 3: GitHub Action is triggered automatically

Now that we’ve created the GitHub Workflow for deploying the application, let’s go ahead and integrate JSM with GitHub.

Integrate JSM with GitHub

To collaborate as a team on Jira Service Management, we need to integrate JSM with GitHub so that everyone on our team can see the code changes in GitHub that pertain to a bug reported using JSM. This allows us to review the code efficiently and to check whether the updated code resolves the bug or not.

To integrate JSM with GitHub, we first need to install the GitHub integration tool.

Figure 4: Install GitHub for integration with JSM

Then click “Get it now” to install GitHub for JSM.

Figure 5: Choose a site

After choosing the relevant JSM site, click “Install app.”

Figure 6: Get started with GitHub for JSM

Click “Get started” to start integrating GitHub and JSM. After this step, we’ll be redirected to the configuration page automatically, where we’ll indicate our GitHub organization or GitHub personal repository in order to choose which data we’re going to integrate with JSM.

Figure 7: Connect a GitHub organization to a JSM site

If the relevant personal or organizational GitHub account isn’t showing up on this screen yet, we need to install the “Jira Software + GitHub” application in the appropriate GitHub account. The Github For Jira integration page offers a guide to this process.

Figure 8: Install Jira Software + GitHub from GitHub marketplace

After installing the “Jira Software + GitHub” application, we’ll see that the “Jira” application is added to our listed applications in GitHub.

Figure 9: Jira integration application is added to GitHub

Then, we should be able to see our GitHub account/GitHub organization in the Jira set up page in order to integrate them with one another.

Figure 10: Jira integration application is added to GitHub

After choosing the Github account/GitHub organization we want to integrate, we should see “Install Jira'' displayed:

Figure 11: Install Jira on GitHub organization

Hit “Install,” then choose the relevant site.

Figure 12: Select the Jira site to connect to a GitHub organization

After clicking on “Connect,” we should be able to see our new account/organization in the connected organizations list on the Jira configuration page.

Figure 13: New account visible in Jira

We should also see the Github pull request and its commit in JSM by now.

Figure 14: JSM and GitHub are now integrated

Great! We’ve successfully integrated JSM with GitHub. Let’s move to the next step: Checking the new pull request in GitHub from the JSM site.

Check the New Pull Request in GitHub

Let’s pick up where we left off in our online retail demo. The store’s customer service team had created a new JSM issue on the JSM board. When viewing a product page, customers were being presented with the default number of items being seven, instead of one as we’d expect.

From a business perspective, this could make customers uncomfortable and may discourage purchasing, because customers think that the shopping site is forcing them to buy in high quantities.

Let’s remind ourselves how this looks in JSM:

Figure 15: Reviewing the new bug raised by customer service team

Our team quickly found the root cause of the error and submitted a new pull request to GitHub Action.

Let’s take a look at the pull request to decide whether or not to apply this change.

JSM’s Shortcoming

From the JSM bug report, we can see the code commits as below.

Figure 16: Recent code commits as viewed in JSM

There is a commit for “Update test for default value of item.” Let’s take a closer look.

Figure 17: Details of the code changes

We can see that the default number of items has been updated to one instead of seven, which should resolve our issue. However, we’re not sure whether the bug is really fixed because we can’t see the status of all the executed tests from JSM and GitHub in this view. Moreover, we don’t know whether or not the developer added new tests for the updated codes.

This is where we need to call on Foresight. Let’s integrate Foresight into GitHub Action workflows so we can answer these important questions and make sure our application is functioning as it should.

Integrate Foresight into Existing GitHub Action Workflows

In order to integrate Foresight into GitHub Action workflows, we need to add foresight-workflow-kit-action and foresight-test-kit-action into the defined yaml file. The final workflow yaml file will look like this:


name: Default

on:
  pull_request:
	branches:
  	- "main"

jobs:
  test:
	name: Test
	runs-on: ubuntu-latest
	strategy:
  	max-parallel: 1
  	matrix:
    	python-version: [ 3.8 ]
	steps:
  	- name: Collect Workflow Telemetry
    	uses: runforesight/foresight-workflow-kit-action@v1
    	if: success() || failure()
    	with:
      	api_key: ${{ secrets.THUNDRA_APIKEY }}
  	- uses: actions/checkout@v3
  	- name: Set up Python ${{ matrix.python-version }}
    	uses: actions/setup-python@v1
    	with:
      	python-version: ${{ matrix.python-version }}
  	- name: Install Dependencies
    	run: |
      	python -m pip install --upgrade pip
      	pip install -r requirements.txt
  	- name: Run Tests'
    	run: |
      	pytest --junitxml=report.xml --cov-report xml:cov.xml --cov=core core/tests/
  	- name: Foresight test kit
    	if: success() || failure()
    	uses: runforesight/foresight-test-kit-action@v1
    	with:
      	api_key: ${{ secrets.THUNDRA_APIKEY }}
      	test_format: JUNIT
      	test_framework: PYTEST
      	test_path: report.xml
      	coverage_format: JACOCO/XML
      	coverage_path: cov.xml

Let’s push this updated code to the GitHub repository to see the status of the tests in Foresight.

Foresight Capabilities to the Rescue

In Foresight, we can see that the latest workflow run is successful.

Figure 18: Recent workflow status in Foresight

The “Tests” status in the workflow shows us whether our tests are successful or not.

Figure 19: Overview of change impact analysis and tests status

Here, we can see all our tests (two, in this case) are successful. However, we notice that there is one line in our code that hasn’t yet been tested. Click on “See Changes” to see what code this is.

Figure 20: Details showing which code hasn’t yet been tested

There is one line—indicated by brown highlight—that hasn’t been tested, which is:


def __str__(self):
return self.title

Since this code escaped testing, we need to add more tests to make sure that we’re running tests on each and every line of code in order to mitigate the risks of introducing new bugs to the application. Let’s skip ahead and see what happens once someone on our team has added new tests to account for this line of code.

Check the Tests Status After Adding a New Test

After adding this new test, our team created a new pull request for the JSM issue. When we check the pull request from JSM, we can see that there is a commit for the new test, named “Add test for checking self.title.”

Figure 21: New commit view in JSM

Clicking on that commit, we see the new test that we added.

Figure 22: Testing new code in GitHub

Here, our team added a new test named “test_check_title_item” for checking the __str__ method.

Let’s go to Foresight to see the status of our tests in the workflow.

Figure 23: All codes are now covered by our tests

We now have three tests, all of which have passed, and we can see that all of our code has been accounted for in these tests. The new pull request is now ready to be merged.

Figure 24: Preparing to merge the pull request

Let’s go ahead and merge it in order to deploy the fix for the bug.

Figure 25: The pull request is merged successfully

Thanks to Foresight’s change impact analysis, we’re able to see which lines of code are accounted for by tests, and the status of the executed tests. With this information, we’re able to merge our team’s pull request with confidence.

Conclusion

Foresight closes JSM’s test gaps, captures code changes, and reports test statuses, optimizing GitHub and JSM integration by ensuring monitoring transparency for the entire DevOps team, allowing code fixes to be performed quickly and efficiently.

Explore how Foresight can help you to build reliable products quickly and efficiently today!

Flexible pricing that scales with your team, and free for open-source!

See our pricing plans