Skip to content

AbsaOSS/release-notes-presence-check

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Release Notes Presence Checker

A GH action for validating the presence of release notes in pull requests.

Motivation

This action is designed to help maintainers and contributors ensure that release notes are present in pull requests. It can be used to prevent common issues such as:

  • Missing release notes
  • Incomplete release notes
  • Incorrect release note formats
  • Release notes in the wrong location

Requirements

  • GitHub Token: A GitHub token with permission to fetch repository data such as Issues and Pull Requests.
  • Python 3.11+: Ensure you have Python 3.11 installed on your system.

Inputs

GITHUB_TOKEN

  • Description: Your GitHub token for authentication. Store it as a secret and reference it in the workflow file as secrets.GITHUB_TOKEN.
  • Required: Yes

pr-number

  • Description: The pull request number to check for release notes. Example: 1.
  • Required: Yes

github-repository

  • Description: The GitHub repository to check for version tags. Example: AbsaOSS/release-notes-presence-check.
  • Required: Yes

location

  • Description: The location of the release notes in the pull request.
  • Required: No
  • Default: body

title

  • Description: The title of the release notes in the pull request. Example without regex: Release Notes:, with regex: [Rr]elease [Nn]otes:.
  • Required: No
  • Default: [Rr]elease [Nn]otes:

skip-labels

  • Description: The labels to skip the release notes check. Example: skip-release-notes.
  • Required: No
  • Default: ``

fails-on-error

  • Description: Whether the action should fail if an error occurs.
  • Required: No
  • Default: true

Outputs

valid

  • Description: Whether the release notes are present.
  • Value: true or false

Usage

Adding the Action to Your Workflow

See the default action step definition:

- uses: actions/setup-python@v5.1.1
  with:
    python-version: '3.11'

- name: Release Notes Presence Check
  id: release_notes_presence_check
  uses: AbsaOSS/release-notes-presence-check@v0.1.0
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
  with:
    github-repository: "{ org }/{ repo }"
    pr-numer: 109
    location: "body"
    title: "[Rr]elease [Nn]otes:"
    skip-labels: "skip-release-notes,no-release-notes"
    fails-on-error: "false"

Running Static Code Analysis

This project uses Pylint tool for static code analysis. Pylint analyses your code without actually running it. It checks for errors, enforces, coding standards, looks for code smells etc.

Pylint displays a global evaluation score for the code, rated out of a maximum score of 10.0. We are aiming to keep our code quality high above the score 9.5.

Set Up Python Environment

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

This command will also install a Pylint tool, since it is listed in the project requirements.

Run Pylint

Run Pylint on all files that are currently tracked by Git in the project.

pylint $(git ls-files '*.py')

To run Pylint on a specific file, follow the pattern pylint <path_to_file>/<name_of_file>.py.

Example:

pylint ./release_notes_presence_check/release_notes_presence_check_action.py

Run Black Tool Locally

This project uses the Black tool for code formatting. Black aims for consistency, generality, readability and reducing git diffs. The coding style used can be viewed as a strict subset of PEP 8.

The project root file pyproject.toml defines the Black tool configuration. In this project we are accepting the line length of 120 characters.

Follow these steps to format your code with Black locally:

Set Up Python Environment

From terminal in the root of the project, run the following command:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

This command will also install a Black tool, since it is listed in the project requirements.

Run Black

Run Black on all files that are currently tracked by Git in the project.

black $(git ls-files '*.py')

To run Black on a specific file, follow the pattern black <path_to_file>/<name_of_file>.py.

Example:

black ./release_notes_presence_check/release_notes_presence_check_action.py

Expected Output

This is the console expected output example after running the tool:

All done! ✨ 🍰 ✨
1 file reformatted.

Running Unit Test

Unit tests are written using pytest. To run the tests, use the following command:

pytest tests/

This will execute all tests located in the tests directory.

Code Coverage

Code coverage is collected using pytest-cov coverage tool. To run the tests and collect coverage information, use the following command:

pytest --cov=. -v tests/ --cov-fail-under=80

This will execute all tests located in the tests directory and generate a code coverage report.

See the coverage report on the path:

open htmlcov/index.html

Run Action Locally

Create *.sh file and place it in the project root.

#!/bin/bash

# Ensure that Python virtual environment is activated
if [ ! -d ".venv" ]; then
  echo "Python virtual environment not found. Creating one..."
  python3 -m venv .venv
fi

source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Check if GITHUB_TOKEN is set
if [ -z "$GITHUB_TOKEN" ]; then
  echo "Error: GITHUB_TOKEN environment variable is not set."
  exit 1
fi

# Set necessary environment variables
export INPUT_GITHUB_TOKEN="$GITHUB_TOKEN"
export INPUT_PR_NUMBER=109
export INPUT_GITHUB_REPOSITORY="AbsaOSS/generate-release-notes"
export INPUT_LOCATION="body"
export INPUT_TITLE="[Rr]elease notes:"
export INPUT_SKIP_LABELS="skip-release-notes,another-skip-label"
export INPUT_FAILS_ON_ERROR="true"
export GITHUB_OUTPUT="output.txt"   # File to capture outputs

# Remove existing output file if it exists
if [ -f "$GITHUB_OUTPUT" ]; then
  rm "$GITHUB_OUTPUT"
fi

# Run the main script
python main.py

# Display the outputs
echo "Action Outputs:"
cat "$GITHUB_OUTPUT"

Contribution Guidelines

We welcome contributions to the Version Tag Check Action! Whether you're fixing bugs, improving documentation, or proposing new features, your help is appreciated.

How to Contribute

  • Submit Pull Requests: Feel free to fork the repository, make changes, and submit a pull request. Please ensure your code adheres to the existing style and all tests pass.
  • Report Issues: If you encounter any bugs or issues, please report them via the repository's Issues page.
  • Suggest Enhancements: Have ideas on how to make this action better? Open an issue to suggest enhancements.

Before contributing, please review our contribution guidelines for more detailed information.

License Information

This project is licensed under the Apache License 2.0. It is a liberal license that allows you great freedom in using, modifying, and distributing this software, while also providing an express grant of patent rights from contributors to users.

For more details, see the LICENSE file in the repository.

Contact or Support Information

If you need help with using or contributing to Generate Release Notes Action, or if you have any questions or feedback, don't hesitate to reach out:

About

A GH action for validating presence of release notes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages