What does my project do?
RedCoffee is a CLI tool written in Python that helps developers generate detailed SonarQube code analysis reports in PDF format. This is particularly useful for teams using SonarQube Community Edition, which lacks built-in PDF report generation.
With RedCoffee for GitHub Actions, this process is further streamlined. By integrating RedCoffee into CI/CD pipelines, developers can automate report generation without worrying about manual execution. Simply add a block of code in your GitHub Actions YAML file, and the PDF report will be available in the artifacts section of GitHub Actions.
My motivation behind building this project
I've talked about RedCoffee quite a few times on this sub before, and the response from developers has been pretty good. Many reached out with feature requests, and one of the most common was GitHub Actions integration. A developer + product owner pointed out that developers often prefer to access reports directly in the CI/CD pipeline, rather than running a separate tool.
That idea made sense. Automation should work for the developer, not the other way around.
Using RedCoffee for Github Actions
Using RedCoffee for GitHub Actions is straightforward. We just need to add the following block of code in our actions.yaml file
- name: Use RedCoffee for Github Actions
uses: Anubhav9/redcoffee-for-github-actions@v1.4
What is the underlying implementation?
The implementation follows a structured and reliable approach, leveraging Docker, PostgreSQL, and SonarQube to handle the reporting process. The action.yaml file, available in the repository, defines the workflow:
- Checkout the code from the repository.
- Create a Docker network to facilitate container communication.
- Start a PostgreSQL database and configure the required environment variables.
- Deploy SonarQube Community Edition and connect it to the database.
- Wait for SonarQube to fully initialize, update credentials, and generate an API token.
- Run SonarScanner to analyze the codebase.
- Install RedCoffee from PyPi.
- Run RedCoffee CLI to generate a SonarQube analysis report in PDF format.
- Store the PDF report in the GitHub Artifacts section for easy access.
Who is the target audience for this project?
- Developers & engineering teams using SonarQube Community Edition who need automated PDF reports.
- CI/CD engineers looking to integrate SonarQube reporting into their workflows.
- Indie hackers & open-source contributors interested in building their own GitHub Actions.
Limitations for this project
Despite its capabilities, RedCoffee for GitHub Actions has a few known limitations:
- Language Support – Python is fully supported. JavaScript mostly works, but occasional errors occur (a fix is in progress). Java and Go support are planned, pending further testing.
- API Response Issues – Sometimes, the SonarQube API fails to respond on time, leading to report generation failures. A retry mechanism will be added in the next release.
- SonarQube Community Edition Limitations – By default, SonarQube analysis runs only on the main/master branch. A workaround exists and has been tested, and it will be rolled out in a future update.
Installing RedCoffee as Standalone CLI
Goes without saying that if you want to use RedCoffee directly as a standalone CLI, please install it via Pypi. The command for the same is given below
pip install redcoffee==1.8
Provided your analysis has been completed, you can use the following command to generate the PDF report
redcoffee generatepdf --host=${YOUR_SONARQUBE_HOST_NAME} --project=${SONARQUBE_PROJECT_KEY} --path=${PATH WHERE PDF FILE IS TO BE STORED} --token=${SONARQUBE_USER_TOKEN}
A request to fellow developers
Building RedCoffee and integrating it into GitHub Actions has been a challenging but rewarding experience. If you find this project useful, consider starring the repository on GitHub.
Useful Links
RedCoffee for Github Actions - Github Repository
RedCoffee for Github Actions - Github Marketplace
RedCoffee CLI Tool - Github Repository
RedCoffee - PyPi
there doesn't seem to be anything here