Skip to content

Merge remote-tracking branch 'origin/refactor-core-again' #67

Merge remote-tracking branch 'origin/refactor-core-again'

Merge remote-tracking branch 'origin/refactor-core-again' #67

Workflow file for this run

name: Rust CI
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
jobs:
# Check and lint source code
check:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- name: Install cargo-deb
uses: actions-rs/[email protected]
with:
crate: cargo-deb
version: latest
- name: Install cargo-sweep
uses: actions-rs/[email protected]
with:
crate: cargo-sweep
version: latest
- name: Restore core cache
uses: actions/cache/restore@v3
with:
key: core
path: |
~/.cargo/registry
~/.cargo/git
target
- name: Track target/ cache files for cleanup
uses: actions-rs/cargo@v1
with:
command: sweep
args: --stamp
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- name: Clean up target cache
uses: actions-rs/cargo@v1
with:
command: sweep
args: --file
- name: Update core cache for builds on main
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/cache/save@v3
with:
key: core-${{ github.run_id }}
path: |
~/.cargo/registry
~/.cargo/git
target
# Pre-build test assets
build-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Install cargo-sweep
uses: actions-rs/[email protected]
with:
crate: cargo-sweep
version: latest
- name: Restore cache
uses: actions/cache/restore@v3
with:
key: test
path: |
~/.cargo/registry
~/.cargo/git
target
- name: Track target/ cache files for cleanup
uses: actions-rs/cargo@v1
with:
command: sweep
args: --stamp
- name: Pre-build tests
uses: actions-rs/cargo@v1
with:
command: build
args: --tests
- name: Clean up target cache
uses: actions-rs/cargo@v1
with:
command: sweep
args: --file
- name: Update cache for builds on main
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/cache/save@v3
with:
key: test-${{ github.run_id }}
path: |
~/.cargo/registry
~/.cargo/git
target
# Run per-package tests
test:
runs-on: ubuntu-latest
needs: [ "build-tests" ]
continue-on-error: true
strategy:
fail-fast: false
matrix:
package: [ core, rpc, client, engine, daemon ]
steps:
- uses: actions/checkout@v3
- name: Setup toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Restore cache
uses: actions/cache/restore@v3
with:
key: test
path: |
~/.cargo/registry
~/.cargo/git
target
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: -p dsf-${{ matrix.package }}
# Build release binaries
build:
runs-on: ${{ matrix.os }}
needs: [ "check" ]
permissions:
packages: write
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
use_cross: true
docker: amd64
- target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
use_cross: true
docker: armv7
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
use_cross: true
docker: arm64
- target: x86_64-apple-darwin
os: macos-latest
steps:
- uses: actions/checkout@v3
- uses: FranzDiebold/github-env-vars-action@v2
- name: Configure toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.target }}
override: true
- name: Install cargo-sweep
uses: actions-rs/[email protected]
with:
crate: cargo-sweep
version: latest
- name: Install cargo-deb
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions-rs/[email protected]
with:
crate: cargo-deb
version: latest
- name: Restore target cache
uses: actions/cache/restore@v3
with:
key: build-${{ matrix.target }}
path: |
~/.cargo/registry
~/.cargo/git
target
- name: Track target/ cache files for cleanup
uses: actions-rs/cargo@v1
with:
command: sweep
args: --stamp
- name: Set cross compilation flag if required
if: ${{ matrix.use_cross }}
run: |
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
- name: Build release
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use_cross }}
command: build
args: --release --target ${{ matrix.target }}
- name: Clean up target cache
uses: actions-rs/cargo@v1
with:
command: sweep
args: --file
- name: Update target cache
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/cache/save@v3
with:
key: build-${{ matrix.target }}-${{ github.run_id }}
path: |
~/.cargo/registry
~/.cargo/git
target
- name: Create .tgz archive
run: |
tar -cvf target/dsf-${{ matrix.target }}.tgz -C target/${{ matrix.target }}/release/ dsfd dsfc
- name: Create .deb archive for ubuntu/debian targets
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cd ${{ github.workspace }}/daemon && cargo deb --no-build --no-strip --target ${{ matrix.target }}
cd ${{ github.workspace }}/client && cargo deb --no-build --no-strip --target ${{ matrix.target }}
- name: Login to GHCR (for publishing)
if: ${{ matrix.docker != '' }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create docker image if enabled
if: ${{ matrix.docker != '' }}
run: |
docker buildx bake ${{ matrix.docker }} --push
docker push ghcr.io/dist-svc/dsf:${{ matrix.docker }}
- name: Store CI artifacts
uses: actions/upload-artifact@v2
with:
name: dsfd-${{ matrix.target }}
path: |
target/*.tgz
target/debian/*.deb
# Update package manifests
publish:
runs-on: ubuntu-latest
needs: [ "build", "test" ]
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- uses: FranzDiebold/github-env-vars-action@v2
- name: Login to GHCR (for publishing)
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Update docker manifest
run: |
make docker-pull
make docker-publish
make docker-inspect