Skip to content

Update Cargo.lock

Update Cargo.lock #112

Workflow file for this run

name: New CI
on:
push:
branches:
'master'
tags:
'[0-9]+\.[0-9]+\.[0-9]+'
pull_request:
branches:
- 'master'
paths-ignore:
- 'LICENSE'
- '**/*.md'
- '.github/**/*'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
DEBIAN_FRONTEND: noninteractive
INSTDEPS: "apt-get update && apt-get install -y libclang-dev clang"
RUSTFLAGS: "-C link-arg=-s"
CACHE_PREFIX: "${{ vars.CACHE_PREFIX }}"
jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install build dependencies
run: sudo sh -c "${{ env.INSTDEPS }}"
- run: cargo test --all-features --workspace
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install build dependencies
run: sudo sh -c "${{ env.INSTDEPS }}"
- name: Clippy check
run: cargo clippy --all-targets --all-features --workspace -- -D warnings
docs:
name: Docs
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install build dependencies
run: sudo sh -c "${{ env.INSTDEPS }}"
- name: Check documentation
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --no-deps --document-private-items --all-features --workspace
publish-dry-run:
name: Publish dry run
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Publish dry-run
run: cargo publish -p cherryrgb --dry-run
check-cargo-lock:
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
name: Check Cargo.lock
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- run: cargo fetch --locked
clean:
if: ${{ github.event_name != 'pull_request' }} # If this is a pull request, stop here
name: Clean before matrix build
needs: [test, clippy, rustfmt, docs, publish-dry-run]
runs-on: ubuntu-latest
steps:
- name: Clean target
run: rm -rf target
build:
needs: [clean]
strategy:
matrix:
# Name of the tar archives: <assetprefix>-<tag>-<assetname>.tar.gz
assetprefix: [cherryrgb-rs]
job:
- os: ubuntu-latest
assetname: linux-x86_64
target: x86_64-unknown-linux-gnu
buildopts: "--all --features uhid"
installdeps: true
native: true
- os: macos-latest
assetname: macos-x86_64
target: x86_64-apple-darwin
buildopts: ""
installdeps: false
native: true
- os: windows-latest
assetname: windows-x86_64
target: x86_64-pc-windows-msvc
buildopts: ""
installdeps: false
native: true
- os: ubuntu-latest
assetname: linux-arm64
target: aarch64-unknown-linux-gnu
buildopts: "--all --features uhid"
native: false
imagetag: edge
- os: ubuntu-latest
assetname: linux-i686
target: i686-unknown-linux-gnu
buildopts: "--all --features uhid"
native: false
imagetag: edge
- os: ubuntu-latest
assetname: linux-ppc64le
target: powerpc64le-unknown-linux-gnu
buildopts: "--all --features uhid"
native: false
imagetag: edge
runs-on: ${{ matrix.job.os }}
name: Build for ${{ matrix.job.target }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Initialize CARGO_HOME
shell: bash
# The following must be set from within a shell, because HOME is not preset in a github runner context.
# See also https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
run: echo "CARGO_HOME=${HOME}/.cargo-${{ matrix.job.target }}" >> "$GITHUB_ENV"
- name: Install native build dependencies
if: ${{ matrix.job.installdeps && matrix.job.native }}
run: sudo sh -c "${{ env.INSTDEPS }}"
- name: Retrieve target cache
uses: actions/cache@v3
with:
path: |
target
${{ env.CARGO_HOME }}/bin/
${{ env.CARGO_HOME }}/registry/index/
${{ env.CARGO_HOME }}/registry/cache/
${{ env.CARGO_HOME }}/git/db/
key: ${{ env.CACHE_PREFIX }}${{ matrix.job.target }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ env.CACHE_PREFIX }}${{ matrix.job.target }}
enableCrossOsArchive: true
- name: Build native
if: ${{ matrix.job.native }}
run: |
cargo build --release --target ${{ matrix.job.target }} ${{ matrix.job.buildopts }}
- name: Install cross-rs
id: install_cross
if: ${{ ! matrix.job.native }}
run: test -f ${{ env.CARGO_HOME }}/bin/cross && echo "::notice::cross provided from cache, skipping install" || cargo install cross
- name: Configure cross
id: configure_cross
if: ${{ ! matrix.job.native }}
run: |
cat > Cross.toml << EOM
[target.${{ matrix.job.target }}]
image = "ghcr.io/cross-rs/${{ matrix.job.target }}:${{ matrix.job.imagetag }}"
pre-build = ["${{ env.INSTDEPS }}"]
EOM
- name: Build with cross
id: build_foreign
if: ${{ ! matrix.job.native }}
run: |
${{ env.CARGO_HOME }}/bin/cross build --release --target ${{ matrix.job.target }} ${{ matrix.job.buildopts }}
- name: Update target cache
uses: actions/cache@v3
with:
path: |
target
${{ env.CARGO_HOME }}/bin/
${{ env.CARGO_HOME }}/registry/index/
${{ env.CARGO_HOME }}/registry/cache/
${{ env.CARGO_HOME }}/git/db/
key: ${{ env.CACHE_PREFIX }}${{ matrix.job.target }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ env.CACHE_PREFIX }}${{ matrix.job.target }}
enableCrossOsArchive: true
- name: Generate cmdline help/docs/completions
run: cargo xtask all
- name: Collect artifacts
shell: bash
run: |
mkdir -p artifacts/bin
case "${{ matrix.job.target }}" in
*linux*)
for bin in cli ncli service; do
path=target/${{ matrix.job.target }}/release/cherryrgb_${bin}
test -f ${path} && cp -av ${path} artifacts/bin/ || true
done
miscfiles="*.md LICENSE service/etc udev docs examples target/generated/*"
;;
*windows*)
cp -av target/${{ matrix.job.target }}/release/cherryrgb_cli.exe artifacts/bin/
miscfiles="*.md LICENSE docs examples target/generated/*"
;;
*)
cp -av target/${{ matrix.job.target }}/release/cherryrgb_cli artifacts/bin/
miscfiles="*.md LICENSE docs examples target/generated/*"
;;
esac
cp -av ${miscfiles} artifacts/
afname="${{ matrix.assetprefix }}-${{ github.ref_name }}-${{ matrix.job.assetname }}"
mv artifacts "${afname}"
tar cvzf "${afname}.tar.gz" "${afname}"
echo "${GITHUB_REF}" > github-ref
echo "${GITHUB_SHA}" > commithash
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: cherryrgb-rs
path: |
github-ref
commithash
${{ matrix.assetprefix }}-${{ github.ref_name }}-${{ matrix.job.assetname }}.tar.gz
deploy:
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
needs: [build, check-cargo-lock]
name: Call
uses: ./.github/workflows/cd.yml
secrets: inherit
with:
artifact-id: cherryrgb-rs