Skip to content

Commit

Permalink
mypy-ratchet: Run first ratchet run inside a nix-shell
Browse files Browse the repository at this point in the history
We need to evaluate twice, once using any previous version of mypy and
a second time using the current version of mypy.

If we don't a mypy version bump can find new type errors that makes
the initial check fail.
  • Loading branch information
adisbladis committed Mar 27, 2020
1 parent 023d926 commit ad15b76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
27 changes: 10 additions & 17 deletions ci/mypy-ratchet.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash ../shell.nix
#!/usr/bin/env bash

set -eu

cd "${0%/*}/.."

scratch=$(mktemp -d -t tmp.XXXXXXXXXX)
function finish {
rm -rf "$scratch"
}
trap finish EXIT
# trap finish EXIT

cp ci/run-ratchet.sh $scratch/

head=$(git rev-parse HEAD)
base=origin/${GITHUB_BASE_REF:-master}
Expand All @@ -17,22 +20,12 @@ git fetch origin
echo "Checking base branch at %s, then PR at %s...\n" "$base" "$head"

git checkout "$base"
mypy \
--any-exprs-report "$scratch/base" \
--linecount-report "$scratch/base" \
--lineprecision-report "$scratch/base" \
--txt-report "$scratch/base" \
nixops
nix-shell shell.nix --run "$scratch/run-ratchet.sh $scratch base"

git checkout "$head"
mypy \
--any-exprs-report "$scratch/head" \
--linecount-report "$scratch/head" \
--lineprecision-report "$scratch/head" \
--txt-report "$scratch/head" \
nixops
nix-shell shell.nix --run "$scratch/run-ratchet.sh $scratch base"

diff --ignore-all-space -u100 -r "$scratch/base/" "$scratch/head/" || true

mypy ./ci/ratchet.py
python3 ./ci/ratchet.py "$scratch"
nix-shell shell.nix --run "mypy ./ci/ratchet.py"
nix-shell shell.nix --run "python3 ./ci/ratchet.py $scratch"
12 changes: 12 additions & 0 deletions ci/run-ratchet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -eu

scratch=$1
sub=$2

exec mypy \
--any-exprs-report "$scratch/$sub" \
--linecount-report "$scratch/$sub" \
--lineprecision-report "$scratch/$sub" \
--txt-report "$scratch/$sub" \
nixops

0 comments on commit ad15b76

Please sign in to comment.