diff --git a/.github/workflows/dockerfile_ci.yml b/.github/workflows/dockerfile_ci.yml deleted file mode 100644 index 10adcc1..0000000 --- a/.github/workflows/dockerfile_ci.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: Docker CI - -on: - schedule: - - cron: '15 21 * * *' - push: - branches: [ "main" ] - # Publish semver tags as releases. - tags: [ 'v*.*.*' ] - pull_request: - branches: [ "main" ] - -env: - # Use docker.io for Docker Hub if empty - REGISTRY: ghcr.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} - -jobs: - build_dockerfile: - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 #v3.9.2 - with: - cosign-release: 'v2.2.4' - - # Set up BuildKit Docker container builder to be able to build - # multi-platform images and export cache - # https://github.com/docker/setup-buildx-action - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 - - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - logout: true - - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable - TAGS: ${{ steps.meta.outputs.tags }} - DIGEST: ${{ steps.build-and-push.outputs.digest }} - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index e1c0523..0000000 --- a/Dockerfile +++ /dev/null @@ -1,41 +0,0 @@ -# Use a specific Ubuntu base image -FROM ubuntu:20.04 - -# Set environment variables to avoid interaction -ENV DEBIAN_FRONTEND=noninteractive \ - TZ=UTC - -# Install system dependencies and clean up -RUN apt-get update && \ - apt-get install -y \ - build-essential \ - gcc \ - g++ \ - gdb \ - libstdc++-10-dev \ - wget \ - python3 \ - python3-pip \ - git \ - tzdata && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -RUN python3 -m pip install --no-cache-dir meson ninja - -# Set environment variables -ENV CC=/usr/bin/gcc -ENV CXX=/usr/bin/g++ -ENV LD_LIBRARY_PATH=/usr/local/lib - -# Set the working directory -WORKDIR /usr/src/app - -# Copy the source code -COPY . . - -# Set the working directory -RUN meson setup -Dwith_test=enabled builddir -RUN meson compile -C builddir -RUN meson test -C builddir -RUN meson install -C builddir \ No newline at end of file diff --git a/code/logic/fossil/pizza/common.h b/code/logic/fossil/pizza/common.h index 9ea6560..69acabb 100644 --- a/code/logic/fossil/pizza/common.h +++ b/code/logic/fossil/pizza/common.h @@ -24,6 +24,19 @@ # define FOSSIL_PIZZA_API #endif +/* + * Objective-C / Objective-C++ includes guarded for Apple platforms + */ + +#if defined(__APPLE__) + #include + + // macOS, iOS, tvOS, watchOS + #if TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_TV || TARGET_OS_WATCH + #include + #endif +#endif // __APPLE__ + // C headers #include #include diff --git a/code/logic/meson.build b/code/logic/meson.build index aba84f0..6f1462c 100644 --- a/code/logic/meson.build +++ b/code/logic/meson.build @@ -7,12 +7,15 @@ fossil_test_lib = library('fossil_test', test_code, install: true, include_directories: dir, - dependencies: [cc.find_library('m', required: false) + dependencies: [ + cc.find_library('m', required: false), + apple_dep ] ) fossil_test_dep = declare_dependency( link_with: fossil_test_lib, + dependencies: [apple_dep], include_directories: dir ) diff --git a/code/meson.build b/code/meson.build index 09d4233..da49fe7 100644 --- a/code/meson.build +++ b/code/meson.build @@ -1,6 +1,10 @@ if host_machine.system() == 'darwin' add_languages('objc', native: false, required: true) add_languages('objcpp', native: false, required: true) + + apple_dep = dependency('appleframeworks', modules : ['Foundation']) +else + apple_dep = [] endif subdir('logic') diff --git a/code/tests/cases/test_sample.m b/code/tests/cases/test_sample.m index 0821a10..89da57d 100644 --- a/code/tests/cases/test_sample.m +++ b/code/tests/cases/test_sample.m @@ -13,90 +13,90 @@ * ----------------------------------------------------------------------------- */ +#import #include "fossil/pizza/framework.h" -// Test data structure for a sample test -FOSSIL_MOCK_STRUCT(ObjCSampleTestData) { - int input; - int expected_output; -} ObjCSampleTestData; +// ----------------------------------------------------------------------------- +// Objective-C Sample Test Data Class +// ----------------------------------------------------------------------------- +@interface ObjCSampleTestData : NSObject +@property(nonatomic, assign) int input; +@property(nonatomic, assign) int expected_output; +- (instancetype)initWithInput:(int)input expected:(int)expected; +@end -// Setup function for the test suite +@implementation ObjCSampleTestData +- (instancetype)initWithInput:(int)input expected:(int)expected { + self = [super init]; + if (self) { + _input = input; + _expected_output = expected; + } + return self; +} +@end + +// ----------------------------------------------------------------------------- +// Fossil Logic Test Suite Setup/Teardown +// ----------------------------------------------------------------------------- FOSSIL_SETUP(objc_sample_suite) { - // Setup code here + // Setup code for Objective-C tests } -// Teardown function for the test suite FOSSIL_TEARDOWN(objc_sample_suite) { - // Teardown code here + // Teardown code for Objective-C tests } -// Define the test suite and add test cases FOSSIL_SUITE(objc_sample_suite); -// A simple test case to check if input + 1 equals expected_output +// ----------------------------------------------------------------------------- +// Fossil Logic Test Cases (Objective-C flavored) +// ----------------------------------------------------------------------------- FOSSIL_TEST(objc_test_input_increment) { - ObjCSampleTestData data = {5, 6}; // Simplified initialization - + ObjCSampleTestData *data = [[ObjCSampleTestData alloc] initWithInput:5 expected:6]; int actual_output = data.input + 1; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Increment test failed"); } -// A simple test case to check if input - 1 equals expected_output FOSSIL_TEST(objc_test_input_decrement) { - ObjCSampleTestData data = {5, 4}; // Simplified initialization - + ObjCSampleTestData *data = [[ObjCSampleTestData alloc] initWithInput:5 expected:4]; int actual_output = data.input - 1; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Decrement test failed"); } -// A simple test case to check if input * 2 equals expected_output FOSSIL_TEST(objc_test_input_double) { - ObjCSampleTestData data = {5, 10}; // Simplified initialization - + ObjCSampleTestData *data = [[ObjCSampleTestData alloc] initWithInput:5 expected:10]; int actual_output = data.input * 2; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Double test failed"); } -// A simple test case to check if input / 2 equals expected_output FOSSIL_TEST(objc_test_input_half) { - ObjCSampleTestData data = {10, 5}; // Simplified initialization - + ObjCSampleTestData *data = [[ObjCSampleTestData alloc] initWithInput:10 expected:5]; int actual_output = data.input / 2; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Half test failed"); } -// A simple test case to check if input % 2 equals expected_output FOSSIL_TEST(objc_test_input_modulo) { - ObjCSampleTestData data = { 5, 1 }; - + ObjCSampleTestData *data = [[ObjCSampleTestData alloc] initWithInput:5 expected:1]; int actual_output = data.input % 2; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Modulo test failed"); } -// A simple test case to check if input squared equals expected_output FOSSIL_TEST(objc_test_input_square) { - ObjCSampleTestData data = { 3, 9 }; - + ObjCSampleTestData *data = [[ObjCSampleTestData alloc] initWithInput:3 expected:9]; int actual_output = data.input * data.input; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Square test failed"); } -// A simple test case to check if input is equal to expected_output FOSSIL_TEST(objc_test_input_equal) { - ObjCSampleTestData data = { 7, 7 }; - + ObjCSampleTestData *data = [[ObjCSampleTestData alloc] initWithInput:7 expected:7]; int actual_output = data.input; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Equality test failed"); } +// ----------------------------------------------------------------------------- +// Grouping Tests +// ----------------------------------------------------------------------------- FOSSIL_TEST_GROUP(objc_sample_test_cases) { FOSSIL_TEST_ADD(objc_sample_suite, objc_test_input_increment); FOSSIL_TEST_ADD(objc_sample_suite, objc_test_input_decrement); diff --git a/code/tests/cases/test_sample.mm b/code/tests/cases/test_sample.mm index 00a517f..dc4dc66 100644 --- a/code/tests/cases/test_sample.mm +++ b/code/tests/cases/test_sample.mm @@ -12,91 +12,101 @@ * Copyright (C) 2014-2025 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ - +#import #include "fossil/pizza/framework.h" -// Test data structure for a sample test +// ----------------------------------------------------------------------------- +// C struct (still supported in ObjC++) +// ----------------------------------------------------------------------------- FOSSIL_MOCK_STRUCT(ObjCppSampleTestData) { int input; int expected_output; }; -// Setup function for the test suite +// ----------------------------------------------------------------------------- +// C++ helper (available in Objective-C++) +// ----------------------------------------------------------------------------- +class ObjCppHelper { +public: + static int square(int x) { return x * x; } + static int half(int x) { return x / 2; } +}; + +// ----------------------------------------------------------------------------- +// Objective-C wrapper class +// ----------------------------------------------------------------------------- +@interface ObjCppWrapper : NSObject +- (BOOL)checkValue:(int)input equals:(int)expected; +@end + +@implementation ObjCppWrapper +- (BOOL)checkValue:(int)input equals:(int)expected { + return input == expected; +} +@end + +// ----------------------------------------------------------------------------- +// Fossil Logic Test Suite Setup/Teardown +// ----------------------------------------------------------------------------- FOSSIL_SETUP(objcpp_sample_suite) { - // Setup code here + // Setup for ObjC++ tests } -// Teardown function for the test suite FOSSIL_TEARDOWN(objcpp_sample_suite) { - // Teardown code here + // Teardown for ObjC++ tests } -// Define the test suite and add test cases FOSSIL_SUITE(objcpp_sample_suite); -// A simple test case to check if input + 1 equals expected_output +// ----------------------------------------------------------------------------- +// Fossil Logic Test Cases +// ----------------------------------------------------------------------------- FOSSIL_TEST(objcpp_test_input_increment) { - ObjCppSampleTestData data = {5, 6}; // Simplified initialization - + ObjCppSampleTestData data = {5, 6}; int actual_output = data.input + 1; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Increment test failed"); } -// A simple test case to check if input - 1 equals expected_output FOSSIL_TEST(objcpp_test_input_decrement) { - ObjCppSampleTestData data = {5, 4}; // Simplified initialization - + ObjCppSampleTestData data = {5, 4}; int actual_output = data.input - 1; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Decrement test failed"); } -// A simple test case to check if input * 2 equals expected_output FOSSIL_TEST(objcpp_test_input_double) { - ObjCppSampleTestData data = {5, 10}; // Simplified initialization - + ObjCppSampleTestData data = {5, 10}; int actual_output = data.input * 2; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Double test failed"); } -// A simple test case to check if input / 2 equals expected_output FOSSIL_TEST(objcpp_test_input_half) { - ObjCppSampleTestData data = {10, 5}; // Simplified initialization - - int actual_output = data.input / 2; - + ObjCppSampleTestData data = {10, 5}; + int actual_output = ObjCppHelper::half(data.input); // Using C++ helper FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Half test failed"); } -// A simple test case to check if input % 2 equals expected_output FOSSIL_TEST(objcpp_test_input_modulo) { - ObjCppSampleTestData data = { 5, 1 }; - + ObjCppSampleTestData data = {5, 1}; int actual_output = data.input % 2; - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Modulo test failed"); } -// A simple test case to check if input squared equals expected_output FOSSIL_TEST(objcpp_test_input_square) { - ObjCppSampleTestData data = { 3, 9 }; - - int actual_output = data.input * data.input; - + ObjCppSampleTestData data = {3, 9}; + int actual_output = ObjCppHelper::square(data.input); // Using C++ helper FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Square test failed"); } -// A simple test case to check if input is equal to expected_output FOSSIL_TEST(objcpp_test_input_equal) { - ObjCppSampleTestData data = { 7, 7 }; - - int actual_output = data.input; - - FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Equality test failed"); + ObjCppSampleTestData data = {7, 7}; + ObjCppWrapper *checker = [[ObjCppWrapper alloc] init]; + BOOL success = [checker checkValue:data.input equals:data.expected_output]; + FOSSIL_TEST_ASSUME(success, "Equality test failed"); } +// ----------------------------------------------------------------------------- +// Grouping Tests +// ----------------------------------------------------------------------------- FOSSIL_TEST_GROUP(objcpp_sample_test_cases) { FOSSIL_TEST_ADD(objcpp_sample_suite, objcpp_test_input_increment); FOSSIL_TEST_ADD(objcpp_sample_suite, objcpp_test_input_decrement);