Skip to content

Latest commit

 

History

History
212 lines (170 loc) · 9.47 KB

CONTRIBUTING.md

File metadata and controls

212 lines (170 loc) · 9.47 KB

Contributing In General

Our project welcomes external contributions. If you have an itch, please feel free to scratch it.

To contribute code or documentation, please submit a pull request.

A good way to familiarize yourself with the codebase and contribution process is to look for and tackle low-hanging fruit in the issue tracker. Before embarking on a more ambitious contribution, please quickly get in touch with us.

Note: We appreciate your effort, and want to avoid a situation where a contribution requires extensive rework (by you or by us), sits in backlog for a long time, or cannot be accepted at all!

Proposing new features

If you would like to implement a new feature, please raise an issue before sending a pull request so the feature can be discussed. This is to avoid you wasting your valuable time working on a feature that the project developers are not interested in accepting into the code base.

Fixing bugs

If you would like to fix a bug, please raise an issue before sending a pull request so it can be tracked.

Merge approval

The project maintainers use LGTM (Looks Good To Me) in comments on the code review to indicate acceptance. A change requires LGTMs from two of the maintainers of each component affected.

For a list of the maintainers, see the MAINTAINERS.md page.

Legal

Each source file must include a license header for the Apache Software License 2.0. Using the SPDX format is the simplest approach. e.g.

/*
Copyright <holder> All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

We have tried to make it as easy as possible to make contributions. This applies to how we handle the legal aspects of contribution. We use the same approach - the Developer's Certificate of Origin 1.1 (DCO) - that the Linux® Kernel community uses to manage code contributions.

We simply ask that when submitting a patch for review, the developer must include a sign-off statement in the commit message.

Here is an example Signed-off-by line, which indicates that the submitter accepts the DCO:

Signed-off-by: John Doe <[email protected]>

You can include this automatically when you commit a change to your local git repository using the following command:

git commit -s

Communication

Please feel free to connect with us on our Slack channel.

Setup

  1. Install Pycharm
  2. Navigate to Project from Version Control... and follow next steps

To run the tool with sample data perform the following steps:

  1. Right click on javacore_analyzer.py directory in Project view and select Modify Run Configuration.... When the window appears, add the following commandline to run parameters
    test/data/javacores /tmp/javacoreanalyser_output
    Change the second parameter to the directory where you want the output report be created.
  2. Right click again on javacore_analyser.py and select Run or Debug.

To run web application:

  1. Right click on javacore_analyser_web.py directory in Project view and select Modify Run Configuration....

  2. Add the following parameters:
    debug=True reports_dir=/tmp/web_reports

    You can change the report dir to the location when you want to store the report. The application will start on http://localhost:5000

Build pip package

Follow the steps from Packaging projects. Currently Chris and Tad have an API keys for test and production pypi

Build container localy

To build a container:
podman build -t javacore-analyser .

or

docker build -t javacore-analyser .

To start the container:
podman run -it --rm --name javacore-analyser --mount type=bind,src="local-dir-on-fs",target=/reports -p 5001:5000 javacore-analyser

or

docker run -it --rm --name javacore-analyser --mount type=bind,src="local-dir-on-fs",target=/reports -p 5001:5000 javacore-analyser

src parameter specifies where you want to store reports locally
-p specifies port mapping. The application in container is running on port 5000. You can map it to another port on your machine (5001 in this example).

Publish the container to ghcr.io/ibm/javacore-analyser

Once you built the container locally, you might need to publish it on ghcr.io/ibm/javacore-analyser. Here are the instructions: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry.
Steps:

  1. Generate the token by navigating to https://github.com/settings/tokens/new?scopes=write:packages.
    • Select the read:packages scope to download container images and read their metadata.
    • Select the write:packages scope to download and upload container images and read and write their metadata.
    • Select the delete:packages scope to delete container images.
      NOTE: you can use the same token for multiple pushes until it does not expire.
  2. Tag image:
    podman image tag localhost/javacore-analyser ghcr.io/ibm/javacore-analyser:latest
    podman image tag localhost/javacore-analyser ghcr.io/ibm/javacore-analyser:2.1
    
  3. Push the image:
    export CR_PAT=<token-id generated in step 1>
    echo $CR_PAT | podman login ghcr.io -u USERNAME --password-stdin  
    podman push ghcr.io/ibm/javacore-analyser:2.1
    podman push ghcr.io/ibm/javacore-analyser:latest
    

Build and Publish multiplatform image

To publish the image for multiple platforms, follow these instructions: https://developers.redhat.com/articles/2023/11/03/how-build-multi-architecture-container-images#benefits_of_multi_architecture_containers

<Generate token if you do not have it yet>
export CR_PAT=<token-id generated in step 1>
echo $CR_PAT | podman login ghcr.io -u USERNAME --password-stdin  
podman manifest create javacore-analyser:2.1
podman build --platform linux/amd64,linux/arm64,linux/i386  --manifest javacore-analyser:2.1  .
podman manifest push javacore-analyser:2.1 docker://ghcr.io/ibm/javacore-analyser:2.1
podman manifest push javacore-analyser:2.1 docker://ghcr.io/ibm/javacore-analyser:latest

Releasing a new version

Release a new version is partially automated by Travis. Here are the steps:

  1. Make sure you are on main branch in your repository.

  2. Create a new tag e.g:
    git tag 2.1

  3. Push the tag to Github:
    git push --tags
    alternatively you can perform this operation from Pycharm UI (Git -> Push -> Select Push Tags -> Click Push)

    Creating a new tag invokes a build operation which is doing the following:

    • The following code
      deploy:
      - provider: script
        #script: python -m twine upload --skip-existing --verbose --password $TWINE_TEST_TOKEN --repository testpypi dist/* #test instance
        script: python -m twine upload --skip-existing --verbose --password $TWINE_PROD_TOKEN dist/* #production instance.  
        on:  
        # all_branches: true # uncomment for testing purposes
          branch: prod # uncomment on production
          tags: true # We need to consider if we want to publish all versions or every build (which should not be an issue
      Is publishing pip package to pip repository. You are setting all passwords here: https://app.travis-ci.com/github/IBM/javacore-analyser/settings section Environmental Variables. TWINE_USERNAME should be set to token and TWINE_PROD_TOKEN or TWINE_TEST_TOKEN are the tokens set on pipy page (https://pypi.org/manage/account/token/ or https://test.pypi.org/manage/account/token/).
    • The following code:
       - provider: releases
         edge: true
         draft: true
         file: dist/*
         on:
           # all_branches: true # uncomment for testing purposes
           branch: prod # uncomment on production
           tags: true # We need to consider if we want to publish all versions or every build (which should not be an issue
      Generates the new Draft release on Github and adds distribution files (They are located in dist/*). This code requires setting GITHUB_TOKEN variable in https://app.travis-ci.com/github/IBM/javacore-analyser/settings. You can generate github token on https://github.com/settings/tokens/new
  4. Navigate in Github to the new Draft release page. You can easily find it on https://github.com/IBM/javacore-analyser/releases

  5. Click on Edit pen and then click on Generate release notes and edit them before saving.

  6. Publish release.

  7. Copy release notes to CHANGELOG.md file.

Testing

As default the tests in Pycharm are ran in the current selected directory. However we want to run them in main directory of the tool (javacore-analyser directory, not test directory).

  1. Right click on test directory in Project view and select Modify Run Configuration.... When the window appears, the Working Directory will be set to test directory. Change it to javacore-analyser directory
  2. Right click again on test and select Run or Debug.

Coding style guidelines

We use PEP 8 Python style for Python files.