<commit_before># Copyright (c) 2020-2021 Project CHIP Authors
#
# 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.

name: Builds

on:
    push:
    pull_request:
    workflow_dispatch:

concurrency:
    group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
    cancel-in-progress: true

jobs:
    build_linux_gcc_debug:
        name: Build on Linux (gcc_debug)
        timeout-minutes: 65

        runs-on: ubuntu-latest
        if: github.actor != 'restyled-io[bot]'

        container:
            image: connectedhomeip/chip-build:0.5.56
            volumes:
                - "/tmp/log_output:/tmp/test_logs"
            options: --sysctl "net.ipv6.conf.all.disable_ipv6=0
                net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"

        steps:
            - name: Dump GitHub context
              env:
                  GITHUB_CONTEXT: ${{ toJSON(github) }}
              run: echo "$GITHUB_CONTEXT"
            - name: Dump Concurrency context
              env:
                  CONCURRENCY_CONTEXT: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
              run: echo "$CONCURRENCY_CONTEXT"
            - uses: Wandalen/wretry.action@v1.0.11
              name: Checkout
              with:
                  action: actions/checkout@v3
                  with: |
                      submodules: true
                      token: ${{ github.token }}
                  attempt_limit: 3
                  attempt_delay: 2000
            - name: Bootstrap
              timeout-minutes: 10
              run: scripts/build/gn_bootstrap.sh
            - name: Uploading bootstrap logs
              uses: actions/upload-artifact@v2
              if: ${{ always() }} && ${{ !env.ACT }}
              with:
                  name: bootstrap-logs
                  path: |
                      .environment/gn_out/.ninja_log
                      .environment/pigweed-venv/*.log
            - name: Setup Build
              run: scripts/build/gn_gen.sh --args="chip_config_memory_debug_checks=true chip_config_memory_debug_dmalloc=true"
            - name: Run Build
              timeout-minutes: 20
              run: scripts/run_in_build_env.sh "ninja -C ./out"
            - name: Run Tests
              timeout-minutes: 15
              run: scripts/tests/gn_tests.sh
            # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
            # TODO https://github.com/project-chip/connectedhomeip/issues/1512
            # - name: Run Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: scripts/tools/codecoverage.sh
            # - name: Upload Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: bash <(curl -s https://codecov.io/bash)
            - name: Setup Build Without Detail Logging
              run: scripts/build/gn_gen.sh --args="chip_detail_logging=false"
            - name: Run Build Without Detail Logging
              timeout-minutes: 20
              run: scripts/run_in_build_env.sh "ninja -C ./out"
            - name: Setup Build Without Progress Logging
              run: scripts/build/gn_gen.sh --args="chip_detail_logging=false chip_progress_logging=false"
            - name: Run Build Without Progress Logging
              timeout-minutes: 20
              run: scripts/run_in_build_env.sh "ninja -C ./out"
            - name: Setup Build Without Error Logging
              run: scripts/build/gn_gen.sh --args="chip_detail_logging=false chip_progress_logging=false chip_error_logging=false"
            - name: Run Build Without Error Logging
              timeout-minutes: 20
              run: scripts/run_in_build_env.sh "ninja -C ./out"
    build_linux:
        name: Build on Linux (fake, gcc_release, clang, simulated)
        timeout-minutes: 120

        runs-on: ubuntu-latest
        if: github.actor != 'restyled-io[bot]'

        container:
            image: connectedhomeip/chip-build:0.5.56
            volumes:
                - "/tmp/log_output:/tmp/test_logs"
            options: --sysctl "net.ipv6.conf.all.disable_ipv6=0
                net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"

        steps:
            - name: Dump GitHub context
              env:
                  GITHUB_CONTEXT: ${{ toJSON(github) }}
              run: echo "$GITHUB_CONTEXT"
            - name: Dump Concurrency context
              env:
                  CONCURRENCY_CONTEXT: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
              run: echo "$CONCURRENCY_CONTEXT"
            - uses: Wandalen/wretry.action@v1.0.11
              name: Checkout
              with:
                  action: actions/checkout@v3
                  with: |
                      submodules: true
                      token: ${{ github.token }}
                  attempt_limit: 3
                  attempt_delay: 2000
            # - name: Initialize CodeQL
            #   if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
            #   uses: github/codeql-action/init@v1
            #   with:
            #      languages: "cpp"
            - name: Bootstrap
              timeout-minutes: 10
              run: scripts/build/gn_bootstrap.sh
            - name: Uploading bootstrap logs
              uses: actions/upload-artifact@v2
              if: ${{ always() }} && ${{ !env.ACT }}
              with:
                  name: bootstrap-logs
                  path: |
                      .environment/gn_out/.ninja_log
                      .environment/pigweed-venv/*.log
            - name: Setup and Build Simulated Device
              timeout-minutes: 20
              run: |
                  BUILD_TYPE=simulated
                  GN_ARGS='chip_tests_zap_config="app1" chip_project_config_include_dirs=["../../examples/placeholder/linux/apps/app1/include", "../../config/standalone"] chip_config_network_layer_ble=false'
                  CHIP_ROOT_PATH=examples/placeholder/linux
                  CHIP_ROOT_PATH="$CHIP_ROOT_PATH" BUILD_TYPE="$BUILD_TYPE" scripts/build/gn_gen.sh --args="$GN_ARGS"
                  scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
            - name: Setup Build, Run Build and Run Tests
              timeout-minutes: 90
              run: |
                  for BUILD_TYPE  in gcc_release clang; do
                      case $BUILD_TYPE in
                          "gcc_release") GN_ARGS='is_debug=false';;
                          "clang") GN_ARGS='is_clang=true';;
                      esac

                      BUILD_TYPE=$BUILD_TYPE scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands
                      scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
                      BUILD_TYPE=$BUILD_TYPE scripts/tests/gn_tests.sh
                  done
            - name: Clang-tidy validation
              timeout-minutes: 45
              run: |
                  ./scripts/run_in_build_env.sh \
                    "./scripts/run-clang-tidy-on-compile-commands.py \
                       --no-log-timestamps \
                       --compile-database out/clang/compile_commands.json \
                       check \
                    "
            - name: Run Tests with sanitizers
              timeout-minutes: 30
              env:
                  LSAN_OPTIONS: detect_leaks=0
              run: |
                  # for BUILD_TYPE in asan msan tsan ubsan; do
                    for BUILD_TYPE in asan tsan ubsan; do
                        case $BUILD_TYPE in
                            "asan") GN_ARGS='is_clang=true is_asan=true';;
                            "msan") GN_ARGS='is_clang=true is_msan=true';;
                            "tsan") GN_ARGS='is_clang=true is_tsan=true chip_enable_wifi=false';;
                            "ubsan") GN_ARGS='is_clang=true is_ubsan=true';;
                        esac

                        scripts/build/gn_gen.sh --args="$GN_ARGS"
                        scripts/tests/gn_tests.sh
                    done
            - name: Build using build_examples.py
              timeout-minutes: 40
              run: |
                  ./scripts/run_in_build_env.sh \
                    "./scripts/build/build_examples.py --no-log-timestamps \
                       --target linux-x64-all-clusters-ipv6only-clang \
                       --target linux-x64-chip-tool-ipv6only-clang \
                       --target linux-x64-minmdns-ipv6only-clang \
                       --target linux-x64-rpc-console \
                       build \
                    "
            - name: Run fake linux tests with build_examples
              timeout-minutes: 15
              run: |
                  ./scripts/run_in_build_env.sh \
                    "./scripts/build/build_examples.py --no-log-timestamps --target linux-fake-tests build"

            # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
            # TODO https://github.com/project-chip/connectedhomeip/issues/1512
            # - name: Run Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: scripts/tools/codecoverage.sh
            # - name: Upload Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: bash <(curl -s https://codecov.io/bash)
            # - name: Remove third_party binaries for CodeQL Analysis
            #   run: find out -type d -name "third_party" -exec rm -rf {} +
            # - name: Remove dbus binaries for CodeQL Analysis
            #   run: find out -type d -name "dbus" -exec rm -rf {} +
            # - name: Remove nrfxlib binaries for CodeQL Analysis
            #   run: find . -type d -name "nrfxlib" -exec rm -rf {} +
            # - name: Perform CodeQL Analysis
            #   if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
            #   uses: github/codeql-action/analyze@v1
    build_linux_python_lib:
        name: Build on Linux (python_lib)
        timeout-minutes: 60

        runs-on: ubuntu-latest
        if: github.actor != 'restyled-io[bot]'

        container:
            image: connectedhomeip/chip-build:0.5.56
            volumes:
                - "/tmp/log_output:/tmp/test_logs"
            options: --sysctl "net.ipv6.conf.all.disable_ipv6=0
                net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"

        steps:
            - name: Dump GitHub context
              env:
                  GITHUB_CONTEXT: ${{ toJSON(github) }}
              run: echo "$GITHUB_CONTEXT"
            - name: Dump Concurrency context
              env:
                  CONCURRENCY_CONTEXT: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
              run: echo "$CONCURRENCY_CONTEXT"
            - uses: Wandalen/wretry.action@v1.0.11
              name: Checkout
              with:
                  action: actions/checkout@v3
                  with: |
                      submodules: true
                      token: ${{ github.token }}
                  attempt_limit: 3
                  attempt_delay: 2000
            - name: Bootstrap
              timeout-minutes: 10
              run: scripts/build/gn_bootstrap.sh
            - name: Setup Build, Run Build and Run Tests
              timeout-minutes: 50
              run: |
                  scripts/build/gn_gen.sh --args="enable_rtti=true enable_pylib=true chip_config_memory_debug_checks=false chip_config_memory_debug_dmalloc=false"
                  scripts/run_in_build_env.sh "ninja -C ./out"
                  scripts/tests/gn_tests.sh
            - name: Run Python library specific unit tests
              timeout-minutes: 5
              run: |
                  scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip-0.0-cp37-abi3-linux_x86_64.whl'
                  scripts/run_in_build_env.sh '(cd src/controller/python/test/unit_tests/ && python3 -m unittest -v)'

    build_darwin:
        name: Build on Darwin (clang, python_lib, simulated)
        timeout-minutes: 200
        runs-on: macos-latest
        if: github.actor != 'restyled-io[bot]'

        steps:
            - uses: Wandalen/wretry.action@v1.0.11
              name: Checkout
              with:
                  action: actions/checkout@v3
                  with: |
                      submodules: true
                      token: ${{ github.token }}
                  attempt_limit: 3
                  attempt_delay: 2000
            #- name: Initialize CodeQL
            #  if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
            #  uses: github/codeql-action/init@v1
            #  with:
            #     languages: "cpp"
            - name: Setup Environment
              run: brew install openssl pkg-config
            - name: Try to ensure the directory for diagnostic log collection exists
              run: |
                  mkdir -p ~/Library/Logs/DiagnosticReports || true
            - name: Fix pkgconfig link
              working-directory: /usr/local/lib/pkgconfig
              run: |
                  pwd
                  ls -la /usr/local/Cellar/
                  ls -la /usr/local/Cellar/openssl@1.1
                  OPEN_SSL_VERSION=`ls -la /usr/local/Cellar/openssl@1.1 | cat | tail -n1 | awk '{print $NF}'`
                  ln -s /usr/local/Cellar/openssl@1.1/$OPEN_SSL_VERSION/lib/pkgconfig/* .
            - name: Bootstrap
              timeout-minutes: 25
              run: scripts/build/gn_bootstrap.sh
            - name: Uploading bootstrap logs
              uses: actions/upload-artifact@v2
              if: ${{ always() }} && ${{ !env.ACT }}
              with:
                  name: bootstrap-logs
                  path: |
                      .environment/gn_out/.ninja_log
                      .environment/pigweed-venv/*.log
            - name: Setup and Build Simulated Device
              timeout-minutes: 20
              run: |
                  BUILD_TYPE=simulated
                  GN_ARGS='chip_tests_zap_config="app1" chip_project_config_include_dirs=["../../examples/placeholder/linux/apps/app1/include", "../../config/standalone"] chip_config_network_layer_ble=false'
                  CHIP_ROOT_PATH=examples/placeholder/linux
                  CHIP_ROOT_PATH="$CHIP_ROOT_PATH" BUILD_TYPE="$BUILD_TYPE" scripts/build/gn_gen.sh --args="$GN_ARGS"
                  scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
            - name: Setup Build, Run Build and Run Tests
              timeout-minutes: 120
              run: |
                  for BUILD_TYPE in default python_lib; do
                      case $BUILD_TYPE in
                          # We want to build various standalone example apps
                          # (similar to what examples-linux-standalone.yaml
                          # does), so use target_os="all" to get those picked
                          # up as part of the "unified" build.  But then to
                          # save CI resources we want to exclude a few
                          # redundant things:
                          #
                          # * the mbedtls build, since we don't really plan to
                          #   use that on Darwin.
                          # * the "host clang" build, which uses the pigweed
                          #   clang.
                          "default") GN_ARGS='target_os="all" is_asan=true enable_host_clang_build=false enable_host_gcc_mbedtls_build=false';;
                          "python_lib") GN_ARGS='enable_rtti=true enable_pylib=true';;
                      esac
                      BUILD_TYPE=$BUILD_TYPE scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands
                      scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
                      BUILD_TYPE=$BUILD_TYPE scripts/tests/gn_tests.sh
                  done
            - name: Clang-tidy validation
              timeout-minutes: 45
              run: |
                  ./scripts/run_in_build_env.sh \
                    "./scripts/run-clang-tidy-on-compile-commands.py \
                       --no-log-timestamps \
                       --compile-database out/default/compile_commands.json \
                       check \
                    "
            - name: Uploading diagnostic logs
              uses: actions/upload-artifact@v2
              if: ${{ failure() }} && ${{ !env.ACT }}
              with:
                  name: crash-log-darwin
                  path: ~/Library/Logs/DiagnosticReports/
            # - name: Perform CodeQL Analysis
            #   if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
            #   uses: github/codeql-action/analyze@v1
            # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
            # TODO https://github.com/project-chip/connectedhomeip/issues/1512
            # - name: Run Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: scripts/tools/codecoverage.sh
            # - name: Upload Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: bash <(curl -s https://codecov.io/bash)
<commit_msg>Bump linux RunTests time limit to 30 min from 15 (#17216)<commit_after># Copyright (c) 2020-2021 Project CHIP Authors
#
# 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.

name: Builds

on:
    push:
    pull_request:
    workflow_dispatch:

concurrency:
    group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
    cancel-in-progress: true

jobs:
    build_linux_gcc_debug:
        name: Build on Linux (gcc_debug)
        timeout-minutes: 65

        runs-on: ubuntu-latest
        if: github.actor != 'restyled-io[bot]'

        container:
            image: connectedhomeip/chip-build:0.5.56
            volumes:
                - "/tmp/log_output:/tmp/test_logs"
            options: --sysctl "net.ipv6.conf.all.disable_ipv6=0
                net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"

        steps:
            - name: Dump GitHub context
              env:
                  GITHUB_CONTEXT: ${{ toJSON(github) }}
              run: echo "$GITHUB_CONTEXT"
            - name: Dump Concurrency context
              env:
                  CONCURRENCY_CONTEXT: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
              run: echo "$CONCURRENCY_CONTEXT"
            - uses: Wandalen/wretry.action@v1.0.11
              name: Checkout
              with:
                  action: actions/checkout@v3
                  with: |
                      submodules: true
                      token: ${{ github.token }}
                  attempt_limit: 3
                  attempt_delay: 2000
            - name: Bootstrap
              timeout-minutes: 10
              run: scripts/build/gn_bootstrap.sh
            - name: Uploading bootstrap logs
              uses: actions/upload-artifact@v2
              if: ${{ always() }} && ${{ !env.ACT }}
              with:
                  name: bootstrap-logs
                  path: |
                      .environment/gn_out/.ninja_log
                      .environment/pigweed-venv/*.log
            - name: Setup Build
              run: scripts/build/gn_gen.sh --args="chip_config_memory_debug_checks=true chip_config_memory_debug_dmalloc=true"
            - name: Run Build
              timeout-minutes: 20
              run: scripts/run_in_build_env.sh "ninja -C ./out"
            - name: Run Tests
              timeout-minutes: 30
              run: scripts/tests/gn_tests.sh
            # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
            # TODO https://github.com/project-chip/connectedhomeip/issues/1512
            # - name: Run Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: scripts/tools/codecoverage.sh
            # - name: Upload Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: bash <(curl -s https://codecov.io/bash)
            - name: Setup Build Without Detail Logging
              run: scripts/build/gn_gen.sh --args="chip_detail_logging=false"
            - name: Run Build Without Detail Logging
              timeout-minutes: 20
              run: scripts/run_in_build_env.sh "ninja -C ./out"
            - name: Setup Build Without Progress Logging
              run: scripts/build/gn_gen.sh --args="chip_detail_logging=false chip_progress_logging=false"
            - name: Run Build Without Progress Logging
              timeout-minutes: 20
              run: scripts/run_in_build_env.sh "ninja -C ./out"
            - name: Setup Build Without Error Logging
              run: scripts/build/gn_gen.sh --args="chip_detail_logging=false chip_progress_logging=false chip_error_logging=false"
            - name: Run Build Without Error Logging
              timeout-minutes: 20
              run: scripts/run_in_build_env.sh "ninja -C ./out"
    build_linux:
        name: Build on Linux (fake, gcc_release, clang, simulated)
        timeout-minutes: 120

        runs-on: ubuntu-latest
        if: github.actor != 'restyled-io[bot]'

        container:
            image: connectedhomeip/chip-build:0.5.56
            volumes:
                - "/tmp/log_output:/tmp/test_logs"
            options: --sysctl "net.ipv6.conf.all.disable_ipv6=0
                net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"

        steps:
            - name: Dump GitHub context
              env:
                  GITHUB_CONTEXT: ${{ toJSON(github) }}
              run: echo "$GITHUB_CONTEXT"
            - name: Dump Concurrency context
              env:
                  CONCURRENCY_CONTEXT: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
              run: echo "$CONCURRENCY_CONTEXT"
            - uses: Wandalen/wretry.action@v1.0.11
              name: Checkout
              with:
                  action: actions/checkout@v3
                  with: |
                      submodules: true
                      token: ${{ github.token }}
                  attempt_limit: 3
                  attempt_delay: 2000
            # - name: Initialize CodeQL
            #   if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
            #   uses: github/codeql-action/init@v1
            #   with:
            #      languages: "cpp"
            - name: Bootstrap
              timeout-minutes: 10
              run: scripts/build/gn_bootstrap.sh
            - name: Uploading bootstrap logs
              uses: actions/upload-artifact@v2
              if: ${{ always() }} && ${{ !env.ACT }}
              with:
                  name: bootstrap-logs
                  path: |
                      .environment/gn_out/.ninja_log
                      .environment/pigweed-venv/*.log
            - name: Setup and Build Simulated Device
              timeout-minutes: 20
              run: |
                  BUILD_TYPE=simulated
                  GN_ARGS='chip_tests_zap_config="app1" chip_project_config_include_dirs=["../../examples/placeholder/linux/apps/app1/include", "../../config/standalone"] chip_config_network_layer_ble=false'
                  CHIP_ROOT_PATH=examples/placeholder/linux
                  CHIP_ROOT_PATH="$CHIP_ROOT_PATH" BUILD_TYPE="$BUILD_TYPE" scripts/build/gn_gen.sh --args="$GN_ARGS"
                  scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
            - name: Setup Build, Run Build and Run Tests
              timeout-minutes: 90
              run: |
                  for BUILD_TYPE  in gcc_release clang; do
                      case $BUILD_TYPE in
                          "gcc_release") GN_ARGS='is_debug=false';;
                          "clang") GN_ARGS='is_clang=true';;
                      esac

                      BUILD_TYPE=$BUILD_TYPE scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands
                      scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
                      BUILD_TYPE=$BUILD_TYPE scripts/tests/gn_tests.sh
                  done
            - name: Clang-tidy validation
              timeout-minutes: 45
              run: |
                  ./scripts/run_in_build_env.sh \
                    "./scripts/run-clang-tidy-on-compile-commands.py \
                       --no-log-timestamps \
                       --compile-database out/clang/compile_commands.json \
                       check \
                    "
            - name: Run Tests with sanitizers
              timeout-minutes: 30
              env:
                  LSAN_OPTIONS: detect_leaks=0
              run: |
                  # for BUILD_TYPE in asan msan tsan ubsan; do
                    for BUILD_TYPE in asan tsan ubsan; do
                        case $BUILD_TYPE in
                            "asan") GN_ARGS='is_clang=true is_asan=true';;
                            "msan") GN_ARGS='is_clang=true is_msan=true';;
                            "tsan") GN_ARGS='is_clang=true is_tsan=true chip_enable_wifi=false';;
                            "ubsan") GN_ARGS='is_clang=true is_ubsan=true';;
                        esac

                        scripts/build/gn_gen.sh --args="$GN_ARGS"
                        scripts/tests/gn_tests.sh
                    done
            - name: Build using build_examples.py
              timeout-minutes: 40
              run: |
                  ./scripts/run_in_build_env.sh \
                    "./scripts/build/build_examples.py --no-log-timestamps \
                       --target linux-x64-all-clusters-ipv6only-clang \
                       --target linux-x64-chip-tool-ipv6only-clang \
                       --target linux-x64-minmdns-ipv6only-clang \
                       --target linux-x64-rpc-console \
                       build \
                    "
            - name: Run fake linux tests with build_examples
              timeout-minutes: 15
              run: |
                  ./scripts/run_in_build_env.sh \
                    "./scripts/build/build_examples.py --no-log-timestamps --target linux-fake-tests build"

            # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
            # TODO https://github.com/project-chip/connectedhomeip/issues/1512
            # - name: Run Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: scripts/tools/codecoverage.sh
            # - name: Upload Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: bash <(curl -s https://codecov.io/bash)
            # - name: Remove third_party binaries for CodeQL Analysis
            #   run: find out -type d -name "third_party" -exec rm -rf {} +
            # - name: Remove dbus binaries for CodeQL Analysis
            #   run: find out -type d -name "dbus" -exec rm -rf {} +
            # - name: Remove nrfxlib binaries for CodeQL Analysis
            #   run: find . -type d -name "nrfxlib" -exec rm -rf {} +
            # - name: Perform CodeQL Analysis
            #   if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
            #   uses: github/codeql-action/analyze@v1
    build_linux_python_lib:
        name: Build on Linux (python_lib)
        timeout-minutes: 60

        runs-on: ubuntu-latest
        if: github.actor != 'restyled-io[bot]'

        container:
            image: connectedhomeip/chip-build:0.5.56
            volumes:
                - "/tmp/log_output:/tmp/test_logs"
            options: --sysctl "net.ipv6.conf.all.disable_ipv6=0
                net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"

        steps:
            - name: Dump GitHub context
              env:
                  GITHUB_CONTEXT: ${{ toJSON(github) }}
              run: echo "$GITHUB_CONTEXT"
            - name: Dump Concurrency context
              env:
                  CONCURRENCY_CONTEXT: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
              run: echo "$CONCURRENCY_CONTEXT"
            - uses: Wandalen/wretry.action@v1.0.11
              name: Checkout
              with:
                  action: actions/checkout@v3
                  with: |
                      submodules: true
                      token: ${{ github.token }}
                  attempt_limit: 3
                  attempt_delay: 2000
            - name: Bootstrap
              timeout-minutes: 10
              run: scripts/build/gn_bootstrap.sh
            - name: Setup Build, Run Build and Run Tests
              timeout-minutes: 50
              run: |
                  scripts/build/gn_gen.sh --args="enable_rtti=true enable_pylib=true chip_config_memory_debug_checks=false chip_config_memory_debug_dmalloc=false"
                  scripts/run_in_build_env.sh "ninja -C ./out"
                  scripts/tests/gn_tests.sh
            - name: Run Python library specific unit tests
              timeout-minutes: 5
              run: |
                  scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip-0.0-cp37-abi3-linux_x86_64.whl'
                  scripts/run_in_build_env.sh '(cd src/controller/python/test/unit_tests/ && python3 -m unittest -v)'

    build_darwin:
        name: Build on Darwin (clang, python_lib, simulated)
        timeout-minutes: 200
        runs-on: macos-latest
        if: github.actor != 'restyled-io[bot]'

        steps:
            - uses: Wandalen/wretry.action@v1.0.11
              name: Checkout
              with:
                  action: actions/checkout@v3
                  with: |
                      submodules: true
                      token: ${{ github.token }}
                  attempt_limit: 3
                  attempt_delay: 2000
            #- name: Initialize CodeQL
            #  if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
            #  uses: github/codeql-action/init@v1
            #  with:
            #     languages: "cpp"
            - name: Setup Environment
              run: brew install openssl pkg-config
            - name: Try to ensure the directory for diagnostic log collection exists
              run: |
                  mkdir -p ~/Library/Logs/DiagnosticReports || true
            - name: Fix pkgconfig link
              working-directory: /usr/local/lib/pkgconfig
              run: |
                  pwd
                  ls -la /usr/local/Cellar/
                  ls -la /usr/local/Cellar/openssl@1.1
                  OPEN_SSL_VERSION=`ls -la /usr/local/Cellar/openssl@1.1 | cat | tail -n1 | awk '{print $NF}'`
                  ln -s /usr/local/Cellar/openssl@1.1/$OPEN_SSL_VERSION/lib/pkgconfig/* .
            - name: Bootstrap
              timeout-minutes: 25
              run: scripts/build/gn_bootstrap.sh
            - name: Uploading bootstrap logs
              uses: actions/upload-artifact@v2
              if: ${{ always() }} && ${{ !env.ACT }}
              with:
                  name: bootstrap-logs
                  path: |
                      .environment/gn_out/.ninja_log
                      .environment/pigweed-venv/*.log
            - name: Setup and Build Simulated Device
              timeout-minutes: 20
              run: |
                  BUILD_TYPE=simulated
                  GN_ARGS='chip_tests_zap_config="app1" chip_project_config_include_dirs=["../../examples/placeholder/linux/apps/app1/include", "../../config/standalone"] chip_config_network_layer_ble=false'
                  CHIP_ROOT_PATH=examples/placeholder/linux
                  CHIP_ROOT_PATH="$CHIP_ROOT_PATH" BUILD_TYPE="$BUILD_TYPE" scripts/build/gn_gen.sh --args="$GN_ARGS"
                  scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
            - name: Setup Build, Run Build and Run Tests
              timeout-minutes: 120
              run: |
                  for BUILD_TYPE in default python_lib; do
                      case $BUILD_TYPE in
                          # We want to build various standalone example apps
                          # (similar to what examples-linux-standalone.yaml
                          # does), so use target_os="all" to get those picked
                          # up as part of the "unified" build.  But then to
                          # save CI resources we want to exclude a few
                          # redundant things:
                          #
                          # * the mbedtls build, since we don't really plan to
                          #   use that on Darwin.
                          # * the "host clang" build, which uses the pigweed
                          #   clang.
                          "default") GN_ARGS='target_os="all" is_asan=true enable_host_clang_build=false enable_host_gcc_mbedtls_build=false';;
                          "python_lib") GN_ARGS='enable_rtti=true enable_pylib=true';;
                      esac
                      BUILD_TYPE=$BUILD_TYPE scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands
                      scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
                      BUILD_TYPE=$BUILD_TYPE scripts/tests/gn_tests.sh
                  done
            - name: Clang-tidy validation
              timeout-minutes: 45
              run: |
                  ./scripts/run_in_build_env.sh \
                    "./scripts/run-clang-tidy-on-compile-commands.py \
                       --no-log-timestamps \
                       --compile-database out/default/compile_commands.json \
                       check \
                    "
            - name: Uploading diagnostic logs
              uses: actions/upload-artifact@v2
              if: ${{ failure() }} && ${{ !env.ACT }}
              with:
                  name: crash-log-darwin
                  path: ~/Library/Logs/DiagnosticReports/
            # - name: Perform CodeQL Analysis
            #   if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
            #   uses: github/codeql-action/analyze@v1
            # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
            # TODO https://github.com/project-chip/connectedhomeip/issues/1512
            # - name: Run Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: scripts/tools/codecoverage.sh
            # - name: Upload Code Coverage
            #   if: ${{ contains('main', env.BUILD_TYPE) }}
            #   run: bash <(curl -s https://codecov.io/bash)

{'fraction_non_alphanumeric': 0.10316514010080755, 'fraction_numerical': 0.011137607717738876, 'mean_word_length': 1.4620054706784975, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 18, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '941059', 'n_tokens_mistral': 10847, 'n_tokens_neox': 10014, 'n_words': 2174}