Skip to content

Commit

Permalink
Adjust git paths for command capture, repo clone destinations (#13)
Browse files Browse the repository at this point in the history
* Adjust git paths for command capture, repo clone destinations

Also updates the expected artifact locations, relative to the workspace.

* Use bash for Bazel command capture, try to improve globs

* Remove inline comments from path command

They seem to be interpreted as part of the glob, which screws them up.

* Add artifact merge job

* Build nanobind_example wheel using Bazel to obtain linker flagfiles

Also postprocess the files into a single directory to obtain a neater
artifact.

* Use cp instead of mv, find param files via `find` and copy

Using xargs, in bash.

* Use explicit glob in Bazel artifact to prevent flattening
  • Loading branch information
nicholasjng authored Mar 12, 2024
1 parent d99fa26 commit b8fe40e
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions .github/workflows/capture-compile-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
nb-compile-commands:
name: Capture nanobind CMake compile commands on ${{ matrix.os }}
name: Capture nanobind compile commands on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -15,6 +15,7 @@ jobs:
- uses: actions/checkout@v4
with:
repository: wjakob/nanobind_example
path: nanobind_example
fetch-depth: 0
- uses: actions/checkout@v4
with:
Expand All @@ -25,19 +26,25 @@ jobs:
python-version: 3.12
- run: python -m pip install --upgrade build
- name: Build and capture CMake compile commands
run: python -m build . --wheel -Ccmake.args=-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
run: python -m build . --wheel --config-setting="cmake.args=-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
working-directory: nanobind_example
- name: Upload CMake commands and Ninja build artifacts
uses: actions/upload-artifact@v4
with:
name: compile-commands-${{ matrix.os}}-cmake
name: cmake-compile-commands-${{ matrix.os}}
# the build subfolder name is autogenerated, so just use a glob.
# the build.ninja file has the linker command section.
path: |
# the build subfolder name is autogenerated, so just use a glob.
build/cp312-*/build.ninja # this has the linker command section.
build/cp312-*/CMakeCache.txt
build/cp312-*/compile_commands.json
nanobind_example/build/cp312-*/build.ninja
nanobind_example/build/cp312-*/CMakeCache.txt
nanobind_example/build/cp312-*/compile_commands.json
if-no-files-found: error
- name: Clean repo and switch to Bazel
run: git clean -xdf && git checkout bazel
working-directory: nanobind_example
- name: Build wheel using Bazel
run: python -m build . --wheel
working-directory: nanobind_example
- name: Extract Bazel compile commands for ${{ matrix.os}}
run: |
bazel run @hedron_compile_commands//:refresh_all \
Expand All @@ -47,11 +54,38 @@ jobs:
--@rules_python//python/config_settings:python_version=3.12 \
--@nanobind_bazel//:minsize \
--@nanobind_bazel//:py-limited-api=cp312
shell: bash
working-directory: nanobind_example
- name: Rearrange files into a single output directory
run: |
mkdir ${{ matrix.os }}
cp compile_commands.json ${{ matrix.os }}
find bazel-out/ -name '*.params' | xargs -I _ cp _ ${{ matrix.os }}
shell: bash
working-directory: nanobind_example
- name: Upload Bazel compile commands and flag files for ${{ matrix.os }}
uses: actions/upload-artifact@v4
with:
name: compile-commands-${{ matrix.os}}-bazel
name: bazel-compile-commands-${{ matrix.os }}
# use dir glob to preserve top-level directories.
path: |
compile_commands.json
bazel-out/*-opt/**/*.params # these should be two - the libnanobind params, and the nanobind_example_ext params.
nanobind_example/*-latest/*.params
nanobind_example/*-latest/compile_commands.json
if-no-files-found: error
merge-compile-commands:
name: Stitch together previously collected commands
runs-on: ubuntu-latest
needs: nb-compile-commands
steps:
- name: Merge all CMake Artifacts into one
uses: actions/upload-artifact/merge@v4
with:
name: cmake-compile-commands
pattern: cmake-compile-commands-*
delete-merged: true
- name: Merge all Bazel Artifacts into one
uses: actions/upload-artifact/merge@v4
with:
name: bazel-compile-commands
pattern: bazel-compile-commands-*
delete-merged: true

0 comments on commit b8fe40e

Please sign in to comment.