From 9d8b4700d87f74391174c660c5000b7293c837a0 Mon Sep 17 00:00:00 2001 From: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> Date: Wed, 5 Apr 2023 14:59:53 +1200 Subject: [PATCH] Don't modify global git safe.directory config outside of CI (#25857) Adding CHIP_ROOT as a safe directory is now gated by a --configure flag which is added to all the calls from CI scripts (but not e.g. the Darwin chip_xcode_build_connector). Also avoid adding the directory again if it's already in the list. --- .github/workflows/build.yaml | 10 +++++----- .github/workflows/chef.yaml | 6 +++--- .github/workflows/cirque.yaml | 2 +- .github/workflows/darwin-tests.yaml | 2 +- .github/workflows/darwin.yaml | 2 +- .github/workflows/examples-ameba.yaml | 2 +- .github/workflows/examples-bouffalolab.yaml | 2 +- .github/workflows/examples-cc13x2x7_26x2x7.yaml | 2 +- .github/workflows/examples-cc32xx.yaml | 2 +- .github/workflows/examples-efr32.yaml | 2 +- .github/workflows/examples-esp32.yaml | 4 ++-- .github/workflows/examples-infineon.yaml | 2 +- .github/workflows/examples-k32w.yaml | 2 +- .github/workflows/examples-linux-arm.yaml | 2 +- .github/workflows/examples-linux-imx.yaml | 2 +- .../workflows/examples-linux-standalone.yaml | 2 +- .github/workflows/examples-mbed.yaml | 2 +- .github/workflows/examples-mw320.yaml | 2 +- .github/workflows/examples-nrfconnect.yaml | 2 +- .github/workflows/examples-openiotsdk.yaml | 2 +- .github/workflows/examples-qpg.yaml | 2 +- .github/workflows/examples-telink.yaml | 4 ++-- .github/workflows/examples-tizen.yaml | 2 +- .github/workflows/full-android.yaml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/qemu.yaml | 4 ++-- .github/workflows/smoketest-android.yaml | 2 +- .github/workflows/smoketest-darwin.yaml | 2 +- .github/workflows/tests.yaml | 10 +++++----- .github/workflows/unit_integration_test.yaml | 2 +- .github/workflows/zap_regeneration.yaml | 2 +- .github/workflows/zap_templates.yaml | 2 +- examples/chef/README.md | 3 ++- .../docker/images/chip-cert-bins/Dockerfile | 2 +- scripts/build/gn_gen_cirque.sh | 2 +- scripts/checkout_submodules.py | 17 ++++++++++++++--- 36 files changed, 63 insertions(+), 51 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d0daa83fc2fd35..c580dda8e5603f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -60,7 +60,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Try to ensure the directories for core dumping exist and we can write them. run: | @@ -177,7 +177,7 @@ jobs: # with: # languages: "cpp" - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Try to ensure the directories for core dumping exist and we can write them. run: | @@ -342,7 +342,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Bootstrap cache uses: actions/cache@v3 @@ -398,7 +398,7 @@ jobs: # with: # languages: "cpp" - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform darwin + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform darwin - name: Try to ensure the directory for diagnostic log collection exists run: | mkdir -p ~/Library/Logs/DiagnosticReports || true @@ -501,7 +501,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Bootstrap cache uses: actions/cache@v3 diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index ab8622f64be6c4..29ae5c8fd548a5 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -43,7 +43,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Bootstrap cache uses: actions/cache@v3 timeout-minutes: 10 @@ -79,7 +79,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform esp32 + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform esp32 - name: Bootstrap cache uses: actions/cache@v3 timeout-minutes: 10 @@ -115,7 +115,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform nrfconnect + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform nrfconnect - name: Bootstrap cache uses: actions/cache@v3 timeout-minutes: 10 diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index ea5d4c3755c56d..f1ce18e3693319 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -58,7 +58,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Bootstrap cache uses: actions/cache@v3 diff --git a/.github/workflows/darwin-tests.yaml b/.github/workflows/darwin-tests.yaml index cdf8b5a4364572..5e4d26d27e41c3 100644 --- a/.github/workflows/darwin-tests.yaml +++ b/.github/workflows/darwin-tests.yaml @@ -54,7 +54,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform darwin + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform darwin - name: Setup Environment # coreutils for stdbuf run: brew install coreutils diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 6c82a17f224bf9..40ec4df82cc88d 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -42,7 +42,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform darwin + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform darwin - name: Setup Environment run: brew install python@3.9 diff --git a/.github/workflows/examples-ameba.yaml b/.github/workflows/examples-ameba.yaml index 3ed0d5a866bc15..a747a9565fdd60 100644 --- a/.github/workflows/examples-ameba.yaml +++ b/.github/workflows/examples-ameba.yaml @@ -49,7 +49,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform ameba + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform ameba - name: Bootstrap cache uses: actions/cache@v3 timeout-minutes: 10 diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index 1760458c2b03ab..b87b5da515c373 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -49,7 +49,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform bouffalolab --recursive + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform bouffalolab --recursive - name: Set up environment for size reports if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index 254c4a041c8ccf..a4e2a302bcb8b3 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -51,7 +51,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform cc13x2_26x2 + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform cc13x2_26x2 - name: Set up environment for size reports if: ${{ !env.ACT }} env: diff --git a/.github/workflows/examples-cc32xx.yaml b/.github/workflows/examples-cc32xx.yaml index fed502b34d7530..3bfed24d5497d4 100644 --- a/.github/workflows/examples-cc32xx.yaml +++ b/.github/workflows/examples-cc32xx.yaml @@ -48,7 +48,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform cc32xx + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform cc32xx - name: Set up environment for size reports if: ${{ !env.ACT }} env: diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index a80505fcfd8ab3..5b448eb525a121 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -52,7 +52,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform silabs_docker + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform silabs_docker # - name: Out of Tree verification # run: third_party/silabs/out_of_tree_verification.sh diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 74dee213b71be8..4065aecf78d074 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -49,7 +49,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform esp32 + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform esp32 - name: Set up environment for size reports if: ${{ !env.ACT }} @@ -172,7 +172,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform esp32 + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform esp32 - name: Bootstrap cache uses: actions/cache@v3 diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 46db43bca68fa7..b8e8f73c46912a 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -49,7 +49,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform infineon + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform infineon - name: Set up environment for size reports if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 77b9826f6f8231..4ecbee87147a7b 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -51,7 +51,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform k32w0 + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform k32w0 - name: Set up environment for size reports if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-linux-arm.yaml b/.github/workflows/examples-linux-arm.yaml index f0b78a5b46b383..8d26d9d6f12d86 100644 --- a/.github/workflows/examples-linux-arm.yaml +++ b/.github/workflows/examples-linux-arm.yaml @@ -49,7 +49,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Set up environment for size reports if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-linux-imx.yaml b/.github/workflows/examples-linux-imx.yaml index ded33cb5756ae9..caa56ec4864df7 100644 --- a/.github/workflows/examples-linux-imx.yaml +++ b/.github/workflows/examples-linux-imx.yaml @@ -47,7 +47,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Bootstrap cache uses: actions/cache@v3 diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index 8d2d87f067b916..9097133fe6e6b0 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -49,7 +49,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Set up environment for size reports if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index 53da5ba28ba613..e886d5617f890d 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -55,7 +55,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform mbed + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform mbed - name: Detect changed paths uses: dorny/paths-filter@v2 diff --git a/.github/workflows/examples-mw320.yaml b/.github/workflows/examples-mw320.yaml index 1aea2f34557a52..98c01fc4eab8b6 100755 --- a/.github/workflows/examples-mw320.yaml +++ b/.github/workflows/examples-mw320.yaml @@ -51,7 +51,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform mw320 + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform mw320 - name: Set up environment for size reports if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 929d8af509aeba..ab8b44c89a7ba3 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -52,7 +52,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform nrfconnect + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform nrfconnect - name: Detect changed paths uses: dorny/paths-filter@v2 id: changed_paths diff --git a/.github/workflows/examples-openiotsdk.yaml b/.github/workflows/examples-openiotsdk.yaml index ddf3868d878cc1..6a01bc03cca670 100644 --- a/.github/workflows/examples-openiotsdk.yaml +++ b/.github/workflows/examples-openiotsdk.yaml @@ -51,7 +51,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --recursive --platform openiotsdk + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --recursive --platform openiotsdk - name: Set up environment for size reports if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index 65376a17a86490..a7888a092a3e23 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -51,7 +51,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform qpg + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform qpg - name: Set up environment for size reports if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index df6c31813167e1..1377b4c0ebfee4 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -50,7 +50,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform telink + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform telink - name: Set up environment for size reports if: ${{ !env.ACT }} @@ -132,7 +132,7 @@ jobs: - name: Build example Telink Lighting App with Factory Data run: | - ./scripts/checkout_submodules.py --shallow --platform linux + ./scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux ./scripts/build/gn_gen.sh ./scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE chip-cert chip-tool spake2p" ./scripts/run_in_build_env.sh \ diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index b5d4c33ece6542..7c9d71c8b2c8d8 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -50,7 +50,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform tizen + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform tizen - name: Bootstrap cache uses: actions/cache@v3 diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index 886a9462de9673..14e57bcc281767 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -61,7 +61,7 @@ jobs: if: ${{ env.ACT }} name: Checkout (ACT for local build) - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform android + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform android - name: Bootstrap cache uses: actions/cache@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index caac210d7dfa91..17c31b004581d8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -54,7 +54,7 @@ jobs: # Bootstrap and checkout for internal scripts (like idl_lint) # to run - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Bootstrap cache uses: actions/cache@v3 timeout-minutes: 10 diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index c91e378691d976..1d0cf735d0cd9b 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -53,7 +53,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform esp32 + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform esp32 - name: Bootstrap cache uses: actions/cache@v3 @@ -117,7 +117,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform tizen + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform tizen - name: Bootstrap cache uses: actions/cache@v3 diff --git a/.github/workflows/smoketest-android.yaml b/.github/workflows/smoketest-android.yaml index 3664cc46aa9de1..cd24e24e147516 100644 --- a/.github/workflows/smoketest-android.yaml +++ b/.github/workflows/smoketest-android.yaml @@ -52,7 +52,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform android + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform android - name: Bootstrap cache uses: actions/cache@v3 diff --git a/.github/workflows/smoketest-darwin.yaml b/.github/workflows/smoketest-darwin.yaml index d4b06f4f2d3c89..abf9ce606e8402 100644 --- a/.github/workflows/smoketest-darwin.yaml +++ b/.github/workflows/smoketest-darwin.yaml @@ -42,7 +42,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform darwin + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform darwin - name: Setup Environment run: brew install python@3.9 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2eda3b67aa45fd..da3e93be3c62e0 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -72,7 +72,7 @@ jobs: if: ${{ env.ACT }} name: Checkout (ACT for local build) - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Try to ensure the directories for core dumping exist and we can write them. run: | @@ -324,7 +324,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform darwin + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform darwin - name: Setup Environment # coreutils for stdbuf run: brew install coreutils @@ -450,7 +450,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Try to ensure the directories for core dumping exist and we can write them. run: | @@ -536,7 +536,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Try to ensure the directories for core dumping exist and we can write them. run: | @@ -705,7 +705,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform darwin + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform darwin - name: Setup Environment # coreutils for stdbuf run: brew install coreutils diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index 540e4a9563f283..19d001989e4589 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -53,7 +53,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Bootstrap timeout-minutes: 10 run: | diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index 257b86e81914a7..c0693a79d3b865 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -45,7 +45,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Bootstrap cache uses: actions/cache@v3 diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index d1a846b9968cb0..f4bd3744aa84e8 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -46,7 +46,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform linux + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - name: Bootstrap cache uses: actions/cache@v3 diff --git a/examples/chef/README.md b/examples/chef/README.md index 52829c0500a079..f03b46e01d7ea4 100644 --- a/examples/chef/README.md +++ b/examples/chef/README.md @@ -146,7 +146,8 @@ chef_$PLATFORM: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform $PLATFORM + run: | + scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform $PLATFORM - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index cc3090b4c71547..bc7317f5f7adc2 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -200,7 +200,7 @@ RUN mkdir /root/connectedhomeip RUN git clone https://github.com/project-chip/connectedhomeip.git /root/connectedhomeip WORKDIR /root/connectedhomeip/ RUN git checkout ${COMMITHASH} -RUN ./scripts/checkout_submodules.py --shallow --platform linux +RUN ./scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux RUN scripts/build/gn_bootstrap.sh SHELL ["/bin/bash", "-c"] RUN set -x && \ diff --git a/scripts/build/gn_gen_cirque.sh b/scripts/build/gn_gen_cirque.sh index 85da0c232745c5..061f89932023ee 100755 --- a/scripts/build/gn_gen_cirque.sh +++ b/scripts/build/gn_gen_cirque.sh @@ -30,7 +30,7 @@ env cd "$ROOT_PATH" echo "Ensure submodules for Linux builds are checked out" -./scripts/checkout_submodules.py --shallow --platform linux +./scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux echo "Setup build environment" source "./scripts/activate.sh" diff --git a/scripts/checkout_submodules.py b/scripts/checkout_submodules.py index 8afe1a93fd7564..ec4f67bc60fdf9 100755 --- a/scripts/checkout_submodules.py +++ b/scripts/checkout_submodules.py @@ -77,8 +77,16 @@ def module_initialized(module: Module) -> bool: def make_chip_root_safe_directory() -> None: - # ensure no errors regarding ownership in the directory. Newer GIT seems to require this: - subprocess.check_call(['git', 'config', '--global', '--add', 'safe.directory', CHIP_ROOT]) + # Can't use check_output, git will exit(1) if the setting has no existing value + config = subprocess.run(['git', 'config', '--global', '--null', '--get-all', + 'safe.directory'], stdout=subprocess.PIPE, text=True) + existing = [] + if config.returncode != 1: + config.check_returncode() + existing = config.stdout.split('\0') + if CHIP_ROOT not in existing: + logging.info("Adding CHIP_ROOT to global git safe.directory configuration") + subprocess.check_call(['git', 'config', '--global', '--add', 'safe.directory', CHIP_ROOT]) def checkout_modules(modules: list, shallow: bool, force: bool, recursive: bool) -> None: @@ -109,6 +117,8 @@ def main(): logging.basicConfig(format='%(message)s', level=logging.INFO) parser = argparse.ArgumentParser(description='Checkout or update relevant git submodules') + parser.add_argument('--allow-changing-global-git-config', action='store_true', + help='Allow global git options to be modified if necessary, e.g. safe.directory') parser.add_argument('--shallow', action='store_true', help='Fetch submodules without history') parser.add_argument('--platform', nargs='+', choices=ALL_PLATFORMS, default=[], help='Process submodules for specific platforms only') @@ -124,7 +134,8 @@ def main(): unmatched_modules = [m for m in modules if not module_matches_platforms( m, selected_platforms) and module_initialized(m)] - make_chip_root_safe_directory() + if args.allow_changing_global_git_config: + make_chip_root_safe_directory() # ignore directory ownership issues for sub-modules checkout_modules(selected_modules, args.shallow, args.force, args.recursive) if args.deinit_unmatched and unmatched_modules: