Skip to content

Commit f586309

Browse files
authored
Use /usr/bin/env for scripts (#2315)
`/usr/bin/env bash` is more flexible than `/bin/bash` when using different OSes. This also fixes files and script with wrong permissions.
1 parent f07197c commit f586309

34 files changed

+32
-30
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ repos:
1515
- id: check-case-conflict
1616
- id: check-vcs-permalinks
1717
- id: check-json
18+
- id: check-executables-have-shebangs
19+
- id: check-shebang-scripts-are-executable
20+
- id: check-symlinks
1821
- id: pretty-format-json
1922
args: [--autofix, --no-sort-keys, --no-ensure-ascii]
2023
- id: mixed-line-ending

tests/Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ run-conformance-tests: ## Run conformance tests
3737
--restart=Never -- sh -c "go test -v . -tags conformance,experimental -args --gateway-class=$(GATEWAY_CLASS) \
3838
--supported-features=$(SUPPORTED_FEATURES) --version=$(NGF_VERSION) \
3939
--report-output=output.txt; cat output.txt" | tee output.txt
40-
bash scripts/check-pod-exit-code.sh
40+
./scripts/check-pod-exit-code.sh
4141
sed -e '1,/CONFORMANCE PROFILE/d' output.txt > conformance-profile.yaml
4242
rm output.txt
4343
grpc_core_result=`yq '.profiles[0].core.result' conformance-profile.yaml`; \
@@ -77,27 +77,27 @@ setup-gcp-and-run-nfr-tests: create-gke-router create-and-setup-vm nfr-test ## C
7777

7878
.PHONY: create-gke-cluster
7979
create-gke-cluster: ## Create a GKE cluster
80-
bash scripts/create-gke-cluster.sh $(CI)
80+
./scripts/create-gke-cluster.sh $(CI)
8181

8282
.PHONY: create-and-setup-vm
8383
create-and-setup-vm: ## Create and setup a GCP VM for tests
84-
bash scripts/create-and-setup-gcp-vm.sh
84+
./scripts/create-and-setup-gcp-vm.sh
8585

8686
.PHONY: create-gke-router
8787
create-gke-router: ## Create a GKE router to allow egress traffic from private nodes (allows for external image pulls)
88-
bash scripts/create-gke-router.sh
88+
./scripts/create-gke-router.sh
8989

9090
.PHONY: sync-files-to-vm
9191
sync-files-to-vm: ## Syncs your local NGF files with the NGF repo on the VM
92-
bash scripts/sync-files-to-vm.sh
92+
./scripts/sync-files-to-vm.sh
9393

9494
.PHONY: run-tests-on-vm
9595
run-tests-on-vm: ## Run the functional tests on a GCP VM
96-
bash scripts/run-tests-gcp-vm.sh
96+
./scripts/run-tests-gcp-vm.sh
9797

9898
.PHONY: nfr-test
9999
nfr-test: ## Run the NFR tests on a GCP VM
100-
NFR=true CI=$(CI) bash scripts/run-tests-gcp-vm.sh
100+
NFR=true CI=$(CI) ./scripts/run-tests-gcp-vm.sh
101101

102102
.PHONY: start-longevity-test
103103
start-longevity-test: export START_LONGEVITY=true
@@ -135,19 +135,19 @@ cleanup-gcp: cleanup-router cleanup-vm delete-gke-cluster ## Cleanup all GCP res
135135

136136
.PHONY: cleanup-router
137137
cleanup-router: ## Delete the GKE router
138-
bash scripts/cleanup-router.sh
138+
./scripts/cleanup-router.sh
139139

140140
.PHONY: cleanup-vm
141141
cleanup-vm: ## Delete the test GCP VM and delete the firewall rule
142-
bash scripts/cleanup-vm.sh
142+
./scripts/cleanup-vm.sh
143143

144144
.PHONY: delete-gke-cluster
145145
delete-gke-cluster: ## Delete the GKE cluster
146-
bash scripts/delete-gke-cluster.sh
146+
./scripts/delete-gke-cluster.sh
147147

148148
.PHONY: add-local-ip-to-cluster
149149
add-local-ip-to-cluster: ## Add local IP to the GKE cluster master-authorized-networks
150-
bash scripts/add-local-ip-auth-networks.sh
150+
./scripts/add-local-ip-auth-networks.sh
151151

152152
HELM_PARAMETERS += --set nameOverride=nginx-gateway --set nginxGateway.kind=skip --set service.create=false
153153

tests/reconfig/scripts/create-resources-gw-last.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
num_namespaces=$1
44

tests/reconfig/scripts/create-resources-routes-last.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
num_namespaces=$1
44

tests/reconfig/scripts/delete-multiple.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
num_namespaces=$1
44

tests/results/dp-perf/1.2.0/1.2.0-plus.md

100755100644
File mode changed.

tests/results/dp-perf/1.2.0/1.2.0.md

100755100644
File mode changed.

tests/results/dp-perf/1.3.0/1.3.0-plus.md

100755100644
File mode changed.

tests/results/dp-perf/1.3.0/1.3.0.md

100755100644
File mode changed.

tests/results/dp-perf/edge/edge-oss.md

100755100644
File mode changed.

tests/results/dp-perf/edge/edge-plus.md

100755100644
File mode changed.

tests/results/ngf-upgrade/1.2.0/1.2.0-plus.md

100755100644
File mode changed.

tests/results/ngf-upgrade/1.2.0/1.2.0.md

100755100644
File mode changed.

tests/results/ngf-upgrade/1.3.0/1.3.0-plus.md

100755100644
File mode changed.

tests/results/ngf-upgrade/1.3.0/1.3.0.md

100755100644
File mode changed.

tests/results/ngf-upgrade/edge/edge-oss.md

100755100644
File mode changed.

tests/results/ngf-upgrade/edge/edge-plus.md

100755100644
File mode changed.

tests/results/scale/1.3.0/1.3.0-plus.md

100755100644
File mode changed.

tests/results/scale/1.3.0/1.3.0.md

100755100644
File mode changed.

tests/results/scale/edge/edge-oss.md

100755100644
File mode changed.

tests/results/scale/edge/edge-plus.md

100755100644
File mode changed.

tests/scripts/add-local-ip-auth-networks.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
source scripts/vars.env
44

tests/scripts/check-pod-exit-code.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
CODE=$(kubectl get pod conformance -o jsonpath='{.status.containerStatuses[].state.terminated.exitCode}')
44
if [ $CODE -ne 0 ]; then

tests/scripts/cleanup-router.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
source scripts/vars.env
44

tests/scripts/cleanup-vm.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
source scripts/vars.env
44

tests/scripts/create-and-setup-gcp-vm.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
44

tests/scripts/create-gke-cluster.sh

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
source scripts/vars.env
44

@@ -34,5 +34,5 @@ gcloud container clusters create ${GKE_CLUSTER_NAME} \
3434
# Add current IP to GKE master control node access, if this script is not invoked during a CI run.
3535
if [ "${IS_CI}" = "false" ]; then
3636
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
37-
bash ${SCRIPT_DIR}/add-local-ip-auth-networks.sh
37+
./${SCRIPT_DIR}/add-local-ip-auth-networks.sh
3838
fi

tests/scripts/create-gke-router.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
source scripts/vars.env
44

tests/scripts/delete-gke-cluster.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
source scripts/vars.env
44

tests/scripts/remote-scripts/run-nfr-tests.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
set -e
44

tests/scripts/remote-scripts/run-tests.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
set -e
44

tests/scripts/run-tests-gcp-vm.sh

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
44

@@ -14,7 +14,6 @@ gcloud compute scp --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} ${SCRIPT_
1414
gcloud compute ssh --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} username@${RESOURCE_NAME} \
1515
--command="export START_LONGEVITY=${START_LONGEVITY} &&\
1616
export STOP_LONGEVITY=${STOP_LONGEVITY} &&\
17-
source /etc/profile &&\
1817
bash -s" < ${SCRIPT_DIR}/remote-scripts/${SCRIPT}; retcode=$?
1918

2019
if [ $retcode -ne 0 ]; then

tests/scripts/sync-files-to-vm.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
source scripts/vars.env
44

5-
NGF_DIR=$(dirname "$PWD")
5+
NGF_DIR=$(dirname "$CUR")
66

77
gcloud compute config-ssh --ssh-config-file ngf-gcp.ssh > /dev/null
88

tests/suite/scripts/longevity-wrk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
SVC_IP=$(kubectl -n nginx-gateway get svc ngf-longevity-nginx-gateway-fabric -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
44

0 commit comments

Comments
 (0)