Skip to content

Commit

Permalink
Add CI check
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Dec 5, 2023
1 parent 3adc23c commit ccaa738
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: macos-13
name: Test Library
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Select Xcode 15.0.1
run: sudo xcode-select -s /Applications/Xcode_15.0.1.app
- name: Run tests
Expand All @@ -28,9 +28,21 @@ jobs:
runs-on: macos-13
name: Build Examples
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Select Xcode 15.0.1
run: sudo xcode-select -s /Applications/Xcode_15.0.1.app
- name: Build examples
run: make build-examples

check-breaking-changes:
runs-on: macos-13
name: Check for Breaking API Changes
steps:
- uses: actions/checkout@v4
- name: Select Xcode 15.0.1
run: sudo xcode-select -s /Applications/Xcode_15.0.1.app
- run: |
BASELINE_TREEISH=${{ github.base_ref }} \
BASELINE_REPO_URL=${{ github.server_url }}/${{ github.repository }} \
./scripts/check-for-breaking-api-changes.sh
42 changes: 42 additions & 0 deletions scripts/check-for-breaking-api-changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
##===----------------------------------------------------------------------===##
##
## This source file is part of the SwiftOpenAPIGenerator open source project
##
## Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.txt for the list of SwiftOpenAPIGenerator project authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##

set -euo pipefail

log() { printf -- "** %s\n" "$*" >&2; }
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
fatal() { error "$@"; exit 1; }

CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPO_ROOT="$(git -C "${CURRENT_SCRIPT_DIR}" rev-parse --show-toplevel)"

log "Checking required environment variables..."
test -n "${BASELINE_REPO_URL:-}" || fatal "BASELINE_REPO_URL unset"
test -n "${BASELINE_TREEISH:-}" || fatal "BASELINE_TREEISH unset"

log "Fetching baseline: ${BASELINE_REPO_URL}#${BASELINE_TREEISH}..."
git -C "${REPO_ROOT}" fetch "${BASELINE_REPO_URL}" "${BASELINE_TREEISH}"
BASELINE_COMMIT=$(git -C "${REPO_ROOT}" rev-parse FETCH_HEAD)

log "Checking for API changes since ${BASELINE_REPO_URL}#${BASELINE_TREEISH} (${BASELINE_COMMIT})..."
swift package --package-path "${REPO_ROOT}" diagnose-api-breaking-changes \
"${BASELINE_COMMIT}" \
&& RC=$? || RC=$?

if [ "${RC}" -ne 0 ]; then
fatal "❌ Breaking API changes detected."
exit "${RC}"
fi
log "✅ No breaking API changes detected."

0 comments on commit ccaa738

Please sign in to comment.