Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] update scripts to detect macos or linux for GNU sed usage #1267

Merged
merged 5 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/scripts/prepare-new-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@

set -euo pipefail

OS=$(uname | tr '[:upper:]' '[:lower:]')

if [[ "${OS}" == "darwin" ]]; then
SED="gsed"
else
SED="sed"
fi

if [[ -z "${ISSUE:-}" || -z "${BODY:-}" || -z "${OPENER:-}" ]]; then
echo "Missing one of ISSUE, BODY, or OPENER, please ensure all are set."
exit 0
Expand All @@ -25,7 +33,7 @@ AREAS_SECTION_START=$( (echo "${BODY}" | grep -n '### Area(s)' | awk '{ print $1
BODY_AREAS=""

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

for AREA in ${BODY_AREAS}; do
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ package-lock.json

# Python
venv

# Brew package lock
Brewfile.lock.json
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
brew "gsed"
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ environment configured:
npm install
```

- If on MacOs, ensure you have `gsed` (GNU Sed) installed. If you have [HomeBrew](https://brew.sh)
installed, then you can run the following command to install GSED.

```bash
brew bundle
```

### 1. Modify the YAML model

Refer to the
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
ALL_DOCS := $(shell find . -type f -name '*.md' -not -path './.github/*' -not -path './node_modules/*' | sort)
PWD := $(shell pwd)

# Determine OS & Arch for specific OS only tools on Unix based systems
OS := $(shell uname | tr '[:upper:]' '[:lower:]')
ifeq ($(OS),darwin)
SED := gsed
else
SED := sed
endif

TOOLS_DIR := ./internal/tools

MISSPELL_BINARY=bin/misspell
Expand Down Expand Up @@ -151,7 +159,7 @@ table-check:
#
# .. which is why some additional processing is required to extract the
# latest version number and strip off the "v" prefix.
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')
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')
.PHONY: compatibility-check
compatibility-check:
docker run --rm -v $(PWD)/model:/source -v $(PWD)/docs:/spec --pull=always \
Expand Down
10 changes: 9 additions & 1 deletion internal/tools/scripts/update-issue-template-areas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@

set -euo pipefail

OS=$(uname | tr '[:upper:]' '[:lower:]')

if [[ "${OS}" == "darwin" ]]; then
SED="gsed"
else
SED="sed"
fi

CUR_DIRECTORY=$(dirname "$0")
REPO_DIR="$( cd "$CUR_DIRECTORY/../../../" && pwd )"
GITHUB_DIR="$( cd "$REPO_DIR/.github/" && pwd )"
Expand All @@ -37,7 +45,7 @@ echo -e "The replacement text will be:"
echo -e "---------------------------------------------\n"
echo -e $replacement

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

echo -e "\nISSUE_TEMPLATES updated successfully"
echo -e "---------------------------------------------"
Loading