-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: setup danger to prevent merging PRs that update SPM files but not…
… cocoapods Renovatebot auto-updates Package.swift file but not podspec files. Therefore, if renovatebot opens a PR that updates Package.swift files, let's also make sure to update coaopod files, too. commit-id:64069015
- Loading branch information
1 parent
3b04feb
commit ba83e16
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
on: [pull_request] | ||
|
||
permissions: | ||
pull-requests: write # Write access needed to create a comment. | ||
|
||
jobs: | ||
# Danger is a tool that can help during code reviews. Automate common | ||
# code review tasks. https://danger.systems/js/ | ||
# TL;DR - it runs script `dangerfile.js` on each pull request. | ||
danger: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run danger | ||
run: npx danger@11 ci --dangerfile dangerfile.js | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// The SDK is deployed to multiple dependency management softwares (Cocoapods and Swift Package Manager). | ||
// This code tries to prevent forgetting to update metadata files for one but not the other. | ||
let isSPMFilesModified = danger.git.modified_files.includes('Package.swift') | ||
let isCococapodsFilesModified = danger.git.modified_files.filter((filePath) => filePath.endsWith('.podspec')).length > 0 | ||
|
||
console.log(`SPM files modified: ${isSPMFilesModified}, CocoaPods: ${isCococapodsFilesModified}`) | ||
|
||
if (isSPMFilesModified || isCococapodsFilesModified) { | ||
if (!isSPMFilesModified) { warn("Cocoapods files (*.podspec) were modified but Swift Package Manager files (Package.*) files were not. This is error-prone when updating dependencies in one service but not the other. Double-check that you updated all of the correct files.") } | ||
if (!isCococapodsFilesModified) { warn("Swift Package Manager files (Package.*) were modified but Cocoapods files (*.podspec) files were not. This is error-prone when updating dependencies in one service but not the other. Double-check that you updated all of the correct files.") } | ||
} |