Skip to content

Add astyle test to Github Workflow #5

Add astyle test to Github Workflow

Add astyle test to Github Workflow #5

Workflow file for this run

name: Build
on:
push:
branches: [ '*' ]
pull_request:
branches: [ "main" ]
jobs:
build_test:
runs-on: ubuntu-latest
steps:
- name: install jq
shell: bash
run: |
if ! (command -v jq) &> /dev/null
then
sudo apt install -y --no-install-recommends jq
fi
- uses: actions/checkout@v4
- id: nixpkgs
shell: bash
run: |
if [ -f flake.lock ]; then
nixpkgs="flake:$(cat flake.lock | jq -r '.nodes.nixpkgs.locked // empty | .type + ":" + .owner + "/" + .repo + "/" + .rev')"
else
nixpkgs=channel:nixos-unstable
fi
echo "nixpkgs=$nixpkgs" >> "$GITHUB_OUTPUT"
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=${{ steps.nixpkgs.outputs.nixpkgs }}
- name: Prepare nix dev shell
shell: nix develop .#ci -c bash -e {0}
run: |
astyle --version
- name: Astyle
shell: nix develop .#ci -c bash -e {0}
run: |
err=$(astyle $(git ls-files "*.c" "*.h") --options=.astylerc --dry-run --formatted)
if [[ ${#err} != 0 ]]; then
echo "$err" | awk '{split($0,a);print a[2]}' | while IFS= read -r file; do
echo "::error file={"$file"},title={checking}::Formatted $file"
done
exit 1
fi
- name: Build targets
shell: nix develop .#ci -c bash -e {0}
run: |
make