Skip to content

Commit

Permalink
Added [generate bindings] command for CI
Browse files Browse the repository at this point in the history
Update maintainer guide

hopefully, a GHA commit shouldn't follow

maybe it needs to be an expression?

what's happening...

please xplain.

right sha..

hopefully, a GHA commit shouldn't follow

hopefully, a GHA commit shouldn't follow

no generating of anything
  • Loading branch information
CGMossa committed Nov 18, 2023
1 parent 6fc2b5f commit feffdbe
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 8 deletions.
65 changes: 57 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,63 @@ jobs:
name: generated_binding-${{ matrix.config.os }}-R-${{ matrix.config.r }}-rust-${{ matrix.config.rust-version }}-${{ matrix.config.target || 'default'}}
path: generated_bindings

# Run tests again using different bindings
- name: Run tests on precomputed bindings shipped with libR-sys
if: matrix.config.skip-tests != 'true'
run: |
. ./ci-cargo.ps1
ci-cargo test -vv $(if ($env:RUST_TARGET -ne '') {"--target=$env:RUST_TARGET"} ) '--' --nocapture -ActionName "Running tests for target: $env:RUST_TARGET"
env:
RUST_TARGET: ${{ matrix.config.target }}
# # Run tests again using different bindings
# - name: Run tests on precomputed bindings shipped with libR-sys
# if: matrix.config.skip-tests != 'true'
# run: |
# . ./ci-cargo.ps1
# ci-cargo test -vv $(if ($env:RUST_TARGET -ne '') {"--target=$env:RUST_TARGET"} ) '--' --nocapture -ActionName "Running tests for target: $env:RUST_TARGET"
# env:
# RUST_TARGET: ${{ matrix.config.target }}
check_generate_bindings_flag:
name: Check if [generate bindings] is in latest commit message
runs-on: ubuntu-latest
outputs:
head_commit_message: ${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}
# generate_bindings: ${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, '[generate bindings]') }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Get Head Commit Message
id: get_head_commit_message
run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
- name: Show commit message
run: |
echo "${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}"
echo "${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, '[generate bindings]') }}"
pr_generated_bindings:
name: Make PR with generated bindings
needs: [test_with_bindgen, check_generate_bindings_flag]
if: ${{ contains(needs.check_generate_bindings_flag.outputs.head_commit_message, '[generate bindings]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/download-artifact@v3

- name: Update bindings
run: |
# Update or add the bindings
cp generated_binding-*/*.rs bindings/
# Replace the default bindings
cd bindings
for x in linux-aarch64 linux-x86_64 macos-aarch64 macos-x86_64 windows-x86_64; do
# Choose the newest version except for devel
ln --force -s "$(ls -1 ./bindings-${x}-*.rs | grep -v devel | sort | tail -1)" ./bindings-${x}.rs
done
cd ..
- name: Add generated bindings
run: |
git add bindings/
git config --local user.name "${GITHUB_ACTOR}"
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git commit -m "Update bindings [skip ci]"
- name: Push to PR branch
run: git push

# Gather the generated bindings and push them to generated_bindings branch.
# If we need to update the bindings, create a pull request from that branch.
Expand Down
14 changes: 14 additions & 0 deletions MAINTAINERS_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# GUIDE

## Commit newly generated bindings

You last commit must contain `[generate bindings]`. You can make an empty
commit with this message:

```sh
git commit -m "[generate bindings]" --allow-empty
```

Then after successfully running workflows, GitHub Actions will push a commit
with the updated bindings onto your PR branch.

## Precomputed bindings

### How to update the precomputed bindings?
Expand Down

0 comments on commit feffdbe

Please sign in to comment.