Skip to content

Commit

Permalink
Improve time taken by Github actions (#439)
Browse files Browse the repository at this point in the history
* Improve time taken by Github actions

Signed-off-by: Vacha Shah <[email protected]>

* Add Changelog

Signed-off-by: Vacha Shah <[email protected]>

* Fixing distribution and adding cache

Signed-off-by: Vacha Shah <[email protected]>

---------

Signed-off-by: Vacha Shah <[email protected]>
  • Loading branch information
VachaShah authored Apr 12, 2023
1 parent c050365 commit 81c088d
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 32 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ jobs:
java: [ 11 ]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout Java Client
uses: actions/checkout@v3

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}

- name: Checkout Branch
uses: actions/checkout@v2
distribution: 'temurin'
cache: 'gradle'

- name: Build with Gradle
run: ./gradlew clean build -x test
8 changes: 6 additions & 2 deletions .github/workflows/checkstyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ jobs:
matrix:
java: [ 11 ]
steps:
- name: Checkout Java Client
uses: actions/checkout@v3

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'gradle'

- uses: actions/checkout@v2
- name: Check style and license headers
run: |
./gradlew checkstyleMain checkstyleTest
2 changes: 1 addition & 1 deletion .github/workflows/dependabot_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
installation_id: 22958780

- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ steps.github_app_token.outputs.token }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: lychee Link Checker
id: lychee
uses: lycheeverse/[email protected]
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/publish-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: adopt
java-version: '11'
distribution: 'temurin'
cache: 'gradle'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ jobs:
issue-body: "Please approve or deny the release of opensearch-java. **VERSION**: ${{ steps.get_data.outputs.version }} **TAG**: ${{ github.ref_name }} **COMMIT**: ${{ github.sha }}"
exclude-workflow-initiator-as-approver: true
- name: Set up JDK 11
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 11
java-version: '11'
distribution: 'temurin'
cache: 'gradle'
- name: Build with Gradle
run: |
./gradlew --no-daemon publishPublishMavenPublicationToLocalRepoRepository && tar -C build -cvf artifacts.tar.gz repository
Expand Down
43 changes: 31 additions & 12 deletions .github/workflows/test-integration-unreleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,55 @@ jobs:
- { opensearch_ref: '1.x', java: 11 }
- { opensearch_ref: '2.x', java: 11 }
- { opensearch_ref: '2.x', java: 17 }
- { opensearch_ref: '2.0', java: 11 }
- { opensearch_ref: 'main', java: 11 }
- { opensearch_ref: 'main', java: 17 }
steps:
- name: Set up JDK ${{ matrix.entry.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.entry.java }}
distribution: 'temurin'

- name: Checkout OpenSearch
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: opensearch-project/OpenSearch
ref: ${{ matrix.entry.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

- 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 }}

# 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: 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 Java Client
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: opensearch-java

Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ jobs:
- { opensearch_version: 2.4.1, java: 11 }
- { opensearch_version: 2.5.0, java: 11 }
steps:
- name: Checkout Java Client
uses: actions/checkout@v3

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.entry.java }}

- name: Checkout Branch
uses: actions/checkout@v2
distribution: 'temurin'
cache: 'gradle'

- name: Run Docker
run: |
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ jobs:
java: [ 11 ]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout Java Client
uses: actions/checkout@v3

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}

- name: Checkout Branch
uses: actions/checkout@v2
distribution: 'temurin'
cache: 'gradle'

- name: Run Unit Test
run: ./gradlew clean unitTest
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Add support for OpenSearch Serverless ([#339](https://github.com/opensearch-project/opensearch-java/pull/339))
- Fix completion suggestions failure with missing required property TermSuggestOption.score ([#347](https://github.com/opensearch-project/opensearch-java/pull/347))
- Fix search failure with missing required property HitsMetadata.total when trackTotalHits is disabled ([#372](https://github.com/opensearch-project/opensearch-java/pull/372))
- Improve time taken by Github actions by using cache ([#439](https://github.com/opensearch-project/opensearch-java/pull/439))

### Deprecated

Expand Down

0 comments on commit 81c088d

Please sign in to comment.