Skip to content

Master as a tcp server #894

Master as a tcp server

Master as a tcp server #894

Workflow file for this run

name: CI
on:
push:
branches:
- main
tags:
- "*"
pull_request:
jobs:
# Check formatting and run clippy lints
linting:
strategy:
fail-fast: false
matrix:
rust:
- stable
- beta
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy -- -D warnings
# Build the workspace with the feature permutations not built by default
features:
strategy:
fail-fast: false
matrix:
feature-args:
- "--no-default-features"
- "--no-default-features --features serialization"
- "--no-default-features --features serial"
- "--no-default-features --features tls"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Caching
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: Swatinem/rust-cache@v2
- name: Build the workspace with the features
run: cargo build --release ${{ matrix.feature-args }}
# Run the unit tests on Windows and Linux
test:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
rust:
- stable
- beta
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Caching
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: Swatinem/rust-cache@v2
- name: Run Rust unit tests
run: cargo test
# Build API documentation packages
documentation:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@stable
- name: Install doxygen 1.9.5
run: wget -q https://github.com/stepfunc/ci-files/raw/main/doxygen/doxygen-1.9.5.linux.bin.tar.gz -O- | sudo tar --strip-components=1 -C /usr -xz doxygen-1.9.5
- name: Caching
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: Swatinem/rust-cache@v2
- name: Build FFI and JNI
run: cargo build --release -p dnp3-ffi -p dnp3-ffi-java
- name: Build Rustdoc
run: cargo doc -p dnp3 --no-deps
- name: C bindings
run: cargo run --bin dnp3-bindings -- --c --doxygen --no-tests
- name: .NET bindings
run: cargo run --bin dnp3-bindings -- --dotnet --doxygen --no-tests
- name: Java bindings
run: cargo run --bin dnp3-bindings -- --java
- name: Extract documentation
run: |
mkdir -p ~/doc
cp -a target/doc ~/doc/rust
cp -a ffi/bindings/c/generated/doc/c ~/doc/c
cp -a ffi/bindings/c/generated/doc/cpp ~/doc/cpp
cp -a ffi/bindings/dotnet/dnp3/doc ~/doc/dotnet
cp -a ffi/bindings/java/dnp3/target/apidocs ~/doc/java
rm ffi/bindings/c/generated/logo.png ffi/bindings/c/generated/doxygen-awesome.css
- name: Upload documentation
uses: actions/upload-artifact@v3
with:
name: doc
path: ~/doc
# Build bindings on Windows x64 [64-bit MSVC (Windows 7+) (x86_64-pc-windows-msvc)] and x86 [32-bit MSVC (Windows 7+) (i686-pc-windows-msvc)]
bindings-windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc # 64-bit MSVC (Windows 7+)
test: true
- target: i686-pc-windows-msvc # 32-bit MSVC (Windows 7+)
test: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Caching
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: Swatinem/rust-cache@v2
- name: Create FFI modules DIR
run: mkdir ffi-modules\${{ matrix.target }}
- name: Build FFI
run: cargo build -p dnp3-ffi --release --target ${{ matrix.target }}
- name: Build JNI
run: cargo build -p dnp3-ffi-java --release --target ${{ matrix.target }}
- name: Copy the FFI and JNI libs
shell: pwsh
run: |
Copy-Item -Path ./target/${{ matrix.target }}/release/dnp3_ffi.dll -Destination ffi-modules/${{ matrix.target }}
Copy-Item -Path ./target/${{ matrix.target }}/release/dnp3_ffi.dll.lib -Destination ffi-modules/${{ matrix.target }}
Copy-Item -Path ./target/${{ matrix.target }}/release/dnp3_ffi_java.dll -Destination ffi-modules/${{ matrix.target }}
- name: Upload compiled FFI modules
uses: actions/upload-artifact@v3
with:
name: ffi-modules
path: ffi-modules
- name: Test C Bindings
if: ${{ matrix.test }}
run: cargo run --bin dnp3-bindings -- --c -r ${{ matrix.target }} -a ./target/${{ matrix.target }}/release
- name: Test .NET Bindings
if: ${{ matrix.test }}
run: cargo run --bin dnp3-bindings -- --dotnet -r ${{ matrix.target }} -a ./target/${{ matrix.target }}/release
- name: Test Java
if: ${{ matrix.test }}
run: cargo run --bin dnp3-bindings -- --java -r ${{ matrix.target }} -a ./target/${{ matrix.target }}/release
# Build bindings on MacOS [64-bit macOS (10.7+, Lion+) (x86_64-apple-darwin)]
bindings-macos:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-apple-darwin # 64-bit macOS (10.7+, Lion+)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Caching
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: Swatinem/rust-cache@v2
- name: Create FFI modules dir
run: mkdir -p ffi-modules/${{ matrix.target }}
- name: Build FFI
run: cargo build -p dnp3-ffi --release
- name: Build JNI
run: cargo build -p dnp3-ffi-java --release
- name: Copy the FFI and JNI libs
run: |
cp ./target/release/libdnp3_ffi.dylib ./ffi-modules/${{ matrix.target }}
cp ./target/release/libdnp3_ffi_java.dylib ./ffi-modules/${{ matrix.target }}
- name: Upload compiled FFI modules
uses: actions/upload-artifact@v3
with:
name: ffi-modules
path: ffi-modules
- name: Test .NET bindings
run: cargo run --bin dnp3-bindings -- --dotnet
- name: Test Java bindings
run: cargo run --bin dnp3-bindings -- --java
# Cross-compilation for Linux to produce portable C and JNI libraries
bindings-linux:
env:
# By default, MUSL will not produce a cdylib with dynamic linkage to MUSL LIB C
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-C target-feature=-crt-static"
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-C target-feature=-crt-static"
CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_RUSTFLAGS: "-C target-feature=-crt-static"
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu # 64-bit Linux (kernel 2.6.32+, glibc 2.11+)
- i686-unknown-linux-gnu # 32-bit Linux (kernel 3.2+, glibc 2.17+)
- x86_64-unknown-linux-musl # 64-bit Linux with MUSL
- arm-unknown-linux-gnueabihf # ARMv6 Linux, hardfloat (kernel 3.2, glibc 2.17)
- arm-unknown-linux-musleabihf # ARMv6 Linux with MUSL, hardfloat
- aarch64-unknown-linux-gnu # ARM64 Linux (kernel 4.2, glibc 2.17+)
- aarch64-unknown-linux-musl # ARM64 Linux with MUSL
- armv7-unknown-linux-gnueabihf # ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17)
- arm-unknown-linux-gnueabi # ARMv6 Linux (kernel 3.2, glibc 2.17)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# - name: Caching
# if: ${{ !startsWith(github.ref, 'refs/tags/') }}
# uses: Swatinem/rust-cache@v2
- name: Install Rust Cross
run: cargo install cross
- name: Create FFI modules dir
run: mkdir -p ffi-modules/${{ matrix.target }}
- name: Build FFI
run: cross build -p dnp3-ffi --release --target ${{ matrix.target }}
- name: Build JNI
run: cross build -p dnp3-ffi-java --release --target ${{ matrix.target }}
- name: Copy the FFI and JNI libs
run: |
cp ./target/${{ matrix.target }}/release/libdnp3_ffi.so ./ffi-modules/${{ matrix.target }}
cp ./target/${{ matrix.target }}/release/libdnp3_ffi_java.so ./ffi-modules/${{ matrix.target }}
- name: Upload compiled FFI modules
uses: actions/upload-artifact@v3
with:
name: ffi-modules
path: ffi-modules
guide:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
working-directory: guide
run: yarn install
- name: Build guide
working-directory: guide
run: |
yarn build
mkdir -p ~/doc/guide
mv build/* ~/doc/guide
- name: Upload guide
uses: actions/upload-artifact@v3
with:
name: doc
path: ~/doc
# Package all the generated bindings
packaging:
needs: [documentation, bindings-windows, bindings-macos, bindings-linux]
runs-on: ubuntu-latest
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Cargo CycloneDx
run: cargo install cargo-cyclonedx
- name: Install custom allow-list tool
run: cargo install --git https://github.com/stepfunc/bom-tools.git
- name: Caching
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: Swatinem/rust-cache@v2
- name: Checkout
uses: actions/checkout@v4
- name: Download compiled FFI
uses: actions/download-artifact@v3
with:
name: ffi-modules
path: ffi-modules
- name: Create SBOMs
run: |
for dir in ffi-modules/*; do
target=`basename "${dir}"`
cargo cyclonedx -f json --target $target
mv ./ffi/dnp3-ffi/dnp3-ffi.cdx.json ffi-modules/$target
mv ./ffi/dnp3-ffi-java/dnp3-ffi-java.cdx.json ffi-modules/$target
done
- name: Create FFI third-party-licenses.txt
run: allow-list gen-licenses-dir -l ffi-modules -b dnp3-ffi.cdx.json -c allowed.json > third-party-licenses.txt
- name: Create FFI third-party-licenses-java.txt
run: allow-list gen-licenses-dir -l ffi-modules -b dnp3-ffi-java.cdx.json -c allowed.json > third-party-licenses-java.txt
- name: Package C/C++ bindings
run: cargo run --bin dnp3-bindings -- --c --package ./ffi-modules --options ./packaging.json -f third-party-licenses.txt
- name: Package .NET bindings
run: cargo run --bin dnp3-bindings -- --dotnet --package ./ffi-modules --options ./packaging.json -f third-party-licenses.txt
- name: Package Java bindings
run: cargo run --bin dnp3-bindings -- --java --package ./ffi-modules --options ./packaging.json -f third-party-licenses-java.txt
- name: Upload C/C++ bindings
uses: actions/upload-artifact@v3
with:
name: c-bindings
path: ffi/bindings/c/generated/*
- name: Upload .NET bindings
uses: actions/upload-artifact@v3
with:
name: dotnet-bindings
path: ffi/bindings/dotnet/nupkg/dnp3*
- name: Upload Java bindings
uses: actions/upload-artifact@v3
with:
name: java-bindings
path: ffi/bindings/java/dnp3/target/*.jar
- name: Upload Java pom.xml
uses: actions/upload-artifact@v3
with:
name: java-bindings
path: ffi/bindings/java/dnp3/pom.xml
# Run the conformance tests
conformance:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Caching
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: Swatinem/rust-cache@v2
- name: Build JNI
run: cargo build --release -p dnp3-ffi-java
- name: Build Java bindings
run: cargo run --release --bin dnp3-bindings -- --java
- name: Install Java bindings
shell: bash
run: (cd ffi/bindings/java/dnp3 && sudo mvn install)
- name: Checkout dnp4s
uses: actions/checkout@v4
with:
repository: stepfunc/dnp4s
ssh-key: ${{ secrets.DNP4S_SSH_KEY }}
ref: scala-2.13
path: dnp4s
- name: Build dnp4s
working-directory: dnp4s
run: sudo mvn --batch-mode install
- name: Run the conformance tests
working-directory: conformance
run: sudo mvn --batch-mode scala:run
- name: Upload conformance test results
if: always()
uses: actions/upload-artifact@v3
with:
name: conformance-results
path: conformance/results
release:
needs: [packaging, features, conformance, guide]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Package C Bindings and Conformance Results
run: |
mkdir release
cd artifacts/c-bindings
zip -r ../../release/dnp3-${{github.ref_name}}.zip .
cd ../conformance-results
zip -r ../../release/conformance-results.zip .
- name: Checkout stepfunc/docs
uses: actions/checkout@v4
with:
repository: stepfunc/docs
ssh-key: ${{ secrets.SFIO_DOCS_SSH_KEY }}
path: docs
- name: Upload docs
working-directory: docs
run: |
git config user.name github-actions
git config user.email [email protected]
rm -rf ./dnp3/${{github.ref_name}}
mkdir -p ./dnp3/${{github.ref_name}}
cp -a ../artifacts/doc/* ./dnp3/${{github.ref_name}}
git add -A
git commit -m "[dnp3] release ${{github.ref_name}}"
git push
- name: Import PGP key
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.SFIO_PGP_PRIVATE_KEY }}
passphrase: ${{ secrets.SFIO_PGP_PRIVATE_KEY_PASSPHRASE }}
- name: Login to OSSRH
uses: whelk-io/maven-settings-xml-action@v14
with:
servers: '[{ "id": "ossrh", "username": "${{ secrets.SFIO_OSSRH_USERNAME }}", "password": "${{ secrets.SFIO_OSSRH_PASSWORD }}" }]'
- name: Deploy Java
shell: bash
working-directory: artifacts/java-bindings
run: >
shopt -s extglob &&
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2 -DrepositoryId=ossrh -DpomFile=pom.xml -Dfile=dnp3-${{github.ref_name}}.jar &&
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2 -DrepositoryId=ossrh -DpomFile=pom.xml -Dfile=dnp3-${{github.ref_name}}-sources.jar -Dclassifier=sources &&
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2 -DrepositoryId=ossrh -DpomFile=pom.xml -Dfile=dnp3-${{github.ref_name}}-javadoc.jar -Dclassifier=javadoc
- name: Publish NuGet package
shell: bash
run: dotnet nuget push $(find artifacts/dotnet-bindings/dnp3*.nupkg) -s https://api.nuget.org/v3/index.json -k ${{ secrets.SFIO_NUGET_KEY }}
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
release/*.zip
artifacts/dotnet-bindings/dnp3*
artifacts/java-bindings/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}