Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added format support to the changelog mode #56

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Additional arguments:

| CLI | Action input | Default |
| --------------------- | ------------------- | ------- |
| --format | format | yaml |
Copy link

@jbergstroem jbergstroem Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think default should be the same as cli (text)

| --include-path-params | include-path-params | false |
| --exclude-elements | exclude-elements | '' |
| --composed | composed | false |
Expand Down
5 changes: 5 additions & 0 deletions changelog/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ inputs:
revision:
description: 'Path of revised OpenAPI spec in YAML or JSON format'
required: true
format:
description: 'Output format'
required: false
default: 'yaml'
include-path-params:
description: 'Include path parameter names in endpoint matching'
required: false
Expand All @@ -32,6 +36,7 @@ runs:
args:
- ${{ inputs.base }}
- ${{ inputs.revision }}
- ${{ inputs.format }}
- ${{ inputs.include-path-params }}
- ${{ inputs.exclude-elements }}
- ${{ inputs.composed }}
Expand Down
12 changes: 8 additions & 4 deletions changelog/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ write_output () {

readonly base="$1"
readonly revision="$2"
readonly include_path_params="$3"
readonly exclude_elements="$4"
readonly composed="$5"
readonly output_to_file="$6"
readonly format="$3"
readonly include_path_params="$4"
readonly exclude_elements="$5"
readonly composed="$6"
readonly output_to_file="$7"

echo "running oasdiff changelog base: $base, revision: $revision, include_path_params: $include_path_params, exclude_elements: $exclude_elements, composed: $composed, output_to_file: $output_to_file"

# Build flags to pass in command
flags=""
if [ "$format" != "yaml" ]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would validate format here. I was actually about to open a PR that achieves the same where I did something like:

validate_format() {
  local -a output_formats=(githubactions html json junit markup singleline text yaml)
  for f in "${output_formats[@]}"; do
    [[ "${f}" == "${1}" ]] && return 0
  done
  return 1
}

validate_format $format || { echo "Invalid format: ${format}" >&2; exit 1; }

flags="$flags --format $format"
fi
if [ "$include_path_params" = "true" ]; then
flags="$flags --include-path-params"
fi
Expand Down