diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..35e4b20d5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Code Quality Check / Perform Unit Testing + +on: + pull_request: + +concurrency: + # New commit on branch cancels running workflows of the same branch + group: ${{ github.workflow }}-${{ github.head_ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: macos-latest + environment: sdds + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: 'latest' + + - name: Run build script + run: | + chmod +x ./scripts/build.sh + ./scripts/build.sh + diff --git a/SDDSCore/SDDSCore.xcodeproj/project.pbxproj b/SDDSCore/SDDSCore.xcodeproj/project.pbxproj index 5c7feb012..ee7ea460a 100644 --- a/SDDSCore/SDDSCore.xcodeproj/project.pbxproj +++ b/SDDSCore/SDDSCore.xcodeproj/project.pbxproj @@ -207,7 +207,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"${SRCROOT}/../lint.sh\"\n"; + shellScript = "if [ \"$SKIP_LINT\" == \"YES\" ]; then\n echo \"Skipping Lint...\"\n exit 0\nfi\n\n/bin/sh \"${SRCROOT}/../lint.sh\"\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/SDDSDemoApp/SDDSDemoApp.xcodeproj/project.pbxproj b/SDDSDemoApp/SDDSDemoApp.xcodeproj/project.pbxproj index 5f9a257b1..9d4b14539 100644 --- a/SDDSDemoApp/SDDSDemoApp.xcodeproj/project.pbxproj +++ b/SDDSDemoApp/SDDSDemoApp.xcodeproj/project.pbxproj @@ -316,7 +316,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"${SRCROOT}/../lint.sh\"\n"; + shellScript = "if [ \"$SKIP_LINT\" == \"YES\" ]; then\n echo \"Skipping Lint...\"\n exit 0\nfi\n\n/bin/sh \"${SRCROOT}/../lint.sh\"\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/SDDSIcons/SDDSIcons.xcodeproj/project.pbxproj b/SDDSIcons/SDDSIcons.xcodeproj/project.pbxproj index 06922c2d4..1ce4dc747 100644 --- a/SDDSIcons/SDDSIcons.xcodeproj/project.pbxproj +++ b/SDDSIcons/SDDSIcons.xcodeproj/project.pbxproj @@ -207,7 +207,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"${SRCROOT}/../lint.sh\"\n"; + shellScript = "if [ \"$SKIP_LINT\" == \"YES\" ]; then\n echo \"Skipping Lint...\"\n exit 0\nfi\n\n/bin/sh \"${SRCROOT}/../lint.sh\"\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/SDDSSwiftUI/SDDSSwiftUI.xcodeproj/project.pbxproj b/SDDSSwiftUI/SDDSSwiftUI.xcodeproj/project.pbxproj index 504be000a..8a66c0819 100644 --- a/SDDSSwiftUI/SDDSSwiftUI.xcodeproj/project.pbxproj +++ b/SDDSSwiftUI/SDDSSwiftUI.xcodeproj/project.pbxproj @@ -207,7 +207,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"${SRCROOT}/../lint.sh\"\n"; + shellScript = "if [ \"$SKIP_LINT\" == \"YES\" ]; then\n echo \"Skipping Lint...\"\n exit 0\nfi\n\n/bin/sh \"${SRCROOT}/../lint.sh\"\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/SDDSUIKit/SDDSUIKit.xcodeproj/project.pbxproj b/SDDSUIKit/SDDSUIKit.xcodeproj/project.pbxproj index 71ee85668..6f175553c 100644 --- a/SDDSUIKit/SDDSUIKit.xcodeproj/project.pbxproj +++ b/SDDSUIKit/SDDSUIKit.xcodeproj/project.pbxproj @@ -207,7 +207,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"${SRCROOT}/../lint.sh\"\n"; + shellScript = "if [ \"$SKIP_LINT\" == \"YES\" ]; then\n echo \"Skipping Lint...\"\n exit 0\nfi\n\n/bin/sh \"${SRCROOT}/../lint.sh\"\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100644 index 000000000..0903f9ea9 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,32 @@ +#!/bin/bash +source "$(dirname "$0")/pretty_echo.sh" + +PROJECT_ROOT_DIR="$(dirname "$0")/.." +PROJECT_ROOT_DIR=$(cd "$PROJECT_ROOT_DIR" && pwd) +print_info "Root directory is ${PROJECT_ROOT_DIR}" + +WORKSPACE_NAME="SDDS.xcworkspace" +WORKSPACE_PATH="${PROJECT_ROOT_DIR}/${WORKSPACE_NAME}" +print_info "XCWorkspace path is ${PROJECT_ROOT_DIR}" + +modules=("SDDSSwiftUI" "SDDSUIKit" "SDDSIcons" "SDDSCore") + +print_info "Running tests for all targets..." +for MODULE in "${!modules[@]}"; do + SCHEME=${modules[$MODULE]} + XCODE_PROJECT_PATH="${PROJECT_ROOT_DIR}/${SCHEME}/${SCHEME}.xcodeproj" + + print_info "Running tests for the scheme $SCHEME" + + SKIP_LINT=YES xcodebuild -scheme ${SCHEME} -workspace ${WORKSPACE_PATH} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Pro Max' test + + if [ $? -ne 0 ]; then + print_error "Tests failed for the scheme $SCHEME." + exit 1 + else + print_success "Tests succeeded for the scheme $SCHEME" + fi + +done + +print_success "All tests succeeded"