Skip to content

Commit

Permalink
Adding Github Action (#47)
Browse files Browse the repository at this point in the history
* Adding initial Action

* Fixing id

* Using GITHUB_ENV instead

* Running the action

* Trying again

* switching to node20

* Using docker

* updating sha

* switching to composite

* updating sha

* updating action

* updating sha

* updating sha

* updating action

* updating sha

* updating action

* updating sha

* updating sha

* tmp disabled workflows + added cancelling

* fixing output

* wrapping markdown output into a string

* passing the filepath as output

* Adding output test

* fixing format

* mhh

* actually fixing yml format

* fixing typo

* Removing plist

* experimenting

* using DIFF_OUTPUT_FILEPATH

* trying out some things

* moving the commenting to the action

* actually executing the diff

* reactivated workflows

* updating action

* Renamed workflows

* trying to get the last version of the action in the detection script

* using right branch name

* switching back to the github-action branch

* fixing typo

---------

Co-authored-by: Alex Guretzki <[email protected]>
  • Loading branch information
goergisn and Alex Guretzki authored Nov 15, 2024
1 parent b53ac33 commit 61afba0
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 25 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/cancel-duplicate-workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 🧹 Cancel duplicate work flows

on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
cancel-multiple-workflow-runs:
name: "Cancel the self CI workflow run"
runs-on: ubuntu-latest
steps:
- name: "Cancel 'detect-api-changes'"
uses: potiuk/cancel-workflow-runs@master
with:
cancelMode: allDuplicates
cancelFutureDuplicates: true
token: ${{ secrets.GITHUB_TOKEN }}
workflowFileName: detect-api.changes.yml
- name: "Cancel 'build-release'"
uses: potiuk/cancel-workflow-runs@master
with:
cancelMode: allDuplicates
cancelFutureDuplicates: true
token: ${{ secrets.GITHUB_TOKEN }}
workflowFileName: build-release.yml
- name: "Cancel 'run-tests'"
uses: potiuk/cancel-workflow-runs@master
with:
cancelMode: allDuplicates
cancelFutureDuplicates: true
token: ${{ secrets.GITHUB_TOKEN }}
workflowFileName: run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on:
required: true

jobs:

build:
runs-on: macos-14 # Apple Silicon Runner

Expand All @@ -27,17 +26,14 @@ jobs:
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'

- name: 🚚 Fetch repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🔍 Detect Changes

- name: 👾 Define Diff Versions
run: |
PROJECT_FOLDER=$PWD
echo $PROJECT_FOLDER
NEW="${{ env.source }}~${{ env.githubRepo }}"
if [[ '${{ github.head_ref || env.noTargetBranch }}' == 'release/*' ]]
then
Expand All @@ -47,19 +43,22 @@ jobs:
OLD="${{ env.target }}~${{ env.githubRepo }}"
fi
swift run public-api-diff project --new "$NEW" --old "$OLD" --platform macos --output "$PROJECT_FOLDER/api_comparison.md" --log-level debug --log-output "$PROJECT_FOLDER/logs.txt"
cat "$PROJECT_FOLDER/logs.txt"
cat "$PROJECT_FOLDER/api_comparison.md" >> $GITHUB_STEP_SUMMARY
echo "OLD=$OLD"
echo "NEW=$NEW"
# Providing the output to the environment
echo "OLD_VERSION=$OLD" >> $GITHUB_ENV
echo "NEW_VERSION=$NEW" >> $GITHUB_ENV
env:
source: '${{ github.event.inputs.new || github.head_ref }}'
target: '${{ github.event.inputs.old || github.event.pull_request.base.ref }}'
githubRepo: '${{github.server_url}}/${{github.repository}}.git'
noTargetBranch: 'no target branch'
- if: ${{ github.event.pull_request.base.ref != '' }}
name: 📝 Comment on PR
uses: thollander/actions-comment-pull-request@v3

- name: 🔍 Detect Changes
uses: Adyen/adyen-swift-public-api-diff@github-action
id: public_api_diff
with:
file-path: "${{ github.workspace }}/api_comparison.md"
comment-tag: api_changes
mode: recreate
platform: "macOS"
new: ${{ env.NEW_VERSION }}
old: ${{ env.OLD_VERSION }}
8 changes: 0 additions & 8 deletions Info.plist

This file was deleted.

39 changes: 39 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Swift Public API Diff'
description: 'This tool allows comparing 2 versions of a swift (sdk) project and lists all changes in a human readable way. And outputs it to the step summary or PR comment.'
inputs:
platform:
description: 'The platform to build the project for (iOS/macOS)'
required: true
new:
description: 'Specify the updated version to compare to'
required: true
old:
description: 'Specify the old version to compare to'
required: true
runs:
using: 'composite'
steps:
- name: "Run Diff"
run: |
NEW=${{ inputs.new }}
OLD=${{ inputs.old }}
PLATFORM=${{ inputs.platform }}
PROJECT_FOLDER=$PWD
echo $PROJECT_FOLDER
swift run public-api-diff project --new "$NEW" --old "$OLD" --platform "$PLATFORM" --output "$PROJECT_FOLDER/api_comparison.md" --log-output "$PROJECT_FOLDER/logs.txt"
cat "$PROJECT_FOLDER/logs.txt"
cat "$PROJECT_FOLDER/api_comparison.md" >> $GITHUB_STEP_SUMMARY
shell: bash

- if: ${{ github.event.pull_request.base.ref != '' }}
name: 📝 Comment on PR
uses: thollander/actions-comment-pull-request@v3
with:
file-path: "${{ github.workspace }}/api_comparison.md"
comment-tag: api_changes
mode: recreate



0 comments on commit 61afba0

Please sign in to comment.