Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bindings failure on PRs #208

Merged
merged 4 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 49 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,56 @@ jobs:
with:
name: generated_binding-${{ matrix.config.os }}-R-${{ matrix.config.r }}-rust-${{ matrix.config.rust-version }}-${{ matrix.config.target || 'default'}}
path: generated_bindings

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

# 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 }}
- 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
Ilia-Kosenkov marked this conversation as resolved.
Show resolved Hide resolved
# 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

Your 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
4 changes: 2 additions & 2 deletions bindings/bindings-linux-aarch64-R4.4-devel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ pub const R_MINOR: &[u8; 4] = b"4.0\0";
pub const R_STATUS: &[u8; 29] = b"Under development (unstable)\0";
pub const R_YEAR: &[u8; 5] = b"2023\0";
pub const R_MONTH: &[u8; 3] = b"11\0";
pub const R_DAY: &[u8; 3] = b"11\0";
pub const R_SVN_REVISION: u32 = 85510;
pub const R_DAY: &[u8; 3] = b"16\0";
pub const R_SVN_REVISION: u32 = 85542;
pub const R_GE_definitions: u32 = 13;
pub const R_GE_deviceClip: u32 = 14;
pub const R_GE_group: u32 = 15;
Expand Down
4 changes: 2 additions & 2 deletions bindings/bindings-linux-x86_64-R4.4-devel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ pub const R_MINOR: &[u8; 4] = b"4.0\0";
pub const R_STATUS: &[u8; 29] = b"Under development (unstable)\0";
pub const R_YEAR: &[u8; 5] = b"2023\0";
pub const R_MONTH: &[u8; 3] = b"11\0";
pub const R_DAY: &[u8; 3] = b"11\0";
pub const R_SVN_REVISION: u32 = 85510;
pub const R_DAY: &[u8; 3] = b"16\0";
pub const R_SVN_REVISION: u32 = 85542;
pub const R_GE_definitions: u32 = 13;
pub const R_GE_deviceClip: u32 = 14;
pub const R_GE_group: u32 = 15;
Expand Down
4 changes: 2 additions & 2 deletions bindings/bindings-macos-x86_64-R4.2.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* automatically generated by rust-bindgen 0.69.1 */

/* libR-sys version: 0.6.0 */
/* bindgen clang version: Homebrew clang version 17.0.3 */
/* clang-rs version: Homebrew clang version 17.0.3 */
/* bindgen clang version: Homebrew clang version 17.0.2 */
/* clang-rs version: Homebrew clang version 17.0.2 */
/* r version: 4.2.3 */

#[repr(C)]
Expand Down
Loading