Skip to content

Commit

Permalink
Check platform compatibility as well on macOS (#33)
Browse files Browse the repository at this point in the history
* Check platform compatibility as well on macOS

* Update run-unit-tests.yml

* Update action.yml

* Update action.yml

* Update action.yml

* Update run-unit-tests.yml

* Update action.yml

* Update .github/actions/check-compatible-swift/action.yml

Co-authored-by: Gwynne Raskind <[email protected]>

---------

Co-authored-by: Gwynne Raskind <[email protected]>
  • Loading branch information
MahdiBM and gwynne authored Oct 23, 2024
1 parent 8a558c5 commit 24f2d7a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions .github/actions/check-compatible-swift/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: check-compatible-swift
description: >
Determines whether the default Swift toolchain presently available is new enough to
Determines whether the default Swift toolchain and platform version presently available is new enough to
satisfy the minimum Swift version required by the package in the current directory.
inputs:
Expand All @@ -18,7 +18,7 @@ outputs:
runs:
using: composite
steps:
- name: Compare package's Swift version to installed
- name: Compare package's Swift and platform versions to the installed
id: swift-version-check
env:
PACKAGE_ROOT: ${{ inputs.package_root != '' && format('--package-path={0}', inputs.package_root) || '' }}
Expand All @@ -29,11 +29,24 @@ runs:
local minor="$(echo $1 | cut -d . -f 2)"; \
local patch="$(echo $1 | cut -d . -f 3)"; \
\
echo $(( ${major} * 10000 + ${minor} * 100 + ${patch} )); \
echo $(( ${major} * 10000 + ${minor:-0} * 100 + ${patch:-0} )); \
}
toolchain_version=$(parse_version $(swift package --version | cut -c31-))
package_version=$(parse_version $(swift package ${PACKAGE_ROOT} tools-version))
is_compatible=$((( ${package_version} <= ${toolchain_version} )) && echo true || echo false)
echo "ok=${is_compatible}" >>"${GITHUB_OUTPUT}"
swift_is_compatible=$((( ${package_version} <= ${toolchain_version} )) && echo true || echo false)
if [[ "$(uname)" == "Darwin" ]]; then
platform_version=$(parse_version $(swift package dump-package | jq -r '.platforms[] | select(.platformName == "macos") | .version'))
if [[ "${platform_version}" == "null" || -z "${platform_version}" ]]; then
platform_is_compatible=true
else
current_platform=$(parse_version $(sw_vers -productVersion))
platform_is_compatible=$((( ${platform_version} <= ${current_platform} )) && echo true || echo false)
fi
else
platform_is_compatible=true
fi
echo "ok=$([[ "${swift_is_compatible}" == true && "${platform_is_compatible}" == true ]] && echo true || echo false)" >> "${GITHUB_OUTPUT}"

0 comments on commit 24f2d7a

Please sign in to comment.