Merge pull request #116 from spacemeshos/108-profile-k2pow #489
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
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
name: CI | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo check --workspace --all-features | |
test: | |
name: Test Suite | |
needs: | |
- check | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-20.04 | |
toolchain: stable | |
- os: [self-hosted, linux, arm64] | |
rustflags: --cfg=aes_armv8 | |
toolchain: nightly-2023-06-27 # required for AES (https://docs.rs/aes/0.8.2/aes/#armv8-intrinsics-nightly-only) | |
- os: [self-hosted, macos, arm64] | |
rustflags: --cfg=aes_armv8 | |
toolchain: nightly-2023-06-27 # required for AES (https://docs.rs/aes/0.8.2/aes/#armv8-intrinsics-nightly-only) | |
- os: macos-latest | |
toolchain: stable | |
- os: windows-2019 | |
toolchain: stable | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
- if: matrix.os == 'ubuntu-20.04' | |
run: sudo apt-get install -y libpocl2 mesa-opencl-icd ocl-icd-opencl-dev | |
name: Install dependencies for testing openCL | |
- if: matrix.os == 'windows-2019' | |
name: Install dependencies for linking openCL | |
run: | | |
choco install -y wget unzip opencl-intel-cpu-runtime | |
wget https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v2023.04.17/OpenCL-SDK-v2023.04.17-Win-x64.zip | |
unzip -j OpenCL-SDK-v2023.04.17-Win-x64.zip OpenCL-SDK-v2023.04.17-Win-x64/lib/OpenCL.lib | |
- uses: Swatinem/rust-cache@v2 | |
- name: Test post crate | |
run: cargo test --all-features --release | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
# https://github.com/tevador/RandomX/issues/262 | |
# https://github.com/tari-project/randomx-rs/issues/48 | |
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk" | |
- name: Test scrypt-ocl crate | |
if: matrix.os != 'windows-2019' | |
run: cargo test -p scrypt-ocl --all-features --release -- --test-threads=1 | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
# https://github.com/tevador/RandomX/issues/262 | |
# https://github.com/tari-project/randomx-rs/issues/48 | |
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk" | |
- name: Test ffi crate | |
run: cargo test -p post-cbindings --all-features --release -- --test-threads=1 | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
# https://github.com/tevador/RandomX/issues/262 | |
# https://github.com/tari-project/randomx-rs/issues/48 | |
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk" | |
fmt: | |
name: Rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo fmt --all -- --check | |
clippy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
components: clippy | |
toolchain: nightly-2023-06-27 | |
- uses: Swatinem/rust-cache@v2 | |
- name: Annotate commit with clippy warnings | |
uses: actions-rs/clippy-check@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
args: --all-features --workspace | |
coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install stable | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: llvm-tools-preview | |
- name: cargo install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: cargo generate-lockfile | |
if: hashFiles('Cargo.lock') == '' | |
run: cargo generate-lockfile | |
- name: cargo llvm-cov | |
run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
build: | |
name: Build library | |
runs-on: ${{ matrix.os }} | |
needs: | |
- test | |
- fmt | |
- clippy | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-20.04 | |
dylib: libpost.so | |
staticlib: libpost.a | |
artifact-name: linux | |
toolchain: stable | |
- os: [self-hosted, linux, arm64] | |
dylib: libpost.so | |
staticlib: libpost.a | |
rustflags: --cfg=aes_armv8 | |
artifact-name: linux-arm64 | |
toolchain: nightly-2023-06-27 # required for AES (https://docs.rs/aes/0.8.2/aes/#armv8-intrinsics-nightly-only) | |
- os: [self-hosted, macos, arm64] | |
dylib: libpost.dylib | |
staticlib: libpost.a | |
rustflags: --cfg=aes_armv8 | |
artifact-name: macos-m1 | |
toolchain: nightly-2023-06-27 # required for AES (https://docs.rs/aes/0.8.2/aes/#armv8-intrinsics-nightly-only) | |
- os: macos-latest | |
dylib: libpost.dylib | |
staticlib: libpost.a | |
artifact-name: macos | |
toolchain: stable | |
- os: windows-2019 | |
dylib: post.dll | |
staticlib: post.lib | |
artifact-name: windows | |
toolchain: stable | |
steps: | |
- if: matrix.os == 'ubuntu-20.04' | |
run: sudo apt-get install -y libpocl2 mesa-opencl-icd ocl-icd-opencl-dev | |
name: Install opencl | |
- if: matrix.os == 'windows-2019' | |
name: Install opencl | |
run: vcpkg install opencl | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ join( matrix.os, '-' ) }} | |
- if: matrix.os == 'windows-2019' | |
name: Download OpenCL.lib | |
run: | | |
choco install -y wget unzip | |
wget https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v2023.04.17/OpenCL-SDK-v2023.04.17-Win-x64.zip | |
unzip -j OpenCL-SDK-v2023.04.17-Win-x64.zip OpenCL-SDK-v2023.04.17-Win-x64/lib/OpenCL.lib | |
- name: Version suffix (for release only) | |
id: version | |
run: echo "suffix=${{ github.ref_type == 'tag' && '-' || ''}}${{ github.ref_type == 'tag' && github.ref || ''}}" >> $GITHUB_OUTPUT | |
- name: Build clib | |
run: cargo build -p post-cbindings --profile release-clib | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
# https://github.com/tevador/RandomX/issues/262 | |
# https://github.com/tari-project/randomx-rs/issues/48 | |
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk" | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: libpost-${{ matrix.artifact-name }}${{ steps.version.output.suffix }} | |
path: | | |
ffi/post.h | |
target/release-clib/${{ matrix.dylib }} | |
target/release-clib/${{ matrix.staticlib }} | |
if-no-files-found: error | |
- name: Build profiler tool | |
run: cargo build -p profiler --release | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
# https://github.com/tevador/RandomX/issues/262 | |
# https://github.com/tari-project/randomx-rs/issues/48 | |
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk" | |
- name: Archive profiler artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: profiler-${{ matrix.artifact-name }}${{ steps.version.output.suffix }} | |
path: | | |
target/release/profiler${{ matrix.os == 'windows-2019' && '.exe' || '' }} | |
if-no-files-found: error | |
release: | |
name: Publish release | |
if: github.event_name == 'push' && github.ref_type == 'tag' | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: ./artifacts | |
- name: List artifacts | |
run: ls -R ./artifacts | |
- name: Create a draft release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ github.ref }} | |
draft: true | |
prerelease: false | |
- name: Pack artifacts | |
run: > | |
mkdir ./assets; | |
for dir in ./artifacts/*/; do | |
zip -o -j -r "./assets/$(basename "$dir")-$TAG.zip" "$dir"; | |
done | |
env: | |
TAG: ${{ github.ref_name }} | |
- name: Upload Release Assets | |
run: gh release upload $TAG ./assets/*.zip | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAG: ${{ github.ref_name }} |