diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3ba8cd76..20fad9c3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,6 +10,9 @@ on: jobs: API-diff: + strategy: + matrix: + module: ["ConfidenceProvider", "Confidence"] runs-on: macOS-latest steps: - name: install sourcekitten @@ -20,7 +23,7 @@ jobs: with: ssh-private-key: ${{ secrets.SDK_REPO_PRIVATE_KEY }} - name: Run public API diff - run: scripts/api_diff.sh + run: scripts/api_diff.sh ${{ matrix.module }} Tests: runs-on: macOS-latest diff --git a/api/ConfidenceProvider_public_api.json b/api/ConfidenceProvider_public_api.json new file mode 100644 index 00000000..ec00367a --- /dev/null +++ b/api/ConfidenceProvider_public_api.json @@ -0,0 +1,43 @@ +[ + { + "className": "ConfidenceFeatureProvider", + "apiFunctions": [ + { + "name": "init(confidence:initializationStrategy:)", + "declaration": "public convenience init(confidence: Confidence, initializationStrategy: InitializationStrategy = .fetchAndActivate)" + }, + { + "name": "initialize(initialContext:)", + "declaration": "public func initialize(initialContext: OpenFeature.EvaluationContext?)" + }, + { + "name": "onContextSet(oldContext:newContext:)", + "declaration": "public func onContextSet(\n oldContext: OpenFeature.EvaluationContext?,\n newContext: OpenFeature.EvaluationContext\n)" + }, + { + "name": "getBooleanEvaluation(key:defaultValue:context:)", + "declaration": "public func getBooleanEvaluation(key: String, defaultValue: Bool, context: EvaluationContext?) throws\n-> OpenFeature.ProviderEvaluation" + }, + { + "name": "getStringEvaluation(key:defaultValue:context:)", + "declaration": "public func getStringEvaluation(key: String, defaultValue: String, context: EvaluationContext?) throws\n-> OpenFeature.ProviderEvaluation" + }, + { + "name": "getIntegerEvaluation(key:defaultValue:context:)", + "declaration": "public func getIntegerEvaluation(key: String, defaultValue: Int64, context: EvaluationContext?) throws\n-> OpenFeature.ProviderEvaluation" + }, + { + "name": "getDoubleEvaluation(key:defaultValue:context:)", + "declaration": "public func getDoubleEvaluation(key: String, defaultValue: Double, context: EvaluationContext?) throws\n-> OpenFeature.ProviderEvaluation" + }, + { + "name": "getObjectEvaluation(key:defaultValue:context:)", + "declaration": "public func getObjectEvaluation(key: String, defaultValue: OpenFeature.Value, context: EvaluationContext?)\nthrows -> OpenFeature.ProviderEvaluation" + }, + { + "name": "observe()", + "declaration": "public func observe() -> AnyPublisher" + } + ] + } +] \ No newline at end of file diff --git a/api/public_api.json b/api/Confidence_public_api.json similarity index 100% rename from api/public_api.json rename to api/Confidence_public_api.json diff --git a/scripts/api_diff.sh b/scripts/api_diff.sh index 74f42d74..29e35953 100755 --- a/scripts/api_diff.sh +++ b/scripts/api_diff.sh @@ -5,19 +5,26 @@ set -e script_dir=$(dirname $0) root_dir="$script_dir/../" +# exit if param is not supplied +if [ -z "$1" ]; then + echo "Please provide the module name as a parameter." + exit 1 +fi +MODULE=$1 + # Generate the json file with: -sourcekitten doc --module-name Confidence -- -scheme Confidence-Package -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' > $script_dir/raw_api.json +sourcekitten doc --module-name ${MODULE} -- -scheme Confidence-Package -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' > $script_dir/${MODULE}_raw_api.json # Extract the public API from the raw api json file -python3 $script_dir/extract_public_funcs.py $script_dir/raw_api.json $script_dir/current_public_api.json +python3 $script_dir/extract_public_funcs.py $script_dir/${MODULE}_raw_api.json $script_dir/${MODULE}_current_public_api.json # Clean up the raw api json file -rm $script_dir/raw_api.json +rm $script_dir/${MODULE}_raw_api.json # Compare the public API with the previous public API and exit with 1 if there are changes echo "Comparing genereated public API with previous public API" set +e -git diff --no-index --exit-code $root_dir/api/public_api.json $script_dir/current_public_api.json +git diff --no-index --exit-code $root_dir/api/${MODULE}_public_api.json $script_dir/${MODULE}_current_public_api.json # Capture the exit code of the git diff command diff_exit_code=$? set -e @@ -36,7 +43,7 @@ If the changes are unintended, please investigate the changes and update the sou fi # Clean up the current public api json file -rm $script_dir/current_public_api.json +rm $script_dir/${MODULE}_current_public_api.json # Exit with the diff's exit code to maintain the intended behavior exit $diff_exit_code \ No newline at end of file diff --git a/scripts/generate_public_api.sh b/scripts/generate_public_api.sh index 5308952a..e584adc9 100755 --- a/scripts/generate_public_api.sh +++ b/scripts/generate_public_api.sh @@ -5,11 +5,18 @@ set -e script_dir=$(dirname $0) root_dir="$script_dir/../" +# exit if param is not supplied +if [ -z "$1" ]; then + echo "Please provide the module name as a parameter." + exit 1 +fi +MODULE=$1 + # Generate the json file with: -sourcekitten doc --module-name Confidence -- -scheme Confidence-Package -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' > $script_dir/raw_api.json +sourcekitten doc --module-name ${MODULE} -- -scheme Confidence-Package -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' > $script_dir/${MODULE}_raw_api.json # Extract the public API from the raw api json file -python3 $script_dir/extract_public_funcs.py $script_dir/raw_api.json $root_dir/api/public_api.json +python3 $script_dir/extract_public_funcs.py $script_dir/${MODULE}_raw_api.json $root_dir/api/${MODULE}_public_api.json # Clean up the raw api json file -rm $script_dir/raw_api.json \ No newline at end of file +rm $script_dir/${MODULE}_raw_api.json \ No newline at end of file