Skip to content

Commit

Permalink
Merge pull request #1014 from vaisakhkannan/Fix-#998-Allow-input-LSP4…
Browse files Browse the repository at this point in the history
…IJ-PR-number

Enabled developer to input PR number for lsp4ij checkout input
  • Loading branch information
vaisakhkannan authored Jan 29, 2025
2 parents 98517b1 + ab59fb2 commit a967e46
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 8 deletions.
56 changes: 51 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ on:
required: true
type: boolean
default: false
lsp4ijPrNumber:
description: 'Run build with an LSP4IJ PR. Make sure to enter the LSP4IJ PR number in the "Reference/branch/PR for LSP4IJ checkout" input box.'
required: true
type: boolean
default: false
refLsp4ij:
description: 'Reference/branch for Lsp4ij checkout'
description: 'Reference/branch/PR for LSP4IJ checkout'
type: string
required: true
default: main
Expand All @@ -45,7 +50,48 @@ on:
branches: [ main ]

jobs:
fetch_merge_commit_sha_from_lsp4ij_PR:
runs-on: ubuntu-latest
outputs:
pr_details: ${{ steps.extract.outputs.pr_details }}
checkout_name: ${{ steps.extract.outputs.checkout_name }}
env:
API_URL: https://api.github.com/repos/redhat-developer/lsp4ij/pulls
REF_LSP4IJ: ${{ inputs.refLsp4ij }}
LSP4IJ_BRANCH: ${{ inputs.lsp4ijBranch }}
name: Fetch Commit ${{ inputs.refLsp4ij || '' }}
steps:
- name: Extract Merge Commit SHA
shell: bash
id: extract
run: |
pr_details="${{ env.REF_LSP4IJ }}"
checkout_name="${{ env.LSP4IJ_BRANCH }}"
if [ "${{ inputs.lsp4ijPrNumber }}" == "true" ]; then
url="${{ env.API_URL }}/${{ env.REF_LSP4IJ }}"
pr_detail=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$url")
pr_details=$(jq -r '.merge_commit_sha' <<< "$pr_detail" | xargs)
echo "Merge commit SHA of PR ${{ env.REF_LSP4IJ }}: $pr_details"
checkout_name="${{ env.REF_LSP4IJ }}"
if [[ "$pr_details" == "null" ]]; then
echo "::warning file=::The merge commit SHA of the entered PR is 'null'. Please try again later or use a different PR number."
fi
elif [ -z "$pr_details" ]; then
echo "No LSP4IJ checkout found. Using default case."
elif [ -z "$checkout_name" ]; then
echo "Merge Commit SHA/Branch Name/Tag : $pr_details"
checkout_name="${{ env.REF_LSP4IJ }}"
else
echo "Merge Commit SHA/Branch Name/Tag : $pr_details"
fi
# Set output for further steps
echo "pr_details=$pr_details" >> $GITHUB_OUTPUT
echo "checkout_name=$checkout_name" >> $GITHUB_OUTPUT
build:
needs: fetch_merge_commit_sha_from_lsp4ij_PR
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -63,8 +109,8 @@ jobs:
reportName: windows-test-report
env:
USE_LOCAL_PLUGIN: ${{ inputs.useLocalPlugin || false }}
REF_LSP4IJ: ${{ inputs.refLsp4ij }}
LSP4IJ_BRANCH: ${{ inputs.lsp4ijBranch || 'default' }}
REF_LSP4IJ: ${{ needs.fetch_merge_commit_sha_from_lsp4ij_PR.outputs.pr_details }}
LSP4IJ_BRANCH: ${{ needs.fetch_merge_commit_sha_from_lsp4ij_PR.outputs.checkout_name }}
REF_LTI_TAG: ${{ inputs.refLTITag }}
steps:
- name: Configure pagefile
Expand Down Expand Up @@ -108,7 +154,7 @@ jobs:
if: ${{ runner.os == 'Linux' && !failure() }}
uses: actions/upload-artifact@v4.3.4
with:
name: liberty-tools-intellij-LTI-${{ env.REF_LTI_TAG || 'default' }}-LSP4IJ-${{ env.LSP4IJ_BRANCH }}
name: liberty-tools-intellij-LTI-${{ env.REF_LTI_TAG || 'default' }}-LSP4IJ-${{ env.LSP4IJ_BRANCH || 'default' }}
path: |
./**/*liberty-tools-intellij*.zip
./**/libs/*liberty-tools-intellij*.jar
Expand All @@ -122,6 +168,6 @@ jobs:
if: ${{ failure() && steps.run_tests.conclusion == 'failure' }}
uses: actions/upload-artifact@v4.3.4
with:
name: ${{ matrix.reportName }}-LTI-${{ env.REF_LTI_TAG || 'default' }}-LSP4IJ-${{ env.LSP4IJ_BRANCH }}
name: ${{ matrix.reportName }}-LTI-${{ env.REF_LTI_TAG || 'default' }}-LSP4IJ-${{ env.LSP4IJ_BRANCH || 'default' }}
path: |
liberty-tools-intellij/build/reports/
15 changes: 12 additions & 3 deletions docs/LSP4IJ-Continuous-Integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The build.yaml workflow is triggered by the following events:
- Workflow Dispatch: Allows manual triggering of the workflow with customizable inputs.


<img alt="Workflow-dispatch" height="300" src="images/Workflow-dispatch.png" width="300" style="display: block; margin: 0 auto;"/>
<img alt="Workflow-dispatch" height="400" src="images/Workflow-dispatch.png" width="300" style="display: block; margin: 0 auto;"/>

To manually trigger the workflow, refer to the [Manually Trigger Workflow](#manually-trigger-workflow) section.

Expand Down Expand Up @@ -209,14 +209,23 @@ LSP4IJ nightly builds can be downloaded from the [JetBrains Marketplace](https:/

## Manually Trigger Workflow
To manually trigger the build.yaml workflow , navigate to the [Actions](https://github.com/OpenLiberty/liberty-tools-intellij/actions) tab in the OpenLiberty/liberty-tools-intellij repository. On the left side of the page, select Build Workflow under All workflows. You'll see a message stating, This workflow has a workflow_dispatch event trigger. To the right, there will be a Run workflow button. You can choose the branch from which to run the workflow.
<img alt="Manually-trigger" height="300" src="images/manually-trigger.png" width="300" style="display: block; margin: 0 auto;"/>

<img alt="Manually-trigger" height="350" src="images/manually-trigger.png" width="300" style="display: block; margin: 0 auto;"/>

If you want to use the version of lsp4ij specified in the build.gradle file, there's no need to check the box labeled Use lsp4ij locally. However, if you want to check out a different tag, merge commit SHA, or specific branch of lsp4ij, you can check the box and specify the branch in the provided field. Additionally, you can specify the tag or branch of liberty-tools-intellij to be used.


For example, if you want to trigger the Build Workflow from the `main` branch of the LTI repository and build against version `0.5.0` of LSP4IJ and the `main` branch of LTI, you would configure it as follows:

<img alt="Example" height="300" src="images/example-manually-trigger.png" width="300" style="display: block; margin: 0 auto;"/>
<img alt="Example" height="400" src="images/example-manually-trigger.png" width="300" style="display: block; margin: 0 auto;"/>

If you want to check out LSP4IJ based on a PR number, you can check the box labeled `Run build with an LSP4IJ PR.` and specify the PR number in the provided text field labeled `Reference/branch/PR for LSP4IJ checkout`. Additionally, you can specify the tag or branch of the `liberty-tools-intellij` repository to be used.

> NOTE: Make sure to enable the checkbox labeled `Use lsp4ij locally` as well for this case.
For example, if you want to trigger the Build Workflow from a branch of the LTI repository and build against LSP4IJ PR number `500` while using the `main` branch of LTI, you would configure it as follows:

<img alt="Example" height="400" src="images/Allow-developer-to-input-PR-number.png" width="320" style="display: block; margin: 0 auto;"/>

# How to specify LTI tags or branches in CI-CD builds

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/Workflow-dispatch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/example-manually-trigger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/manually-trigger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a967e46

Please sign in to comment.