Skip to content

Commit 7f3e41f

Browse files
authored
Build OpenSearch on Windows (#767)
* Refactored TemporaryFile and GitRepository into context managers. Signed-off-by: dblock <[email protected]> * Remove mkdtemp. Signed-off-by: dblock <[email protected]> * Fix tests on Windows. Signed-off-by: dblock <[email protected]> * Execute commands using bash. Signed-off-by: dblock <[email protected]> * Support windows zip for OpenSearch-min. Signed-off-by: dblock <[email protected]>
1 parent 6ae52ca commit 7f3e41f

File tree

64 files changed

+444
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+444
-272
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
os:
1818
- ubuntu-latest
1919
- macos-latest
20+
- windows-latest
2021
runs-on: ${{ matrix.os }}
2122
env:
2223
PYTHON_VERSION: 3.7

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ out.txt
1616

1717
/artifacts/
1818
/bundle/
19+
20+
/.vscode/

DEVELOPER_GUIDE.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Fork this repository on GitHub, and clone locally with `git clone`.
2424

2525
#### Pyenv
2626

27-
Use pyenv to manage multiple versions of Python. This can be installed with [pyenv-installer](https://github.com/pyenv/pyenv-installer).
27+
Use pyenv to manage multiple versions of Python. This can be installed with [pyenv-installer](https://github.com/pyenv/pyenv-installer) on Linux and MacOS, and [pyenv-win](https://github.com/pyenv-win/pyenv-win#installation) on Windows.
2828

2929
```
3030
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
@@ -42,7 +42,7 @@ Python 3.7.11
4242
If you are using pyenv.
4343

4444
```
45-
pyenv install 3.7.12
45+
pyenv install 3.7.12 # use 3.7.9 on Windows, the latest at the time of writing this
4646
pyenv global 3.7.12
4747
```
4848

@@ -57,7 +57,10 @@ $ pipenv --version
5757
pipenv, version 19.0
5858
```
5959

60+
On Windows, run `pyenv rehash` if `pipenv` cannot be found. This rehashes pyenv shims, creating a `pipenv` file in `/.pyenv/pyenv-win/shims/`.
61+
6062
#### NVM and Node
63+
6164
Install [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md) to use the Node 10.24.1 version as it is required
6265

6366
```
@@ -66,6 +69,7 @@ nvm install v10.24.1
6669
```
6770

6871
#### Yarn
72+
6973
[Yarn](https://classic.yarnpkg.com/en/docs/install) is required for building and running the OpenSearch Dashboards and plugins
7074

7175
```

Pipfile.lock

Lines changed: 67 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ export PIPENV_PIPFILE="$DIR/Pipfile"
2020
python3 -m pipenv install
2121

2222
echo "Running "$1" ${@:2} ..."
23-
python3 -m pipenv run "$1" ${@:2}
23+
python3 -m pipenv run python "$1" ${@:2}

scripts/components/OpenSearch/build.sh

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,42 @@ mkdir -p $OUTPUT/maven/org/opensearch
7272
# Copy maven publications to be promoted
7373
cp -r ./build/local-test-repo/org/opensearch "${OUTPUT}"/maven/org
7474

75+
# Assemble distribution artifact
76+
# see https://github.com/opensearch-project/OpenSearch/blob/main/settings.gradle#L34 for other distribution targets
77+
7578
[ -z "$PLATFORM" ] && PLATFORM=`uname -s` | awk '{print tolower($0)}'
7679
[ -z "$ARCHITECTURE" ] && ARCHITECTURE=`uname -m`
7780

78-
# Assemble distribution artifact
79-
# see https://github.com/opensearch-project/OpenSearch/blob/main/settings.gradle#L34 for other distribution targets
81+
case "$(uname -s)" in
82+
Linux*)
83+
PACKAGE="tar"
84+
EXT="tar.gz"
85+
;;
86+
Darwin*)
87+
PACKAGE="tar"
88+
EXT="tar.gz"
89+
;;
90+
CYGWIN*)
91+
PACKAGE="zip"
92+
EXT="zip"
93+
;;
94+
MINGW*)
95+
PACKAGE="zip"
96+
EXT="zip"
97+
;;
98+
*)
99+
echo "Unsupported system: $(uname -s)"
100+
exit 1
101+
;;
102+
esac
103+
80104
case $ARCHITECTURE in
81105
x64)
82-
TARGET="$PLATFORM-tar"
106+
TARGET="$PLATFORM-$PACKAGE"
83107
QUALIFIER="$PLATFORM-x64"
84108
;;
85109
arm64)
86-
TARGET="$PLATFORM-arm64-tar"
110+
TARGET="$PLATFORM-arm64-$PACKAGE"
87111
QUALIFIER="$PLATFORM-arm64"
88112
;;
89113
*)
@@ -96,7 +120,7 @@ esac
96120

97121
# Copy artifact to dist folder in bundle build output
98122
[[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT"
99-
ARTIFACT_BUILD_NAME=`ls distribution/archives/$TARGET/build/distributions/ | grep "opensearch-min.*$QUALIFIER.tar.gz"`
123+
ARTIFACT_BUILD_NAME=`ls distribution/archives/$TARGET/build/distributions/ | grep "opensearch-min.*$QUALIFIER.$EXT"`
100124
mkdir -p "${OUTPUT}/dist"
101125
cp distribution/archives/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME "${OUTPUT}"/dist/$ARTIFACT_BUILD_NAME
102126

src/assemble_workflow/bundle_opensearch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
class BundleOpenSearch(Bundle):
1313
def install_plugin(self, plugin):
1414
tmp_path = self._copy_component(plugin, "plugins")
15-
cli_path = os.path.join(self.archive_path, "bin/opensearch-plugin")
15+
cli_path = os.path.join(self.archive_path, "bin", "opensearch-plugin")
1616
self._execute(f"{cli_path} install --batch file:{tmp_path}")
1717
super().install_plugin(plugin)

0 commit comments

Comments
 (0)