Skip to content

Commit 21b8f46

Browse files
adrielpjoaopgrassilmolkova
authored
[chore] update scripts to detect macos or linux for GNU sed usage (open-telemetry#1267)
Co-authored-by: Joao Grassi <5938087+joaopgrassi@users.noreply.github.com> Co-authored-by: Liudmila Molkova <limolkova@microsoft.com>
1 parent 06b0b62 commit 21b8f46

File tree

6 files changed

+38
-3
lines changed

6 files changed

+38
-3
lines changed

.github/workflows/scripts/prepare-new-issue.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515

1616
set -euo pipefail
1717

18+
OS=$(uname | tr '[:upper:]' '[:lower:]')
19+
20+
if [[ "${OS}" == "darwin" ]]; then
21+
SED="gsed"
22+
else
23+
SED="sed"
24+
fi
25+
1826
if [[ -z "${ISSUE:-}" || -z "${BODY:-}" || -z "${OPENER:-}" ]]; then
1927
echo "Missing one of ISSUE, BODY, or OPENER, please ensure all are set."
2028
exit 0
@@ -25,7 +33,7 @@ AREAS_SECTION_START=$( (echo "${BODY}" | grep -n '### Area(s)' | awk '{ print $1
2533
BODY_AREAS=""
2634

2735
if [[ "${AREAS_SECTION_START}" != '-1' ]]; then
28-
BODY_AREAS=$(echo "${BODY}" | sed -n $((AREAS_SECTION_START+2))p)
36+
BODY_AREAS=$(echo "${BODY}" | "${SED}" -n $((AREAS_SECTION_START+2))p)
2937
fi
3038

3139
for AREA in ${BODY_AREAS}; do

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ package-lock.json
3838

3939
# Python
4040
venv
41+
42+
# Brew package lock
43+
Brewfile.lock.json

Brewfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
brew "gsed"

CONTRIBUTING.md

+7
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ environment configured:
8080
npm install
8181
```
8282

83+
- If on MacOs, ensure you have `gsed` (GNU Sed) installed. If you have [HomeBrew](https://brew.sh)
84+
installed, then you can run the following command to install GSED.
85+
86+
```bash
87+
brew bundle
88+
```
89+
8390
### 1. Modify the YAML model
8491

8592
Refer to the

Makefile

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
ALL_DOCS := $(shell find . -type f -name '*.md' -not -path './.github/*' -not -path './node_modules/*' | sort)
33
PWD := $(shell pwd)
44

5+
# Determine OS & Arch for specific OS only tools on Unix based systems
6+
OS := $(shell uname | tr '[:upper:]' '[:lower:]')
7+
ifeq ($(OS),darwin)
8+
SED := gsed
9+
else
10+
SED := sed
11+
endif
12+
513
TOOLS_DIR := ./internal/tools
614

715
MISSPELL_BINARY=bin/misspell
@@ -151,7 +159,7 @@ table-check:
151159
#
152160
# .. which is why some additional processing is required to extract the
153161
# latest version number and strip off the "v" prefix.
154-
LATEST_RELEASED_SEMCONV_VERSION := $(shell git ls-remote --tags https://github.com/open-telemetry/semantic-conventions.git | cut -f 2 | sort --reverse | head -n 1 | tr '/' ' ' | cut -d ' ' -f 3 | sed 's/v//g')
162+
LATEST_RELEASED_SEMCONV_VERSION := $(shell git ls-remote --tags https://github.com/open-telemetry/semantic-conventions.git | cut -f 2 | sort --reverse | head -n 1 | tr '/' ' ' | cut -d ' ' -f 3 | $(SED) 's/v//g')
155163
.PHONY: compatibility-check
156164
compatibility-check:
157165
docker run --rm -v $(PWD)/model:/source -v $(PWD)/docs:/spec --pull=always \

internal/tools/scripts/update-issue-template-areas.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111

1212
set -euo pipefail
1313

14+
OS=$(uname | tr '[:upper:]' '[:lower:]')
15+
16+
if [[ "${OS}" == "darwin" ]]; then
17+
SED="gsed"
18+
else
19+
SED="sed"
20+
fi
21+
1422
CUR_DIRECTORY=$(dirname "$0")
1523
REPO_DIR="$( cd "$CUR_DIRECTORY/../../../" && pwd )"
1624
GITHUB_DIR="$( cd "$REPO_DIR/.github/" && pwd )"
@@ -37,7 +45,7 @@ echo -e "The replacement text will be:"
3745
echo -e "---------------------------------------------\n"
3846
echo -e $replacement
3947

40-
find ${TEMPLATES_DIR} -type f -name '*.yaml' -print0 | xargs -0 sed -i "/$START_AREA_LIST/,/$END_AREA_LIST/c\\$replacement"
48+
find ${TEMPLATES_DIR} -type f -name '*.yaml' -print0 | xargs -0 ${SED} -i "/$START_AREA_LIST/,/$END_AREA_LIST/c\\$replacement"
4149

4250
echo -e "\nISSUE_TEMPLATES updated successfully"
4351
echo -e "---------------------------------------------"

0 commit comments

Comments
 (0)