-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first commit, with binding generation, publish and caching on CI
- Loading branch information
1 parent
4a80c75
commit d82ad66
Showing
16 changed files
with
686 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
max_line_length = 120 | ||
|
||
[*.md] | ||
# double whitespace at end of line | ||
# denotes a line break in Markdown | ||
trim_trailing_whitespace = false | ||
|
||
[{*.sh,*.yml,*.yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Publish | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- v* | ||
|
||
env: | ||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | ||
|
||
jobs: | ||
publish: | ||
strategy: | ||
matrix: | ||
triple: | ||
- { os: 'ubuntu-latest', target: 'x86_64-unknown-linux-gnu', lib: 'libcicd_ffi.so' } | ||
- { os: 'macos-latest', target: 'aarch64-apple-darwin', lib: 'libcicd_ffi.dylib' } | ||
- { os: 'macos-latest', target: 'x86_64-apple-darwin', lib: 'libcicd_ffi.dylib' } | ||
- { os: 'windows-latest', target: 'x86_64-pc-windows-msvc', lib: 'cicd_ffi.dll' } | ||
env: | ||
ARTIFACT_FILE_PATH: "./target/${{ matrix.triple.target }}/release/${{ matrix.triple.lib }}" | ||
KOTLIN_BINDINGS_PATH: "./uniffi" | ||
PYTHON_BINDINGS_PATH: "./cicd_ffi.py" | ||
UDL_PATH: "./cicd_ffi/src/cicd_ffi.udl" | ||
ZIP_NAME: "cicd_ffi-${{ matrix.triple.target }}.zip" | ||
name: Publish artifacts for ${{ matrix.triple.os }} with ${{ matrix.triple.target }} | ||
runs-on: ${{ matrix.triple.os }} | ||
|
||
steps: | ||
# Get current tag to use as the release name. | ||
- name: Get current tag | ||
id: tag | ||
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | ||
|
||
# Get current date to use as the release as part of the release name. | ||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date --rfc-3339=date)" >> $GITHUB_OUTPUT | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
token: ${{ secrets.PAT }} | ||
fetch-depth: 1 | ||
|
||
- name: Install Rust stable | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: "${{ matrix.triple.target }}" | ||
|
||
- name: Generate Cargo.lock | ||
run: cargo update | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
~/.cargo/.crates.toml | ||
~/.cargo/.crates2.json | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
./target | ||
key: "${{ runner.os }}-rust-${{ matrix.triple.target }}-${{ hashFiles('**/Cargo.lock') }}" | ||
restore-keys: "${{ runner.os }}-rust-${{ matrix.triple.target }}-" | ||
|
||
- name: Build project | ||
run: cargo build --release --target ${{ matrix.triple.target }} | ||
|
||
- name: Build kotlin artifacts | ||
run: cargo run --release --bin uniffi-bindgen generate ${{ env.UDL_PATH }} -l kotlin -o ./ --no-format | ||
|
||
- name: Build python artifacts | ||
run: cargo run --release --bin uniffi-bindgen generate ${{ env.UDL_PATH }} -l python -o ./ --no-format | ||
|
||
- name: Zip artifacts | ||
run: 7z a ${{ env.ZIP_NAME }} ${{ env.KOTLIN_BINDINGS_PATH }} ${{ env.PYTHON_BINDINGS_PATH }} ${{ env.ARTIFACT_FILE_PATH }} | ||
|
||
- name: Upload development binaries to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
release_name: "[${{ steps.tag.outputs.tag }}] - ${{ steps.date.outputs.date }}" | ||
repo_token: ${{ secrets.PAT }} | ||
file: ${{ env.ZIP_NAME }} | ||
asset_name: ${{ env.ZIP_NAME }} | ||
tag: ${{ github.ref }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
name: Update caches | ||
|
||
on: | ||
## Run on every push to the dev branch. | ||
push: | ||
branches: | ||
- master | ||
## Run every Wednesday and Sunday at 00:00 UTC. | ||
schedule: | ||
- cron: "0 0 * * 0,3" | ||
## Manual trigger. | ||
workflow_dispatch: | ||
|
||
jobs: | ||
cache-ubuntu: | ||
strategy: | ||
matrix: | ||
triple: | ||
# x86_64 architecture with the Linux GNU toolchain. | ||
- { os: 'ubuntu-latest', target: 'x86_64-unknown-linux-gnu' } | ||
|
||
name: Update Rust stable caches for ${{ matrix.triple.os }} with ${{ matrix.triple.target }} | ||
runs-on: ${{ matrix.triple.os }} | ||
steps: | ||
# Checkout the repository and all its submodules, only with the latest commit. | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
token: ${{ secrets.PAT }} | ||
fetch-depth: 1 | ||
|
||
# Install Rust stable. | ||
- name: Install Rust stable | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: "${{ matrix.triple.target }}" | ||
|
||
# Generate the Cargo.lock file. Since we ignore the lockfile on .gitignore, we need to generate it before we can check the cache. | ||
- name: Generate Cargo.lock | ||
run: cargo update | ||
|
||
# Check if a cache exists for the given configuration. | ||
- name: Check cache | ||
id: cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
~/.cargo/.crates.toml | ||
~/.cargo/.crates2.json | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
./target | ||
key: "${{ runner.os }}-rust-${{ matrix.triple.target }}-${{ hashFiles('**/Cargo.lock') }}" | ||
lookup-only: true | ||
|
||
# Build the project if cache not found. | ||
- name: Build project | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: cargo build --workspace --release --target ${{ matrix.triple.target }} | ||
|
||
# Save the cache if not found. | ||
- name: Save cache | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: | | ||
~/.cargo/.crates.toml | ||
~/.cargo/.crates2.json | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
./target | ||
key: "${{ runner.os }}-rust-${{ matrix.triple.target }}-${{ hashFiles('**/Cargo.lock') }}" | ||
|
||
# Since only Ubuntu is used for testing in a daily basis, we only need to cache the other platforms once in a while, for publishing. | ||
cache-non-ubuntu: | ||
strategy: | ||
matrix: | ||
triple: | ||
# ARM64 (Apple Silicon) architecture for macOS. | ||
- { os: 'macos-latest', target: 'aarch64-apple-darwin' } | ||
# x86_64 architecture for macOS. | ||
- { os: 'macos-latest', target: 'x86_64-apple-darwin' } | ||
# x86_64 architecture for Windows using MSVC (Microsoft Visual C++). | ||
- { os: 'windows-latest', target: 'x86_64-pc-windows-msvc' } | ||
|
||
name: Update Rust stable caches for ${{ matrix.triple.os }} with ${{ matrix.triple.target }} | ||
runs-on: ${{ matrix.triple.os }} | ||
# if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} | ||
steps: | ||
# Checkout the repository and all its submodules, only with the latest commit. | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
token: ${{ secrets.PAT }} | ||
fetch-depth: 1 | ||
|
||
# Install Rust stable. | ||
- name: Install Rust stable | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: "${{ matrix.triple.target }}" | ||
|
||
# Generate the Cargo.lock file. Since we ignore the lockfile on .gitignore, we need to generate it before we can check the cache. | ||
- name: Generate Cargo.lock | ||
run: cargo update | ||
|
||
# Check if a cache exists for the given configuration. | ||
- name: Check cache | ||
id: cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
~/.cargo/.crates.toml | ||
~/.cargo/.crates2.json | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
./target | ||
key: "${{ runner.os }}-rust-${{ matrix.triple.target }}-${{ hashFiles('**/Cargo.lock') }}" | ||
lookup-only: true | ||
|
||
# Build the project if cache not found. | ||
- name: Build project | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: cargo build --workspace --release --target ${{ matrix.triple.target }} | ||
|
||
# Save the cache if not found. | ||
- name: Save cache | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: | | ||
~/.cargo/.crates.toml | ||
~/.cargo/.crates2.json | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
./target | ||
key: "${{ runner.os }}-rust-${{ matrix.triple.target }}-${{ hashFiles('**/Cargo.lock') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"rustc_fingerprint":8006516878952857912,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.71.0 (8ede3aae2 2023-07-12)\nbinary: rustc\ncommit-hash: 8ede3aae28fe6e4d52b38157d7bfe0d3bceef225\ncommit-date: 2023-07-12\nhost: x86_64-pc-windows-msvc\nrelease: 1.71.0\nLLVM version: 16.0.5\n","stderr":""},"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\Augusto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"12744816824612481171":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\Augusto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""}},"successes":{}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
|
||
members = [ | ||
"cicd_ffi", | ||
"cicd_tests", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "cicd_ffi" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[[bin]] | ||
name = "uniffi-bindgen" | ||
path = "./src/uniffi-bindgen.rs" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[lib] | ||
crate-type = ["cdylib"] | ||
name = "cicd_ffi" | ||
|
||
[dependencies] | ||
cicd_tests = { path = "../cicd_tests" } | ||
uniffi = { version = "0.24.1", features = ["cli"] } | ||
|
||
[build-dependencies] | ||
uniffi = { version = "0.24.1", features = ["build"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fn main() { uniffi::generate_scaffolding("./src/cicd_ffi.udl",).unwrap(); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace cicd_ffi { | ||
|
||
|
||
}; | ||
|
||
[Enum] | ||
interface SchemaName { | ||
Name(string name); | ||
Authorization(string authorization); | ||
SchemaNameAndAuthorization(string name, string authorization); | ||
}; | ||
|
||
interface CreateSchema { | ||
constructor(boolean if_not_exists, SchemaName schema_name); | ||
|
||
boolean if_not_exists(); | ||
|
||
|
||
SchemaName schema_name(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub use cicd_tests::create_schema::{ | ||
CreateSchema, | ||
SchemaName, | ||
}; | ||
|
||
uniffi::include_scaffolding!("cicd_ffi"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
uniffi::uniffi_bindgen_main() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "cicd_tests" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
serde = { version = "1.0.96", features = ["derive"] } | ||
serde_json = "1.0.96" | ||
anyhow = "1.0.71" |
Oops, something went wrong.