Skip to content

Commit

Permalink
fix: Remove git submodule update in cmake (#4048)
Browse files Browse the repository at this point in the history
This is intended to fix the git fatal: unsafe repository error in CI

Build process shouldn't download more code. Instead, submodules should be recursively updated in the initial git checkout.
  • Loading branch information
byronxu99 authored Jul 14, 2022
1 parent 4b1616f commit c8ee82c
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: "CodeQL config"
paths-ignore:
- ext_libs/
- python/docs/
- demo/
9 changes: 9 additions & 0 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Configure
run: |
mkdir build
Expand All @@ -43,6 +45,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- run: |
sudo apt update
sudo apt install -y ninja-build
Expand All @@ -61,6 +65,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- run: echo "/opt/python/cp39-cp39/bin" >> $GITHUB_PATH
- name: Build wheel
shell: bash
Expand All @@ -77,6 +83,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- uses: actions/setup-node@v3
- uses: actions/setup-python@v3
with:
Expand Down Expand Up @@ -150,6 +158,7 @@ jobs:
echo $GITHUB_WORKSPACE
- uses: actions/checkout@v1
with:
submodules: recursive
repository: VowpalWabbit/docs
ref: master
# For some reason, path is relative to the directory above GITHUB_WORKSPACE
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
build_type: [Debug, Release]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
run: brew install cmake boost flatbuffers ninja
- name: Configure
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build_vw_large_action_space.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Build VW with large action space reduction
shell: bash
run: ./.scripts/linux/build-las-reduction.sh
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build_vw_slim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Build VW Slim
shell: bash
run: ./.scripts/linux/build-slim.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_windows_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@v2
with:
path: 'vw'
submodules: true
submodules: recursive
- uses: actions/checkout@v2
with:
path: 'vcpkg'
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3

with:
submodules: recursive
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
steps:
# v1 must be used because newer versions require a node.js version that will not run on this old image.
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Build wheel
shell: bash
run: |
Expand All @@ -44,6 +46,8 @@ jobs:
- { version: "3.9" }
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Download Wheel
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -73,6 +77,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup python
uses: actions/setup-python@v2
with:
Expand All @@ -86,6 +92,8 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Install clang-format
# This is only needed if the diff check runs as it installs 'clang-format-diff'
# 'clang-format' is available by default
Expand Down Expand Up @@ -131,6 +139,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install Ninja
shell: bash
run: |
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/python_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
steps:
# v1 must be used because newer versions require a node.js version that will not run on this old image.
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Build wheel
shell: bash
run: |
Expand All @@ -54,6 +56,8 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- uses: actions/download-artifact@v1
with:
name: manylinux_amd64_${{ matrix.version }}
Expand Down Expand Up @@ -84,7 +88,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
submodules: recursive
- uses: actions/setup-python@v2
with:
python-version: '3.8'
Expand Down Expand Up @@ -119,6 +123,8 @@ jobs:
shell: bash
run: pip install python_source_distribution/*.tar.gz
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
shell: bash
run: |
Expand All @@ -143,6 +149,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
Expand Down Expand Up @@ -177,6 +185,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
Expand Down Expand Up @@ -217,6 +227,8 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
Expand All @@ -242,6 +254,8 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.version }}
Expand Down Expand Up @@ -280,6 +294,7 @@ jobs:
python-version: ${{ matrix.config.version }}
- uses: actions/checkout@v2
with:
submodules: recursive
path: ${{github.workspace}}\vowpal_wabbit
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -325,6 +340,8 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.version }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run_benchmarks_manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
ref: ${{ github.event.inputs.benchmarks_ref }}
- name: Store benchmark related script(s)
shell: bash
Expand All @@ -36,6 +37,7 @@ jobs:
# checkout first ref
- uses: actions/checkout@v1
with:
submodules: recursive
ref: ${{ github.event.inputs.base_ref }}
- name: Remove existing benchmark module (in favour of master)
shell: bash
Expand Down Expand Up @@ -82,6 +84,7 @@ jobs:
# checkout second ref
- uses: actions/checkout@v1
with:
submodules: recursive
ref: ${{ github.event.inputs.compare_ref }}
- name: Download ${{ github.event.inputs.base_ref }} benchmark results
uses: actions/download-artifact@v2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/upload_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Build with coverage C++
shell: bash
run: ./.scripts/linux/build-with-coverage.sh
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Build C++ VW binary
run: ./.scripts/linux/build-minimal.sh Release
- name: Upload vw binary
Expand Down Expand Up @@ -46,6 +48,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- uses: actions/download-artifact@v2
with:
name: vw
Expand Down
23 changes: 0 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,29 +202,6 @@ endif()
# This provides the variables such as CMAKE_INSTALL_LIBDIR for installation paths.
include(GNUInstallDirs)

# Ensure submodules are ready
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
# Check if an abritrary file in the submodules already exists. If it does
# then we assume the submodules are already up to date. This is to avoid
# taking the git lock aggressively whenever we configure. This can cause
# issues if VSCode with certain extensions has the workspace open at the
# same time as you interact with it on the command line.
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ext_libs/spdlog/README.md)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
endif()

add_subdirectory(library)
include(ext_libs/ext_libs.cmake)
add_subdirectory(vowpalwabbit)
Expand Down

0 comments on commit c8ee82c

Please sign in to comment.