Skip to content

Commit

Permalink
Improve time taken by Github actions (opensearch-project#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 committed Apr 12, 2023
1 parent 573ac7f commit 51f95e3
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 30 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
33 changes: 33 additions & 0 deletions .github/workflows/publish-snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish snapshots to maven

on:
push:
branches:
- main

jobs:
build-and-publish-snapshots:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'gradle'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.PUBLISH_SNAPSHOTS_ROLE }}
aws-region: us-east-1
- name: publish snapshots to maven
run: |
export SONATYPE_USERNAME=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-username --query SecretString --output text)
export SONATYPE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-password --query SecretString --output text)
echo "::add-mask::$SONATYPE_USERNAME"
echo "::add-mask::$SONATYPE_PASSWORD"
./gradlew --no-daemon publishPublishMavenPublicationToSnapshotsRepository
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: |
export VERSION=`cat gradle.properties | grep "systemProp.version" | tr -d " " | cut -d '=' -f2`
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

0 comments on commit 51f95e3

Please sign in to comment.