Skip to content

test pr

test pr #11

name: Validate Exporter JSON Changes
on:
pull_request:
paths:
- '**/exporter*.json'
jobs:
validate_exporter_json:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Fetch Base and Head References
run: |
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
git fetch origin ${{ github.head_ref }}:${{ github.head_ref }}
- name: Validate JSON Changes
run: |
changed_files=$(git diff --name-only ${{ github.base_ref }} ${{ github.head_ref }} | grep 'exporter.*\.json$')
if [ -z "$changed_files" ]; then
echo "No exporter JSON files have changed."
exit 0
fi
# Loop through each changed file
for file in $changed_files; do
# Fetch the base and head versions of the file
base_file=$(git show ${{ github.base_ref }}:$file)
head_file=$(git show ${{ github.head_ref }}:$file)
# Compare the JSON keys
base_keys=$(echo "$base_file" | jq -r 'paths | map(tostring) | join(".")')
head_keys=$(echo "$head_file" | jq -r 'paths | map(tostring) | join(".")')
# Check for removed keys
removed_keys=$(comm -23 <(echo "$base_keys" | sort) <(echo "$head_keys" | sort))
if [ -n "$removed_keys" ]; then
echo "Backward incompatibility change detected in $file. The following keys were removed:"
echo "$removed_keys"
exit 1
fi
done
echo "All exporter JSON files have only additions. No backward incompatibility changes detected."
shell: bash