This repository contains a GitHub Action that runs a Python script called release_helper
.
This GitHub Action is designed to automate the validation process of issues linked to a GitHub release. It ensures that all Linear tickets mentioned in the release notes are in a "completed" status before the release is marked as non-draft. If any tickets are not in a completed state, the action sends a Slack notification to the responsible users, prompting them to take action.
To use this action in your repository:
jobs:
run-release-helper:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Release Helper
uses: noviconnect/release-helper-action@v1
with:
github-token: "some-value"
linear-token: "some-value"
slack-bot-token: "some-value"
slack-channel-name: "some-value"
arg1
: The first argument passed to therelease_helper.py
script.
This action does not produce any outputs.
This project is licensed under the MIT License - see the LICENSE file for details.
- Install Poetry: https://python-poetry.org/docs/#installation
- Install dependencies:
poetry install
- Activate the virtual environment:
poetry shell
To run the release_helper, use the following command:
./taskfile.sh run
This command starts the Docker container and runs the main.py script. It will process any potential releases, check the status of related tickets, and send notifications as configured.
The taskfile.sh
script provides several other useful commands for development:
./taskfile.sh clean
: Removes the.cache
directory../taskfile.sh install
: Installs project dependencies using Poetry (for local development)../taskfile.sh generate-linear-client
: Generates the Linear API client using ariadne-codegen.
This GitHub Action operates as a composite action written in Python. It follows a sequence of steps to validate the status of Linear issues associated with a GitHub release. The action uses the following workflow:
-
Set Up Python Environment: The action begins by setting up a Python environment suitable for executing the script.
-
Fetch the Latest GitHub Release: The script retrieves the most recent GitHub release and extracts the release notes. These notes were originally drafted by a separate GitHub Action called "release drafter."
-
Scan for Linear Ticket References: The release notes are scanned for references to Linear tickets using a regular expression pattern. The pattern matches tickets in the form of a few letters, a dash, and a few numerical digits (e.g.,
ABC-123
). -
Query Linear API for Issue Status: For each identified Linear ticket, the script queries the Linear GraphQL API to retrieve the issue's status and associated team.
-
Check for Completed Status: Linear tickets have various status types, such as "completed," "in-progress," etc. The script verifies if all identified issues are in a "completed" status type. Examples of completed statuses include "Deployed," "Ready to Deploy," and "Done."
-
Determine Next Steps:
- If all issues are in a completed state, the script marks the GitHub release as non-draft. This triggers another GitHub Action to deploy the release to production.
- If any issue is not in a completed state, the script compiles a list of these issues and sends a notification to a Slack channel. The Slack message includes the issue details and mentions the responsible users. The users are identified by querying the Slack API using the email address associated with the Linear issue.
If you need to update the Linear API client:
- Modify the GraphQL schema or queries in
release_helper/issue_management/linear/queries.graphql
- Run
./taskfile.sh generate-linear-client
- The updated client will be generated in
release_helper/issue_management/linear/graphql_client/
Currently, there are no specific test commands defined in the taskfile. It's recommended to add unit tests and integration tests to ensure the reliability of the release_helper.
The project uses Ruff for linting and formatting. The configuration can be found in ruff.toml
. To run linting and formatting:
- Activate the virtual environment:
poetry shell
- Install Ruff:
pip install ruff
- Run linter:
ruff check .
- Run formatter:
ruff format .