Skip to content

Commit

Permalink
Caching OpenSearch builds (#147)
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <[email protected]>
Co-authored-by: Harsha Vamsi Kalluri <[email protected]>
  • Loading branch information
nhtruong and harshavamsi authored Feb 23, 2023
1 parent 3da0c35 commit a07ee16
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions .github/workflows/test-unreleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,50 @@ jobs:
strategy:
fail-fast: false
matrix:
entry:
- { opensearch_ref: '1.x' }
- { opensearch_ref: '2.x' }
- { opensearch_ref: '2.0' }
- { opensearch_ref: 'main' }
opensearch_ref: [ '1.x', '2.x', '2.0', 'main' ]
ruby_version: 3.1
steps:
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
ruby-version: ${{ matrix.ruby_version }}

- name: Checkout OpenSearch
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: opensearch-project/OpenSearch
ref: ${{ matrix.entry.opensearch_ref }}
ref: ${{ matrix.opensearch_ref }}
path: opensearch

- name: Get OpenSearch branch top
id: get-key
working-directory: opensearch
run: echo key=`git log -1 --format='%H'` >> $GITHUB_OUTPUT

- name: Restore cached build
id: cache-restore
uses: actions/cache/restore@v3
with:
path: opensearch/distribution/archives/linux-tar/build/distributions
key: ${{ steps.get-key.outputs.key }}

- name: Assemble OpenSearch
run: |
cd opensearch
./gradlew assemble
if: steps.cache-restore.outputs.cache-hit != 'true'
working-directory: opensearch
run: ./gradlew :distribution:archives:linux-tar:assemble

# This step runs the docker image generated during gradle assemble in OpenSearch. It is tagged as opensearch:test.
# Reference: https://github.com/opensearch-project/OpenSearch/blob/2.0/distribution/docker/build.gradle#L190
- name: Run Docker Image
- name: Save cached build
if: steps.cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: opensearch/distribution/archives/linux-tar/build/distributions
key: ${{ steps.get-key.outputs.key }}

- name: Run OpenSearch
working-directory: opensearch/distribution/archives/linux-tar/build/distributions
run: |
docker run -p 9200:9200 -p 9600:9600 -d -e "discovery.type=single-node" -e "bootstrap.memory_lock=true" opensearch:test
sleep 90
tar xf opensearch-min-*
./opensearch-*/bin/opensearch &
for attempt in {1..20}; do sleep 5; if curl -s localhost:9200; then echo '=====> ready'; break; fi; echo '=====> waiting...'; done
- name: Checkout Ruby Client
uses: actions/checkout@v2
Expand All @@ -64,3 +80,10 @@ jobs:
run: cd opensearch-dsl && bundle exec rake test:all
- name: opensearch-aws-sigv4
run: cd opensearch-aws-sigv4 && bundle exec rake test:all

- name: Save server logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: opensearch-logs-${{ matrix.opensearch_ref }}-ruby-${{ matrix.ruby_version }}
path: opensearch/distribution/archives/linux-tar/build/distributions/**/logs/*

0 comments on commit a07ee16

Please sign in to comment.