Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache packages' dependencies #534

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,49 @@ jobs:
-d ${{ matrix.distribution }} \
-n ${{ steps.min_package.outputs.name }}


# Cache OpenSearch plugins
- name: Get Opensearch Version
run: |
VERSION=$(bash build-scripts/upstream-version.sh)
echo "versionOpenSearch_inBuild=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Cache OpenSearch plugins
id: cache-opensearch-plugins
uses: actions/cache@v4
with:
path: $HOME/.m2/repository/org/opensearch/plugin/performance-analyzer/${{ env.VERSION }}.0/
key: ${{ runner.os }}-opensearch-${{ hashFiles('performance-analyzer**.xml') }}
restore-keys: |
${{ runner.os }}-opensearch-performance-analyzer

- if: ${{steps.cache-opensearch-plugins.cache-hit != 'true'}}
name: Cache OpenSearch plugins fail
run: echo "Failed to cache OpenSearch plugins. DIRECTORYY $HOME/.m2/repository/org/opensearch/plugin/performance-analyzer/${{ env.VERSION }}.0/ "

- name: Run `assemble.sh`
run: |
bash build-scripts/assemble.sh \
-a ${{ matrix.architecture }} \
-d ${{ matrix.distribution }} \
-r ${{ inputs.revision }}

- name: Cache OpenSearch plugins POST
id: cache-opensearch-plugins-post
uses: actions/cache@v4
with:
path: $HOME/.m2/repository/org/opensearch/plugin/performance-analyzer/${{ env.VERSION }}.0/
key: ${{ runner.os }}-opensearch-${{ hashFiles('performance-analyzer**.xml') }}
restore-keys: |
${{ runner.os }}-opensearch-performance-analyzer

- if: ${{steps.cache-opensearch-plugins-post.cache-hit != 'true'}}
name: Cache OpenSearch plugins fail POST
run: |
ls $HOME/.m2/repository/org/opensearch/plugin/performance-analyzer/${{ env.VERSION }}.0/ >> $GITHUB_OUTPUT


- name: Test RPM package
if: ${{ matrix.distribution == 'rpm' }}
uses: addnab/docker-run-action@v3
Expand Down
9 changes: 8 additions & 1 deletion build-scripts/assemble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,15 @@ function install_plugins() {
echo "Installing OpenSearch plugins"
local maven_repo_local="$HOME/.m2"
for plugin in "${plugins[@]}"; do
echo "Plugin ${plugin}, version ${VERSION}"
local plugin_from_maven="org.opensearch.plugin:${plugin}:${VERSION}.0"
mvn -Dmaven.repo.local="${maven_repo_local}" org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=https://repo1.maven.org/maven2 -Dartifact="${plugin_from_maven}:zip"
if [[ -f "${maven_repo_local}/org/opensearch/plugin/${plugin}/${VERSION}.0/${plugin}-${VERSION}.0.zip" ]]; then
echo "Plugin ${plugin} is already present, download omitted."
else
echo "Downloand ${plugin} plugin"
mvn -Dmaven.repo.local="${maven_repo_local}" org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=https://repo1.maven.org/maven2 -Dartifact="${plugin_from_maven}:zip"
fi
echo "LOG TESTTTT: Install file -> ${maven_repo_local}/org/opensearch/plugin/${plugin}/${VERSION}.0/${plugin}-${VERSION}.0.zip"
OPENSEARCH_PATH_CONF=$PATH_CONF "${PATH_BIN}/opensearch-plugin" install --batch --verbose "file:${maven_repo_local}/org/opensearch/plugin/${plugin}/${VERSION}.0/${plugin}-${VERSION}.0.zip"
done

Expand Down