<commit_before>#!/usr/bin/env python

# Copyright 2021 Google
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Fetch and print Github workflow matrix values for a given configuration.

This script holds the configurations (standard, expanded) for all of our
Github worklows and prints a string in the format that can be easily parsed
in Github workflows.

Design Notes:
- Desktop workflow is treated as the fallback option if there is no match.
  This also means that all workflows inherit the base set of keys and values from
  Desktop and optionally override them.
- There are 2 types of parameters - matrix and config. Matrix parameters are
  lists and generate jobs dynamically in Github workflows. Config parameters
  represent the additonal fine tuning parameters that can be used in workflow
  dispatch. They are always treated as strings.

Raises:
    ValueError: If the specific key is not found at all even after trying all
                the fallbacks.

Usage examples:
# Query value for matrix (default) parameter "os" for "desktop" (default) workflow.
python scripts/gha/print_matrix_configuration.py -k os

# Query value for matrix (default) parameter "os" for "android" workflow.
python scripts/gha/print_matrix_configuration.py -w android -k os

# Query value for expanded matrix (default) parameter "os" for "android" workflow.
python scripts/gha/print_matrix_configuration.py -w android -e 1 -k os

# Override the value for "os" for "integration_tests"
python scripts/gha/print_matrix_configuration.py -w integration_tests
        -o my_custom_os -k os

# Query value for config parameter "apis" for "integration_tests" workflow.
python scripts/gha/print_matrix_configuration.py -c -w integration_tests -k apis

# Override the value for config parameters "apis" for integration_tests
python scripts/gha/print_matrix_configuration.py -c -w integration_tests
        -o my_custom_api -k apis
"""

import argparse
import json
import os
import re
import subprocess
import sys

from integration_testing import config_reader

# Note that desktop is used for fallback,
# if there is no direct match for a key.
DEFAULT_WORKFLOW = "desktop"
EXPANDED_KEY = "expanded"

PARAMETERS = {
  "desktop": {
    "matrix": {
      "os": ["ubuntu-latest", "macos-latest"],
      "build_type": ["Release", "Debug"],
      "architecture": ["x64", "x86"],
      "msvc_runtime": ["static","dynamic"],
      "xcode_version": ["11.7"],
      "python_version": ["3.7"],

      EXPANDED_KEY: {
        "os": ["ubuntu-latest", "macos-latest", "windows-latest"],
        "xcode_version": ["11.7", "12.4"],
      }
    }
  },

  "android": {
    "matrix": {
      "os": ["ubuntu-latest", "macos-latest", "windows-latest"],
      "architecture": ["x64"],
      "python_version": ["3.7"],

      EXPANDED_KEY: {
        "os": ["ubuntu-latest", "macos-latest", "windows-latest"]
      }
    }
  },

  "integration_tests": {
    "matrix": {
      "os": ["ubuntu-latest", "macos-latest", "windows-latest"],
      "platform": ["Desktop", "Android", "iOS", "tvOS"],
      "ssl_lib": ["openssl"],
      "android_device": ["android_latest", "emulator_target"],
      "ios_device": ["ios_target", "simulator_target"],
      "tvos_device": ["tvos_simulator"],
      "build_type": ["Debug"],
      "architecture_windows_linux": ["x64"],
      "architecture_macos": ["x64"],
      "msvc_runtime": ["dynamic"],
      "cpp_compiler_windows": ["VisualStudio2019"],
      "cpp_compiler_linux": ["clang-11.0"],
      "xcode_version": ["12"],
      "ndk_version": ["r22b"],
      "platform_version": ["28"],
      "build_tools_version": ["28.0.3"],

      EXPANDED_KEY: {
        "ssl_lib": ["openssl", "boringssl"],
        "android_device": ["android_latest", "android_latest", "emulator_target", "emulator_latest", "emulator_32bit"],
        "ios_device": ["ios_min", "ios_target", "ios_latest", "simulator_min", "simulator_target", "simulator_latest"],
        "tvos_device": ["tvos_simulator"],
      }
    },
    "config": {
      "apis": "admob,analytics,auth,database,dynamic_links,firestore,functions,installations,messaging,remote_config,storage",
      "mobile_test_on": "real,virtual"
    }
  },

  "ios": {<commit_msg>Fix android test devices<commit_after>#!/usr/bin/env python

# Copyright 2021 Google
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Fetch and print Github workflow matrix values for a given configuration.

This script holds the configurations (standard, expanded) for all of our
Github worklows and prints a string in the format that can be easily parsed
in Github workflows.

Design Notes:
- Desktop workflow is treated as the fallback option if there is no match.
  This also means that all workflows inherit the base set of keys and values from
  Desktop and optionally override them.
- There are 2 types of parameters - matrix and config. Matrix parameters are
  lists and generate jobs dynamically in Github workflows. Config parameters
  represent the additonal fine tuning parameters that can be used in workflow
  dispatch. They are always treated as strings.

Raises:
    ValueError: If the specific key is not found at all even after trying all
                the fallbacks.

Usage examples:
# Query value for matrix (default) parameter "os" for "desktop" (default) workflow.
python scripts/gha/print_matrix_configuration.py -k os

# Query value for matrix (default) parameter "os" for "android" workflow.
python scripts/gha/print_matrix_configuration.py -w android -k os

# Query value for expanded matrix (default) parameter "os" for "android" workflow.
python scripts/gha/print_matrix_configuration.py -w android -e 1 -k os

# Override the value for "os" for "integration_tests"
python scripts/gha/print_matrix_configuration.py -w integration_tests
        -o my_custom_os -k os

# Query value for config parameter "apis" for "integration_tests" workflow.
python scripts/gha/print_matrix_configuration.py -c -w integration_tests -k apis

# Override the value for config parameters "apis" for integration_tests
python scripts/gha/print_matrix_configuration.py -c -w integration_tests
        -o my_custom_api -k apis
"""

import argparse
import json
import os
import re
import subprocess
import sys

from integration_testing import config_reader

# Note that desktop is used for fallback,
# if there is no direct match for a key.
DEFAULT_WORKFLOW = "desktop"
EXPANDED_KEY = "expanded"

PARAMETERS = {
  "desktop": {
    "matrix": {
      "os": ["ubuntu-latest", "macos-latest"],
      "build_type": ["Release", "Debug"],
      "architecture": ["x64", "x86"],
      "msvc_runtime": ["static","dynamic"],
      "xcode_version": ["11.7"],
      "python_version": ["3.7"],

      EXPANDED_KEY: {
        "os": ["ubuntu-latest", "macos-latest", "windows-latest"],
        "xcode_version": ["11.7", "12.4"],
      }
    }
  },

  "android": {
    "matrix": {
      "os": ["ubuntu-latest", "macos-latest", "windows-latest"],
      "architecture": ["x64"],
      "python_version": ["3.7"],

      EXPANDED_KEY: {
        "os": ["ubuntu-latest", "macos-latest", "windows-latest"]
      }
    }
  },

  "integration_tests": {
    "matrix": {
      "os": ["ubuntu-latest", "macos-latest", "windows-latest"],
      "platform": ["Desktop", "Android", "iOS", "tvOS"],
      "ssl_lib": ["openssl"],
      "android_device": ["android_target", "emulator_target"],
      "ios_device": ["ios_target", "simulator_target"],
      "tvos_device": ["tvos_simulator"],
      "build_type": ["Debug"],
      "architecture_windows_linux": ["x64"],
      "architecture_macos": ["x64"],
      "msvc_runtime": ["dynamic"],
      "cpp_compiler_windows": ["VisualStudio2019"],
      "cpp_compiler_linux": ["clang-11.0"],
      "xcode_version": ["12"],
      "ndk_version": ["r22b"],
      "platform_version": ["28"],
      "build_tools_version": ["28.0.3"],

      EXPANDED_KEY: {
        "ssl_lib": ["openssl", "boringssl"],
        "android_device": ["android_target", "android_latest", "emulator_target", "emulator_latest", "emulator_32bit"],
        "ios_device": ["ios_min", "ios_target", "ios_latest", "simulator_min", "simulator_target", "simulator_latest"],
        "tvos_device": ["tvos_simulator"],
      }
    },
    "config": {
      "apis": "admob,analytics,auth,database,dynamic_links,firestore,functions,installations,messaging,remote_config,storage",
      "mobile_test_on": "real,virtual"
    }
  },

  "ios": {
{'fraction_non_alphanumeric': 0.12578349091681718, 'fraction_numerical': 0.011048549877828535, 'mean_word_length': 3.847579814624099, 'pattern_counts': {'":': 84, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1202350', 'n_tokens_mistral': 2908, 'n_tokens_neox': 2759, 'n_words': 921}