Skip to content

Commit

Permalink
Use submodules in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nbolton committed Sep 26, 2024
1 parent 5123892 commit 14940f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

# HACK: Download Deskflow git repo first, but don't install deps.
# Maybe we should use submodules instead? That way we can just add the submodule
# arg to `actions/checkout`.
# Submodules suck, but maybe this is the appropriate use case.
- name: Install dependencies
run: python ./scripts/setup.py --no-install-deps
with:
submodules: true

- name: Cache vcpkg dir
uses: actions/cache@v4
Expand Down Expand Up @@ -160,6 +155,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Cache deps dir
uses: actions/cache@v4
Expand Down Expand Up @@ -221,9 +218,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: ./scripts/setup.py --no-install-deps
with:
submodules: true

- name: Get JSON file
id: get
Expand All @@ -248,6 +244,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Config Git safe dir
run: git config --global --add safe.directory $GITHUB_WORKSPACE
Expand Down
27 changes: 8 additions & 19 deletions scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,16 @@


def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--no-install-deps",
action="store_true",
help="Leave test package installed",
)
args, _unknown = parser.parse_known_args()

bootstrap.ensure_in_venv(__file__)
setup_deskflow(args.no_install_deps == False)
setup_deskflow()


# Using CMake `FetchContent` would be nice, but that doesn't allow us to run the `install_deps.py`
# script before configuring, which is necessary to install the dependencies before running CMake.
# With `FetchContent`, there may be a way of running `install_deps.py`` before populating,
# but it seemed quite complex and potentially required upstream changes. This approach seems
# to be simpler and easier to maintain.
def setup_deskflow(install_deps):
def setup_deskflow():
if not os.getenv("CI"):
subprocess.run(
[
Expand All @@ -54,15 +46,12 @@ def setup_deskflow(install_deps):
]
)

if install_deps:
current_dir = os.getcwd()
try:
os.chdir(DESKFLOW_DIR)
subprocess.run([sys.executable, "scripts/install_deps.py"] + sys.argv[1:])
finally:
os.chdir(current_dir)
else:
print("Skipping install deps")
current_dir = os.getcwd()
try:
os.chdir(DESKFLOW_DIR)
subprocess.run([sys.executable, "scripts/install_deps.py"] + sys.argv[1:])
finally:
os.chdir(current_dir)


if __name__ == "__main__":
Expand Down

0 comments on commit 14940f6

Please sign in to comment.