Skip to content

merge some build script #1

New issue

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

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

Already on GitHub? # to your account

Merged
merged 31 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
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
11 changes: 10 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ rustdocflags = ["-Clinker=rust-lld.exe"]

# This cfg will reduce the size of `windows::core::Error` from 16 bytes to 4 bytes
[target.'cfg(target_os = "windows")']
rustflags = ["--cfg", "windows_slim_errors"]
rustflags = ["--cfg", "windows_slim_errors"]

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

[target.armv7-unknown-linux-gnueabi]
linker = "arm-linux-gnueabi-gcc"
218 changes: 190 additions & 28 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ on:
push:
branches:
- master
- dev
pull_request:
branches:
- master

permissions:
contents: read

env:
RUSTFLAGS: -Dwarnings

jobs:
build:
name: Build and Test
runs-on: ${{ matrix.os }}
build-and-test-windows:
name: Build and Test on Windows
runs-on: windows-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
# - os: ubuntu-latest
# target: aarch64-unknown-linux-gnu
# - os: ubuntu-latest
# target: armv7-unknown-linux-gnueabihf
target: [x86_64-pc-windows-msvc, x86_64-pc-windows-gnu]

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -37,12 +36,32 @@ jobs:
- name: Install Python dependencies
run: pip install -r ./tests/requirements.txt

- name: Setup msys2 toolchains
if: endsWith(matrix.target, '-gnu')
uses: msys2/setup-msys2@v2
with:
release: false
install: mingw-w64-x86_64-gcc mingw-w64-i686-gcc

- name: Prepare env for windows
if: endsWith(matrix.target, '-gnu')
run: |
# Add symlinks to the target-specific GNU sysroots for Clang
New-Item -Path "C:\Program Files\LLVM\x86_64-w64-mingw32" -ItemType SymbolicLink -Value "C:\msys64\mingw64\x86_64-w64-mingw32"
New-Item -Path "C:\Program Files\LLVM\i686-w64-mingw32" -ItemType SymbolicLink -Value "C:\msys64\mingw64\i686-w64-mingw32"
# Add paths to GCC executables to PATH
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\msys64\mingw32\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# Configure CC_<target> environment variables
echo "CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
echo "CC_i686_pc_windows_gnu=i686-w64-mingw32-gcc" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
# echo "HOST_CC=x86_64-w64-mingw32-gcc" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
components: llvm-tools-preview,clippy,rustfmt
components: llvm-tools-preview

- name: Install nextest
uses: taiki-e/install-action@nextest
Expand All @@ -55,32 +74,175 @@ jobs:
restore-keys: |
${{ runner.os }}-cargo-

- name: Build
run: cargo build --profile ci --workspace --target ${{ matrix.target }} --features full

- name: Run Rust tests
run: cargo nextest run --workspace --no-fail-fast --features full --target ${{ matrix.target }}

- name: Run Python tests
env:
EDGELINK_BUILD_TARGET: ${{ matrix.target }}
EDGELINK_BUILD_PROFILE: ci
run: pytest ./tests -v

build-and-test-linux:
name: Build and Test on Linux (x86-64)
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'

- name: Install Python dependencies
run: pip install -r ./tests/requirements.txt

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
components: llvm-tools-preview

- name: Install nextest
uses: taiki-e/install-action@nextest

- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Build
run: cargo build --profile ci --workspace --target ${{ matrix.target }} --features full

- name: Run Rust tests
run: cargo nextest run --workspace --no-fail-fast --features full --target ${{ matrix.target }}

- name: Run Python tests
env:
EDGELINK_BUILD_TARGET: ${{ matrix.target }}
EDGELINK_BUILD_PROFILE: ci
run: pytest ./tests -v

build-arm-linux:
name: Build on ARM Linux
runs-on: ubuntu-latest
strategy:
matrix:
target: [aarch64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, armv7-unknown-linux-gnueabi]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
components: llvm-tools-preview

- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Install cross-compilation tools for ARM 64
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross
sudo apt-get install -y gcc-aarch64-linux-gnu libc-dev-arm64-cross

- name: Install cross-compilation tools for ARM 32
- name: Install cross-compilation tools for ARM 32 (gnueabihf)
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
sudo apt-get install -y gcc-arm-linux-gnueabihf libc-dev-armhf-cross

- name: Check code formatting
run: cargo fmt --check --all
- name: Install cross-compilation tools for ARM 32 (gnueabi)
if: matrix.target == 'armv7-unknown-linux-gnueabi'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabi libc-dev-armel-cross

- name: Build
run: cargo build --profile ci --workspace --target ${{ matrix.target }} --features full

- name: Run Rust tests
run: cargo nextest run --workspace --no-fail-fast --features full --target ${{ matrix.target }}
fmt:
name: Format checking
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: x86_64-unknown-linux-gnu
components: rustfmt
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check code formatting
run: cargo fmt --check --all

- name: Run doc tests
run: cargo test --doc --profile ci --workspace --target ${{ matrix.target }} --features full
clippy:
name: Format and Clippy
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: x86_64-unknown-linux-gnu
components: clippy
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Clippy
run: cargo clippy --all-features --tests --all

- name: Run Python tests
env:
EDGELINK_BUILD_TARGET: ${{ matrix.target }}
EDGELINK_BUILD_PROFILE: ci
run: pytest ./tests -v
doctest:
name: Run doctests
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: x86_64-unknown-linux-gnu
components: clippy
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Doctest
run: cargo test --doc --profile ci --workspace --features full
25 changes: 2 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "edgelink-app"
version = "0.1.0"
edition = "2021"
rust_version = "1.77.2"
rust-version = "1.77.2"
readme = "README.md"
homepage = "https://github.com/oldrev/edgelink.rs"
description = "EdgeLink is a Node-RED compatible run-time engine in Rust."
Expand Down Expand Up @@ -36,7 +36,6 @@ opt-level = 1 # Enables thin local LTO and some optimizations.

[workspace.dependencies]
bincode = "1.3.3"
linkme = "0.3.28"
async-trait = "0.1.81"
anyhow = { version = "1.0.86", features = ["backtrace"] }
log = "0.4.20"
Expand Down Expand Up @@ -68,14 +67,13 @@ itertools = "0.13.0"
arrayvec = "0.7.6"
smallvec = "1.13.2"
smallstr = { version = "0.3.0", features = ["serde", "std", "union"] }

inventory = "0.3.15"

[dependencies]
clap.workspace = true
dirs-next.workspace = true
anyhow.workspace = true
log.workspace = true
linkme.workspace = true
tokio = { workspace = true, features = ["signal"] }
tokio-util.workspace = true
config.workspace = true
Expand Down
Loading