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

Improve: Use revamped Reloaded GitHub Actions & Fix Compile Warnings #10

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ on:
branches: [ master, refactor-reloaded3-compliance, support-android-and-bsd ]
tags:
- '*'
paths:
- 'src/**'
pull_request:
branches: [ master, refactor-reloaded3-compliance, support-android-and-bsd ]
paths:
- 'src/**'
workflow_dispatch:

jobs:
Expand Down
46 changes: 20 additions & 26 deletions .github/workflows/deploy-mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
name: Deploy Documentation
name: MkDocs Build and Deploy

# Controls when the action will run.
on:
# Triggers the workflow on push on the master branch
push:
branches: [ main, master, refactor-reloaded3-compliance ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
push:
branches: [ main, master ]
paths:
- "mkdocs.yml"
- "docs/**"
pull_request:
branches: [ main, master ]
paths:
- "mkdocs.yml"
- "docs/**"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
permissions:
contents: read
pages: write
id-token: write
steps:

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Branch
uses: actions/checkout@v2
with:
submodules: recursive

# Deploy MkDocs
- name: Deploy MkDocs
# You may pin to the exact commit or the version.
# uses: mhausenblas/mkdocs-deploy-gh-pages@66340182cb2a1a63f8a3783e3e2146b7d151a0bb
uses: mhausenblas/mkdocs-deploy-gh-pages@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REQUIREMENTS: ./docs/requirements.txt
uses: Reloaded-Project/devops-mkdocs@v1
with:
requirements: ./docs/requirements.txt
publish-to-pages: ${{ github.event_name == 'push' }}
checkout-current-repo: true
215 changes: 120 additions & 95 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,162 +1,187 @@
name: Rust Build, Test & Publish
name: Test, Upload Coverage and Release Rust

on:
push:
branches: [ main, master, optimize-for-size ]
tags:
- '*'
paths:
- 'src-rust/**'
pull_request:
branches: [ main, master, optimize-for-size ]
paths:
- 'src-rust/**'
workflow_dispatch:

env:
build-with-pgo: false

jobs:
test-native:
runs-on: ${{ matrix.os }}
build-and-test-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- id: test-rust
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/test-and-coverage@v1 # upgrade if needed
with:
rust_project_path: src-rust
upload_coverage: true
rust_branch: nightly

test-wine:
runs-on: ubuntu-latest
target: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, aarch64-unknown-linux-gnu]
features: ["c_exports", "c_exports,size_opt", "c_exports,size_opt,no_format", "c_exports,size_opt,no_format,all_private"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

- id: test-rust
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/test-in-wine@v1 # upgrade if needed
- name: Build C Libraries and Run Tests
uses: Reloaded-Project/devops-rust-lightweight-binary@v1
with:
rust_project_path: src-rust
rust_branch: nightly
rust-project-path: src-rust
crate-name: ${{ github.event.repository.name }}
target: ${{ matrix.target }}
use-pgo: ${{ env.build-with-pgo }}
use-cross: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }}
features: ${{ matrix.features }}
build-library: true
run-tests-and-coverage: true
codecov-token: ${{ secrets.CODECOV_TOKEN }}

build-c-libs-linux:
runs-on: ${{ matrix.os }}
build-and-test-macos-x86:
runs-on: macos-13
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
target: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, aarch64-unknown-linux-gnu]
features: ["c_exports", "c_exports,size_opt", "c_exports,size_opt,no_format", "c_exports,size_opt,no_format,all_private"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- id: build-libs
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/build-c-library@v1

- name: Build C Libraries and Run Tests
uses: Reloaded-Project/devops-rust-lightweight-binary@v1
with:
rust_project_path: src-rust
target: ${{ matrix.target }}
rust-project-path: src-rust
crate-name: ${{ github.event.repository.name }}
target: x86_64-apple-darwin
use-pgo: ${{ env.build-with-pgo }}
use-cross: false
features: ${{ matrix.features }}
use_cross: true
build-library: true
run-tests-and-coverage: true
codecov-token: ${{ secrets.CODECOV_TOKEN }}

build-c-libs-macos:
runs-on: ${{ matrix.os }}
build-and-test-macos-arm:
runs-on: macos-14
strategy:
fail-fast: false
matrix:
os: [macos-latest]
target: [x86_64-apple-darwin, aarch64-apple-darwin]
features: ["c_exports", "c_exports,size_opt", "c_exports,size_opt,no_format", "c_exports,size_opt,no_format,all_private"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- id: build-libs
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/build-c-library@v1

- name: Build C Libraries and Run Tests
uses: Reloaded-Project/devops-rust-lightweight-binary@v1
with:
rust_project_path: src-rust
target: ${{ matrix.target }}
rust-project-path: src-rust
crate-name: ${{ github.event.repository.name }}
target: aarch64-apple-darwin
use-pgo: ${{ env.build-with-pgo }}
use-cross: false
features: ${{ matrix.features }}
build-library: true
run-tests-and-coverage: true
codecov-token: ${{ secrets.CODECOV_TOKEN }}

build-c-libs-windows:
runs-on: ${{ matrix.os }}
build-and-test-windows:
strategy:
fail-fast: false
matrix:
os: [windows-latest]
target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, aarch64-pc-windows-msvc]
include:
# Native Windows builds with testing
- os: windows-latest
target: x86_64-pc-windows-msvc
run_tests: true
- os: windows-latest
target: i686-pc-windows-msvc
run_tests: true
# aarch64 Windows build without testing
- os: windows-latest
target: aarch64-pc-windows-msvc
run_tests: false # no native runner
# Wine builds (on Linux)
- os: ubuntu-latest
target: x86_64-pc-windows-gnu
run_tests: true
- os: ubuntu-latest
target: i686-pc-windows-gnu
run_tests: true
features: ["c_exports,external_processes", "c_exports,size_opt,external_processes", "c_exports,size_opt,no_format,external_processes", "c_exports,size_opt,no_format", "c_exports,size_opt,no_format,all_private"]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- id: build-libs
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/build-c-library@v1

- name: Build C Libraries and Run Tests
uses: Reloaded-Project/devops-rust-lightweight-binary@v1
with:
rust_project_path: src-rust
rust-project-path: src-rust
crate-name: ${{ github.event.repository.name }}
target: ${{ matrix.target }}
use-pgo: ${{ env.build-with-pgo }}
use-cross: ${{ matrix.os == 'ubuntu-latest' || matrix.target == 'aarch64-pc-windows-msvc' }}
features: ${{ matrix.features }}
build-library: true
run-tests-and-coverage: ${{ matrix.run_tests }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}

# Note: The GitHub Runner Images will contain an up to date Rust Stable Toolchain
# thus as per recommendation of cargo-semver-checks, we're using stable here.
- name: Run cargo-semver-checks
if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/tags/')
run: |
rustup target add ${{ matrix.target }}
cargo install cargo-semver-checks --locked
cargo semver-checks --target ${{ matrix.target }} --features ${{ matrix.features }}

build-c-headers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Generate C++ bindings
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/generate-bindings@v1
uses: Reloaded-Project/devops-rust-cbindgen@v1
with:
rust_project_path: src-rust
config_file: cbindgen_cpp.toml
header_file: bindings_cpp.hpp
rust-project-path: src-rust
config-file: cbindgen_cpp.toml
output-header-file: bindings_cpp.hpp

- name: Generate C bindings
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/generate-bindings@v1
uses: Reloaded-Project/devops-rust-cbindgen@v1
with:
rust_project_path: src-rust
config_file: cbindgen_c.toml
header_file: bindings_c.h

publish-artifacts:
needs: ["build-c-headers", "build-c-libs-windows", "build-c-libs-linux", "build-c-libs-macos", "test-wine", "test-native"]
# Publish only on tags
if: startsWith(github.ref, 'refs/tags/')
rust-project-path: src-rust
config-file: cbindgen_c.toml
output-header-file: bindings_c.h

publish-crate:
permissions:
contents: write
needs: [build-and-test-linux, build-and-test-macos-x86, build-and-test-macos-arm, build-and-test-windows, build-c-headers]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

- name: ↙️ Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts

- name: Compress Artifacts
shell: bash
run: |
dir="artifacts" # Replace with your subdirectory
for subdir in "$dir"/*; do
if [ -d "$subdir" ]; then
base=$(basename "$subdir")
zip -r "$dir/$base.zip" "$subdir"
rm -r "$subdir"
fi
done
ls -A ./artifacts

- name: GitHub Release Artifacts
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/*

- name: Publish to crates.io
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/publish-crate@v1
- name: Publish Rust Crate and Artifacts
uses: Reloaded-Project/devops-publish-action@v1
with:
rust_project_path: src-rust
token: ${{ secrets.CRATES_IO_TOKEN }}
crates-io-token: ${{ secrets.CRATES_IO_TOKEN }}
rust-project-paths: |
src-rust
4 changes: 1 addition & 3 deletions src-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ readme = "../README.md"
repository = "https://github.com/Reloaded-Project/Reloaded.Memory.Buffers"
license = "GPL-3.0"

[lib]
crate-type = ["cdylib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["std"]
Expand All @@ -22,6 +19,7 @@ no_format = [] # Removes string formatting (less detailed errors) for binary siz
all_private = [] # No memory mapped files, memory is not shared.
size_opt = ["nightly"]
nightly = [] # Optimizations for nightly builds.
direct-mmap = [] # If set, uses built-in code for memory mapping. This is auto activated in build.rs for supported platforms.

[dependencies]
concat-string = "1.0.1"
Expand Down
11 changes: 11 additions & 0 deletions src-rust/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn main() {
// This defines a fallback to mmap-rs if one of the explicit memory mapped file implementations
// is not available.
if cfg!(any(
target_os = "macos",
target_os = "windows",
target_os = "linux"
)) {
println!("cargo:rustc-cfg=feature=\"direct-mmap\"");
}
}
2 changes: 2 additions & 0 deletions src-rust/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"
Loading
Loading