ares/.github/workflows/ares-shared.yml

94 lines
3.1 KiB
YAML
Raw Normal View History

2023-03-04 11:23:40 +03:00
on:
workflow_call:
env:
CARGO_TERM_COLOR: always
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
2023-03-04 11:23:40 +03:00
defaults:
run:
working-directory: rust/ares
2023-03-04 11:23:40 +03:00
jobs:
build:
2023-05-20 17:22:21 +03:00
runs-on: 'ubuntu-latest'
2023-03-04 11:23:40 +03:00
steps:
- uses: actions/checkout@v3
# Determine proper nix platform attribute for runner
- name: Determine Nix platform
id: set-nix-platform
working-directory: .
run:
.github/scripts/arch/get-runner-arch ${{ runner.arch }} ${{ runner.os }} > $GITHUB_OUTPUT
# Install nix, required by nix-shell-action
- uses: cachix/install-nix-action@v23
name: Install Nix
with:
extra_nix_config: "extra-experimental-features = nix-command flakes"
2023-05-20 21:50:25 +03:00
2023-12-09 01:09:54 +03:00
- name: Set cache key for dev env
id: set-cache-key
run: |
echo "Determining devshell path for platform ${{ steps.set-nix-platform.outputs.nix-arch }}"
echo "nix-devshell-path=$(nix eval --raw ".#devShells.${{ steps.set-nix-platform.outputs.nix-arch }}.default.outPath")" >> $GITHUB_OUTPUT
- name: Cache nix build artifacts
id: nix-cache
uses: actions/cache@v3
with:
path: |
nix-devshell.nixstore
key: nix-${{ steps.set-cache-key.outputs.nix-devshell-path }}
- name: Restore cached nix artifacts
if: steps.nix-cache.outputs.cache-hit == 'true'
working-directory: .
run: |
pwd
ls
nix-store --import < nix-devshell.nixstore
2023-12-09 01:09:54 +03:00
- name: Cache rust build artifacts
id: cache_rust
uses: Swatinem/rust-cache@v2
with:
key: rust-${{ steps.set-cache-key.outputs.nix-devshell-path }}
2023-12-09 01:09:54 +03:00
workspaces: "rust/ares -> target"
# Check formatting
2023-03-04 11:23:40 +03:00
- name: Format
run: |
nix develop --command bash -c "cargo fmt --check"
2023-03-04 11:23:40 +03:00
2023-05-20 21:47:04 +03:00
# See clippy linter docs: https://github.com/rust-lang/rust-clippy
#
2023-05-20 21:50:25 +03:00
# First linter is set to fail for all warnings, then ignored warnings are
# explicitly listed
2023-05-20 21:47:04 +03:00
#
# XX TODO make a script with all the flags for the linter
2023-03-14 18:37:12 +03:00
- name: Lint
2023-05-20 21:47:04 +03:00
run: |
nix develop --command bash -c "cargo clippy --all-targets --no-deps -- -D warnings -A clippy::missing_safety_doc"
2023-03-14 18:37:12 +03:00
# Build Ares
2023-03-04 11:23:40 +03:00
- name: Build
run: |
nix develop --command bash -c "cargo build --release --verbose"
# Run tests
- name: Test
run: |
nix develop --command bash -c "cargo test --verbose -- --test-threads=1"
2023-03-04 11:23:40 +03:00
- name: Build nix cache export
if: steps.nix-cache.outputs.cache-hit != 'true'
run: |
pwd
nix eval --json ".#devShells.${{ steps.set-nix-platform.outputs.nix-arch }}.default.buildInputs" 2>/dev/null
nix eval --json ".#devShells.${{ steps.set-nix-platform.outputs.nix-arch }}.default.buildInputs" 2>/dev/null | jq -r '.[]' | xargs nix-store --query --requisites
nix-store --export $(nix eval --json ".#devShells.${{ steps.set-nix-platform.outputs.nix-arch }}.default.buildInputs" 2>/dev/null | jq -r '.[]' | xargs nix-store --query --requisites) > ../../nix-devshell.nixstore
ls -lh