Merge pull request #401 from spacemeshos/dependabot/cargo/serde_json-… #1341
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: arduino/setup-protoc@v3 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/[email protected] | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo check --workspace --all-features | |
test: | |
name: Test Suite | |
needs: | |
- check | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 15 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: [self-hosted, linux, x64, intel] | |
- os: ubuntu-latest-arm-8-cores | |
rustflags: --cfg=aes_armv8 | |
- os: [self-hosted, macos, arm64] | |
rustflags: --cfg=aes_armv8 | |
- os: macos-13 | |
toolchain: stable | |
- os: windows-2019 | |
steps: | |
- uses: arduino/setup-protoc@v3 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/[email protected] | |
- if: matrix.os == 'ubuntu-latest-arm-8-cores' | |
run: sudo apt-get update && sudo apt-get install -y libpocl2 pocl-opencl-icd ocl-icd-opencl-dev | |
name: Install dependencies for testing openCL on Linux | |
- if: matrix.os == 'windows-2019' | |
name: Install dependencies for testing openCL on Windows | |
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: Benchmarks | |
run: cargo bench --no-run | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
- name: Tests | |
run: cargo test --workspace --exclude scrypt-ocl | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
- name: Test scrypt-ocl crate | |
if: matrix.os != 'windows-2019' | |
run: cargo test -p scrypt-ocl -- --test-threads=1 | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
fmt: | |
name: Rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/[email protected] | |
with: | |
components: rustfmt | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo fmt --all -- --check | |
clippy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: arduino/setup-protoc@v3 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
components: clippy | |
toolchain: stable | |
- 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: [self-hosted, linux, x64, intel] | |
steps: | |
- uses: arduino/setup-protoc@v3 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install opencl | |
run: sudo apt-get update && sudo apt-get install -y libpocl2 pocl-opencl-icd ocl-icd-opencl-dev | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install stable | |
uses: dtolnay/[email protected] | |
with: | |
components: llvm-tools-preview | |
- name: cargo install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: cargo llvm-cov | |
run: cargo llvm-cov --locked --lcov --output-path lcov.info --workspace --ignore-filename-regex "main.rs" -- --test-threads=1 | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
build: | |
name: Build library | |
runs-on: ${{ matrix.os }} | |
needs: | |
- test | |
- fmt | |
- clippy | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: [self-hosted, linux, x64, intel] | |
dylib: libpost.so | |
staticlib: libpost.a | |
artifact-name: linux | |
- os: ubuntu-latest-arm-8-cores | |
dylib: libpost.so | |
staticlib: libpost.a | |
rustflags: --cfg=aes_armv8 | |
artifact-name: linux-arm64 | |
- os: [self-hosted, macos, arm64] | |
dylib: libpost.dylib | |
staticlib: libpost.a | |
rustflags: --cfg=aes_armv8 | |
artifact-name: macos-m1 | |
- os: macos-13 | |
dylib: libpost.dylib | |
staticlib: libpost.a | |
artifact-name: macos | |
- os: windows-2019 | |
dylib: post.dll | |
staticlib: post.lib | |
artifact-name: windows | |
steps: | |
- if: matrix.os == 'ubuntu-latest-arm-8-cores' | |
run: sudo apt-get update && sudo apt-get install -y ocl-icd-opencl-dev | |
name: Install opencl | |
- if: matrix.os == 'windows-2019' | |
name: Install opencl | |
run: vcpkg install opencl | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: dtolnay/[email protected] | |
- 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: Build clib | |
run: cargo build -p post-cbindings --profile release-clib | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libpost-${{ matrix.artifact-name }} | |
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 }} | |
- name: Archive profiler artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: profiler-${{ matrix.artifact-name }} | |
path: | | |
target/release/profiler${{ matrix.os == 'windows-2019' && '.exe' || '' }} | |
if-no-files-found: error | |
- uses: arduino/setup-protoc@v3 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build service | |
run: cargo build -p service --release | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
- name: Archive service artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: post-service-${{ matrix.artifact-name }} | |
path: | | |
target/release/post-service${{ matrix.os == 'windows-2019' && '.exe' || '' }} | |
if-no-files-found: error | |
- name: Build k2pow service | |
run: cargo build -p k2pow-service --release | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
- name: Archive k2pow service artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: k2pow-service-${{ matrix.artifact-name }} | |
path: | | |
target/release/k2pow-service${{ 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@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
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 }} |