From ca9151fa24222ff33ca0cc412b5c1ba8b9c65158 Mon Sep 17 00:00:00 2001 From: Marc Handalian Date: Fri, 15 Apr 2022 13:09:33 -0700 Subject: [PATCH] Add Github Workflow to build and publish lucene snapshots. (#2906) This change introduces a github workflow so that we can build and push snapshots of lucene. The RepositoriesSetupPlugin is also updated with a url from where these snapshots can be retrieved. Signed-off-by: Marc Handalian --- .github/workflows/lucene-snapshots.yml | 55 +++++++++++++++++++ DEVELOPER_GUIDE.md | 6 ++ .../gradle/RepositoriesSetupPlugin.java | 3 +- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/lucene-snapshots.yml diff --git a/.github/workflows/lucene-snapshots.yml b/.github/workflows/lucene-snapshots.yml new file mode 100644 index 00000000000..0fe025ad1aa --- /dev/null +++ b/.github/workflows/lucene-snapshots.yml @@ -0,0 +1,55 @@ +# This workflow will check out, build, and publish snapshots of lucene. + +name: OpenSearch Lucene snapshots + +on: + workflow_dispatch: + # Inputs the workflow accepts. + inputs: + ref: + description: + required: false + default: 'main' + +jobs: + publish-snapshots: + runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + java-version: '17' + distribution: 'adopt' + + - name: Checkout Lucene + uses: actions/checkout@v2 + with: + repository: 'apache/lucene' + path: lucene + ref: ${{ github.event.inputs.ref }} + + - name: Set hash + working-directory: ./lucene + run: | + echo "::set-output name=REVISION::$(git rev-parse --short HEAD)" + id: version + + - name: Publish Lucene to local maven repo. + working-directory: ./lucene + run: ./gradlew publishJarsPublicationToMavenLocal -Pversion.suffix=snapshot-${{ steps.version.outputs.REVISION }} + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.LUCENE_SNAPSHOTS_ROLE }} + aws-region: us-west-2 + + - name: Copy files to S3 with the aws CLI. + run: | + aws s3 cp ~/.m2/repository/org/apache/lucene/ s3://${{ secrets.LUCENE_SNAPSHOTS_BUCKET }}/snapshots/lucene/org/apache/lucene/ --recursive --no-progress diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 11fcb324c8c..70abfda7673 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -49,6 +49,7 @@ - [Submitting Changes](#submitting-changes) - [Backports](#backports) - [LineLint](#linelint) + - [Lucene Snapshots](#lucene-snapshots) # Developer Guide @@ -488,3 +489,8 @@ Executing the binary will automatically search the local directory tree for lint Pass a list of files or directories to limit your search. linelint README.md LICENSE + +# Lucene Snapshots +The Github workflow in [lucene-snapshots.yml](.github/workflows/lucene-snapshots.yml) is a Github worfklow executable by maintainers to build a top-down snapshot build of lucene. +These snapshots are available to test compatibility with upcoming changes to Lucene by updating the version at [version.properties](buildsrc/version.properties) with the `version-snapshot-sha` version. +Example: `lucene = 10.0.0-snapshot-2e941fc`. diff --git a/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java index 30847f0648c..63b88f671c8 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java @@ -92,10 +92,9 @@ public class RepositoriesSetupPlugin implements Plugin { throw new GradleException("Malformed lucene snapshot version: " + luceneVersion); } String revision = matcher.group(1); - // TODO(cleanup) - Setup own lucene snapshot repo MavenArtifactRepository luceneRepo = repos.maven(repo -> { repo.setName("lucene-snapshots"); - repo.setUrl("https://artifacts.opensearch.org/snapshots/lucene/"); + repo.setUrl("https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/"); }); repos.exclusiveContent(exclusiveRepo -> { exclusiveRepo.filter(