Skip to content

Commit

Permalink
Only test changed files in PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
WeetHet committed Aug 21, 2024
1 parent 36086b9 commit f93292d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: Test All Dafny Files

on: [push]
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v20
- name: Test if all dafny files are named correctly
- name: Test that all dafny files are named correctly
run: nix run .#dafny-namecheck
- name: Run Dafny on all files
run: nix run .#dafny-check
20 changes: 20 additions & 0 deletions .github/workflows/test-dafny-new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test New Dafny Files

on:
push:
branches:
- '*'
- '*/*'
- '**'
- '!main'
jobs:
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v20
- name: Test that all dafny files are named correctly
run: nix run .#dafny-namecheck
- name: Run Dafny on all files
run: nix run .#dafny-check-new
13 changes: 13 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
packages = {
dafny-check = pkgs.writeShellScriptBin "dafny-check" ''
DIR=''${1:-.}
file_count=$(find "$DIR" -maxdepth 1 -name "*.dfy" -printf '.' | wc -m | sed 's/ //g')
file_no=0
for f in "$DIR"/*.dfy
Expand All @@ -23,6 +24,18 @@
done
'';

dafny-check-new = pkgs.writeShellScriptBin "dafny-check" ''
files_changed=$(git diff --name-only main | grep '\.dfy$')
file_count=0
for f in $files_changed; do file_count=$((file_count+1)); done
for f in $files_changed
do
file_no=$((file_no+1))
echo "Running dafny on $(basename "$f") ($file_no/$file_count)"
${pkgs.dafny}/bin/dafny verify --allow-warnings --verification-time-limit 2400 $f || exit 1
done
'';

dafny-namecheck = pkgs.writeShellScriptBin "dafny-namecheck" ''
# Directory to check, use current directory if not specified
DIR=''${1:-.}
Expand Down

0 comments on commit f93292d

Please sign in to comment.