Skip to content

Commit

Permalink
tooling: updating the data api differ tooling to pass in the source d…
Browse files Browse the repository at this point in the history
…ata type
  • Loading branch information
tombuildsstuff committed Feb 13, 2024
1 parent 96c06cc commit 181db79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/automation-data-api-differ.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Detect changes to the API Definitions
name: Detect changes to the API Definitions (Resource Manager)
on:
pull_request:
types: ['opened', 'synchronize']
Expand All @@ -26,19 +26,19 @@ jobs:

- name: Detect Changes
run: |
./scripts/automation-determine-changes-to-api-definitions.sh outputs/
./scripts/automation-determine-changes-to-api-definitions.sh resource-manager outputs/
- name: Post Comment containing Breaking Changes
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 # v2.4.3
with:
filePath: outputs/breaking-changes.md
filePath: outputs/resource-manager-breaking-changes.md

- name: Post Comment containing Changes
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 # v2.4.3
with:
filePath: outputs/changes.md
filePath: outputs/resource-manager-changes.md

- name: Post Comment with New Static Identifiers
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 # v2.4.3
with:
filePath: outputs/static-identifiers.md
filePath: outputs/resource-manager-static-identifiers.md
26 changes: 15 additions & 11 deletions scripts/automation-determine-changes-to-api-definitions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,43 +69,47 @@ function ensureDirectoryExists {
function runBreakingChangeDetector {
local initialApiDefinitionsDirectory="$1"
local updatedApiDefinitionsDirectory="$2"
local outputFilePath="$3"
local sourceDataType="$3"
local outputFilePath="$4"

echo "Detecting Breaking Changes between ${initialApiDefinitionsDirectory} and ${updatedApiDefinitionsDirectory}.."
data-api-differ detect-breaking-changes --initial-path="${initialApiDefinitionsDirectory}" --updated-path="${updatedApiDefinitionsDirectory}" --output-file-path="${outputFilePath}"
data-api-differ "${sourceDataType}" detect-breaking-changes --initial-path="${initialApiDefinitionsDirectory}" --updated-path="${updatedApiDefinitionsDirectory}" --output-file-path="${outputFilePath}"
}

function runChangeDetector {
local initialApiDefinitionsDirectory="$1"
local updatedApiDefinitionsDirectory="$2"
local outputFilePath="$3"
local sourceDataType="$3"
local outputFilePath="$4"

echo "Detecting Changes between ${initialApiDefinitionsDirectory} and ${updatedApiDefinitionsDirectory}.."
data-api-differ detect-changes --initial-path="${initialApiDefinitionsDirectory}" --updated-path="${updatedApiDefinitionsDirectory}" --output-file-path="${outputFilePath}"
data-api-differ "${sourceDataType}" detect-changes --initial-path="${initialApiDefinitionsDirectory}" --updated-path="${updatedApiDefinitionsDirectory}" --output-file-path="${outputFilePath}"
}

function runStaticIdentifierDetector {
local initialApiDefinitionsDirectory="$1"
local updatedApiDefinitionsDirectory="$2"
local outputFilePath="$3"
local sourceDataType="$3"
local outputFilePath="$4"

echo "Detecting any new Static Identifiers between ${initialApiDefinitionsDirectory} and ${updatedApiDefinitionsDirectory}.."
data-api-differ output-resource-id-segments --initial-path="${initialApiDefinitionsDirectory}" --updated-path="${updatedApiDefinitionsDirectory}" --output-file-path="${outputFilePath}"
data-api-differ "${sourceDataType}" output-resource-id-segments --initial-path="${initialApiDefinitionsDirectory}" --updated-path="${updatedApiDefinitionsDirectory}" --output-file-path="${outputFilePath}"
}

function main {
local tempDirectory="./pandora-from-main"
local initialApiDefinitionsDirectory="${tempDirectory}/api-definitions"
local updatedApiDefinitionsDirectory="${DIR}/api-definitions"
local outputDirectory="$1"
local sourceDataType="$1"
local outputDirectory="$2"

buildAndInstallDependencies
checkoutAPIDefinitionsFromMainInto "$tempDirectory"
ensureDirectoryExists "$outputDirectory"

runBreakingChangeDetector "$initialApiDefinitionsDirectory" "$updatedApiDefinitionsDirectory" "${outputDirectory}/breaking-changes.md"
runChangeDetector "$initialApiDefinitionsDirectory" "$updatedApiDefinitionsDirectory" "${outputDirectory}/changes.md"
runStaticIdentifierDetector "$initialApiDefinitionsDirectory" "$updatedApiDefinitionsDirectory" "${outputDirectory}/static-identifiers.md"
runBreakingChangeDetector "$initialApiDefinitionsDirectory" "$updatedApiDefinitionsDirectory" "$sourceDataType" "${outputDirectory}/resource-manager-breaking-changes.md"
runChangeDetector "$initialApiDefinitionsDirectory" "$updatedApiDefinitionsDirectory" "$sourceDataType" "${outputDirectory}/resource-manager-changes.md"
runStaticIdentifierDetector "$initialApiDefinitionsDirectory" "$updatedApiDefinitionsDirectory" "$sourceDataType" "${outputDirectory}/resource-manager-static-identifiers.md"
}

main "$1"
main "$1" "$2"

0 comments on commit 181db79

Please sign in to comment.