diff --git a/.github/workflows/test-cbindgen-workflow.yml b/.github/workflows/test-cbindgen-workflow.yml new file mode 100644 index 0000000..2a3e77d --- /dev/null +++ b/.github/workflows/test-cbindgen-workflow.yml @@ -0,0 +1,94 @@ +name: Test CBindgen Workflow + +on: + schedule: + - cron: '0 0 * * *' # Run daily at midnight + workflow_dispatch: + push: + branches: [ master ] + tags: + - 'v1' + paths: + - 'action.yml' + - '.github/workflows/test-cbindgen-workflow.yml' + pull_request: + branches: [ master ] + paths: + - 'action.yml' + - '.github/workflows/test-cbindgen-workflow.yml' + +jobs: + test-custom-parameters: + runs-on: ubuntu-latest + steps: + - name: Checkout Test Repository + uses: actions/checkout@v4 + with: + repository: Sewer56/prs-rs + ref: d08599ed5473616f57d57a0966939e1a5dbda9b4 + - name: Test Custom Parameters + uses: Reloaded-Project/devops-rust-cbindgen@v1 + with: + rust-project-path: '.' + config-file: cbindgen_cpp.toml + output-header-file: bindings_cpp.hpp + upload-artifact: false + - name: Assert Generated Header File + shell: bash + run: | + if [ ! -f bindings_cpp.hpp ]; then + echo "Generated header file does not exist" + exit 1 + fi + + test-c-bindings: + runs-on: ubuntu-latest + steps: + - name: Checkout Test Repository + uses: actions/checkout@v4 + with: + repository: Sewer56/prs-rs + ref: d08599ed5473616f57d57a0966939e1a5dbda9b4 + - name: Test C Bindings + uses: Reloaded-Project/devops-rust-cbindgen@v1 + with: + config-file: cbindgen_c.toml + output-header-file: bindings_c.h + upload-artifact: false + - name: Assert Generated C Header File + shell: bash + run: | + if [ ! -f bindings_c.h ]; then + echo "Generated C header file does not exist" + exit 1 + fi + + test-artifact-creation: + runs-on: ubuntu-latest + steps: + - name: Checkout Test Repository + uses: actions/checkout@v4 + with: + repository: Sewer56/prs-rs + ref: d08599ed5473616f57d57a0966939e1a5dbda9b4 + - name: Generate Bindings and Create Artifact + uses: Reloaded-Project/devops-rust-cbindgen@v1 + with: + config-file: cbindgen_c.toml + output-header-file: bindings_c.h + upload-artifact: true + github-token: ${{ secrets.GITHUB_TOKEN }} + commit-updated-bindings: 'false' + - name: Download Artifact + uses: actions/download-artifact@v4 + with: + name: C-Bindings-bindings_c.h + path: artifacts + - name: Assert Artifact Contents + shell: bash + run: | + cat artifacts/bindings_c.h + if [ ! -f artifacts/bindings_c.h ]; then + echo "Extracted artifact does not contain the expected header file" + exit 1 + fi \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a91fae5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2023 Sewer56 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..b6850f4 --- /dev/null +++ b/README.MD @@ -0,0 +1,59 @@ +
+ +This GitHub Action generates C bindings with cbindgen for a Rust project. + +## Inputs + +| Input | Required | Default | Description | +| ------------------------- | -------- | --------------- | ------------------------------------------------------------------------------ | +| `rust-project-path` | No | `.` | Path to the Rust project | +| `config-file` | Yes | `cbindgen.toml` | Configuration file for cbindgen | +| `output-header-file` | Yes | `bindings_c.h` | Path to the output header file generated by cbindgen | +| `upload-artifact` | No | `true` | Whether to upload the generated header file as an artifact | +| `github-token` | No | | A GitHub token for pushing to the repo. Example: `${{ secrets.GITHUB_TOKEN }}` | +| `commit-updated-bindings` | No | `false` | Whether to commit the updated bindings | + +## Example Usage + +```yaml +steps: + - uses: actions/checkout@v4 + - uses: Reloaded-Project/cbindgen-action@v1 + with: + rust-project-path: '.' + config-file: 'cbindgen.toml' + output-header-file: 'bindings_c.h' + upload-artifact: 'true' + github-token: ${{ secrets.GITHUB_TOKEN }} + commit-updated-bindings: 'true' +``` + +## Getting Artifacts + +If the `upload-artifact` input is set to `true`, the generated header file will be uploaded as +an artifact with the following name format: + +``` +C-Bindings-