File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6969 run : yarn nx run-many -t lint --all
7070
7171 - name : Test
72- run : yarn nx run-many -t test --all --configuration=ci --detectOpenHandles=false
72+ run : ./bin/run-with-network-isolation.sh yarn nx run-many -t test --all --configuration=ci --detectOpenHandles=false
7373
7474 - name : Upload webapp coverage to Codecov
7575 uses : codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ if [[ $# -eq 0 ]]; then
6+ echo " Usage: $0 <command> [arguments...]" >&2
7+ exit 1
8+ fi
9+
10+ if [[ " $( uname -s) " != " Linux" ]]; then
11+ exec " $@ "
12+ fi
13+
14+ if ! command -v unshare > /dev/null 2>&1 ; then
15+ echo " The 'unshare' command is required on Linux to isolate network access during tests." >&2
16+ exit 1
17+ fi
18+
19+ original_user=" $( id -un) "
20+ original_home=" ${HOME} "
21+ original_path=" ${PATH} "
22+
23+ if unshare --map-root-user -n true > /dev/null 2>&1 ; then
24+ exec unshare --map-root-user -n " $@ "
25+ fi
26+
27+ if unshare -n true > /dev/null 2>&1 ; then
28+ exec unshare -n " $@ "
29+ fi
30+
31+ if command -v sudo > /dev/null 2>&1 ; then
32+ if sudo unshare -n true > /dev/null 2>&1 ; then
33+ if command -v runuser > /dev/null 2>&1 ; then
34+ exec sudo unshare -n runuser -u " ${original_user} " -- env HOME=" ${original_home} " PATH=" ${original_path} " " $@ "
35+ fi
36+
37+ echo " The 'runuser' command is required for the privileged unshare fallback on this Linux runner." >&2
38+ exit 1
39+ fi
40+ fi
41+
42+ echo " Unable to create a network-isolated namespace with unshare on this Linux runner." >&2
43+ exit 1
You can’t perform that action at this time.
0 commit comments