Mercurial > hg
annotate contrib/docker/pytype/recipe.sh @ 51916:7ff35f1290c0 stable tip
run-tests: ensure that --no-rust do not use rust
Since having a valid value in HGWITHRUSTEXT is enough to trigger the use of
rust, we need to unset it before install to be sure.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 27 Sep 2024 15:53:56 +0200 |
parents | 87bfd1703597 |
children |
rev | line source |
---|---|
51307
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
1 #!/usr/bin/env bash |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
2 |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
3 # find repo-root without calling hg as this might be run with sudo |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
4 THIS="$(readlink -m "$0")" |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
5 HERE="$(dirname "$THIS")" |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
6 HG_ROOT="$(readlink -m "$HERE"/../../..)" |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
7 echo source mercurial repository: "$HG_ROOT" |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
8 |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
9 # find actual user as this might be run with sudo |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
10 if [ -n "$SUDO_UID" ]; then |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
11 ACTUAL_UID="$SUDO_UID" |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
12 else |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
13 ACTUAL_UID="$(id -u)" |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
14 fi |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
15 if [ -n "$SUDO_GID" ]; then |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
16 ACTUAL_GID="$SUDO_GID" |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
17 else |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
18 ACTUAL_GID="$(id -g)" |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
19 fi |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
20 echo using user "$ACTUAL_UID:$ACTUAL_GID" |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
21 if groups | egrep -q '\<(docker|root)\>' ; then |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
22 env DOCKER_BUILDKIT=1 docker build --tag mercurial-pytype-checker "$HERE" |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
23 docker run --rm -it --user "$ACTUAL_UID:$ACTUAL_GID" -v "$HG_ROOT:/tmp/mercurial-ci" mercurial-pytype-checker |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
24 else |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
25 echo "user not in the docker group" >&2 |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
26 echo "(consider running this with \`sudo\`)" >&2 |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
27 exit 255 |
87bfd1703597
contrib: add a set of scripts to run pytype in Docker
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
28 fi |