Skip to content

Commit

Permalink
Make Workflows Fetch Version Automatically (#209)
Browse files Browse the repository at this point in the history
Signed-off-by: Mingshi Liu <mingshl@amazon.com>
Signed-off-by: Mingshi Liu <113382730+mingshl@users.noreply.github.com>
(cherry picked from commit dc5b53c)

Co-authored-by: Mingshi Liu <113382730+mingshl@users.noreply.github.com>
  • Loading branch information
noCharger and mingshl committed May 26, 2023
1 parent 9fd5072 commit 34251d8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This should match the list of maintainers in https://github.com/opensearch-project/dashboards-search-relevance/blob/main/MAINTAINERS.md
* @macohen @mingshl @msfroh @noCharger @sejli
* @macohen @mingshl @msfroh @noCharger @sejli
39 changes: 28 additions & 11 deletions .github/workflows/remote-integ-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ on:
pull_request:
branches:
- "*"
env:
OPENSEARCH_DASHBOARDS_VERSION: '2.x'
OPENSEARCH_VERSION: '2.8.0-SNAPSHOT'
OPENSEARCH_DASHBOARDS_FTREPO_VERSION: '2.x'
ANOMALY_DETECTION_PLUGIN_VERSION: '2.x'
jobs:
test-without-security:
name: Run integ tests without security
Expand All @@ -34,23 +29,45 @@ jobs:
distribution: 'corretto'
java-version: '11'

- uses: actions/checkout@v2
- name: Fetch Version Information
id: fetch version
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "Base branch name is $(basename "${{ github.ref }}")"
BRANCH_NAME=$(basename "${{ github.ref }}")
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Base branch name is "${{ github.event.pull_request.base.ref }}""
BRANCH_NAME="${{ github.event.pull_request.base.ref }}"
fi
CURRENT_VERSION=$(node -p "require('./package.json').version")
MAJOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f1)
MINOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f2)
PATCH_VERSION=$(echo $CURRENT_VERSION | cut -d. -f3)
OPENSEARCH_VERSION="$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION"
echo "OPENSEARCH_VERSION: $OPENSEARCH_VERSION"
echo "OPENSEARCH_VERSION=$OPENSEARCH_VERSION" >> $GITHUB_ENV
echo "OPENSEARCH_DASHBOARDS_VERSION=$BRANCH_NAME" >> $GITHUB_ENV
echo "OPENSEARCH_DASHBOARDS_FTREPO_VERSION=$BRANCH_NAME" >> $GITHUB_ENV
echo "SEARCH_PROCESSOR_PLUGIN_VERSION=$BRANCH_NAME" >> $GITHUB_ENV
- name: Enable longer filenames
if: ${{ matrix.os == 'windows-latest' }}
run: git config --system core.longpaths true

# It doesn't matter what plugin we use, but by launching OpenSearch
# from a plugin repo, we don't need to checkout and build
# OpenSearch itself.
- name: Checkout Anomaly-Detection
- name: Checkout Search-Processor
uses: actions/checkout@v2
with:
path: anomaly-detection
repository: opensearch-project/anomaly-detection
ref: ${{ env.ANOMALY_DETECTION_PLUGIN_VERSION }}
path: search-processor
repository: opensearch-project/search-processor
ref: ${{ env.SEARCH_PROCESSOR_PLUGIN_VERSION }}

- name: Run OpenSearch with plugin
run: |
cd anomaly-detection
cd search-processor
./gradlew run -Dopensearch.version=${{ env.OPENSEARCH_VERSION }} &
t=0
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do
Expand Down Expand Up @@ -105,7 +122,7 @@ jobs:

# Windows and Mac OS take a while to start, so we need a long sleep
- name: Sleep until OSD server starts
run: sleep 900
run: sleep 900
shell: bash

- name: Checkout opensearch-dashboards-functional-test
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on: [pull_request, push]

env:
PLUGIN_NAME: dashboards-search-relevance
OPENSEARCH_VERSION: '2.x'
OPENSEARCH_PLUGIN_VERSION: 2.7.0.0

jobs:
build:
Expand All @@ -15,6 +13,21 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Fetch Version Information
shell: bash
run: |
OPENSEARCH_PLUGIN_VERSION=$(node -p "require('./package.json').version")
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "Base branch name is $(basename "${{ github.ref }}")"
BRANCH_NAME=$(basename "${{ github.ref }}")
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Base branch name is "${{ github.event.pull_request.base.ref }}""
BRANCH_NAME="${{ github.event.pull_request.base.ref }}"
fi
echo "OPENSEARCH_PLUGIN_VERSION=$OPENSEARCH_PLUGIN_VERSION" >> $GITHUB_ENV
echo "OPENSEARCH_VERSION=$BRANCH_NAME" >> $GITHUB_ENV
- name: Enable core.longpaths on Windows
if: ${{ matrix.os == 'windows-latest' }}
run: git config --global core.longpaths true
Expand Down Expand Up @@ -78,4 +91,4 @@ jobs:
uses: actions/upload-artifact@v1
with:
name: dashboards-search-relevance-${{ matrix.os }}
path: ./OpenSearch-Dashboards/plugins/dashboards-search-relevance/build
path: ./OpenSearch-Dashboards/plugins/dashboards-search-relevance/build

0 comments on commit 34251d8

Please sign in to comment.