diff --git a/.github/workflows/pull-request-approved.yml b/.github/workflows/pull-request-approved.yml index d96c9562..de0bbc57 100644 --- a/.github/workflows/pull-request-approved.yml +++ b/.github/workflows/pull-request-approved.yml @@ -16,18 +16,25 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: '10' + ## This is important to avoid the error in the next step: "fatal: repository 'https://github.com/zetta-genomics/opencga-enterprise.git/' not found" + persist-credentials: false - id: get_xetabase_branch name: "Get current branch for Xetabase from target branch" run: | chmod +x ./.github/workflows/scripts/get-xetabase-branch.sh - xetabase_branch=$(./.github/workflows/scripts/get-xetabase-branch.sh ${{ github.event.pull_request.base.ref }}) + echo "github.event.pull_request.base.ref: ${{ github.event.pull_request.base.ref }}" + echo "github.event.pull_request.head.ref: ${{ github.event.pull_request.head.ref }}" + echo "secrets.ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}" + xetabase_branch=$(./.github/workflows/scripts/get-xetabase-branch.sh ${{ github.event.pull_request.head.ref }}) echo "__Xetabase ref:__ \"${xetabase_branch}\"" | tee -a ${GITHUB_STEP_SUMMARY} echo "xetabase_branch=${xetabase_branch}" >> $GITHUB_OUTPUT + env: + ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }} test: name: "Run all tests before merging" needs: calculate-xetabase-branch - uses: opencb/java-common-libs/.github/workflows/test-xetabase-workflow.yml@TASK-6399 + uses: opencb/java-common-libs/.github/workflows/test-xetabase-workflow.yml@develop with: branch: ${{ needs.calculate-xetabase-branch.outputs.xetabase_branch }} task: ${{ github.event.pull_request.head.ref }} diff --git a/.github/workflows/scripts/get-xetabase-branch.sh b/.github/workflows/scripts/get-xetabase-branch.sh index 0be5cb32..139e6a0a 100644 --- a/.github/workflows/scripts/get-xetabase-branch.sh +++ b/.github/workflows/scripts/get-xetabase-branch.sh @@ -1,5 +1,6 @@ #!/bin/bash - +set -e +set -x # Function to calculate the corresponding branch of Xetabase project get_xetabase_branch() { # Input parameter (branch name) @@ -7,9 +8,9 @@ get_xetabase_branch() { # If the branch begins with 'TASK' and exists in the opencga-enterprise repository, I return it if [[ $input_branch == TASK* ]]; then - if [ "$(git ls-remote https://github.com/zetta-genomics/opencga-enterprise.git "$input_branch" )" ] ; then - echo "$GIT_BRANCH"; - exit 0; + if [ "$(git ls-remote "https://$ZETTA_REPO_ACCESS_TOKEN@github.com/zetta-genomics/opencga-enterprise.git" "$input_branch" )" ] ; then + echo $input_branch; + return 0; fi fi @@ -40,11 +41,6 @@ get_xetabase_branch() { return 1 } -# Check if the script receives exactly one argument -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi # Call the function with the input branch name get_xetabase_branch "$1" diff --git a/.github/workflows/test-pull-request-approved.yml b/.github/workflows/test-pull-request-approved.yml new file mode 100644 index 00000000..41f878cf --- /dev/null +++ b/.github/workflows/test-pull-request-approved.yml @@ -0,0 +1,48 @@ +name: Pull request approve workflow +run-name: 'Pull request approve workflow ${{ github.event.pull_request.head.ref }} -> ${{ github.event.pull_request.base.ref }} by @${{ github.actor }}' + +on: + push: + branches: + - TASK-* + + +jobs: + calculate-xetabase-branch: + name: Calculate Xetabase branch + runs-on: ubuntu-22.04 + outputs: + xetabase_branch: ${{ steps.get_xetabase_branch.outputs.xetabase_branch }} + steps: + - name: Clone java-common-libs + uses: actions/checkout@v4 + with: + fetch-depth: '10' + ## This is important to avoid the error in the next step: "fatal: repository 'https://github.com/zetta-genomics/opencga-enterprise.git/' not found" + persist-credentials: false + - id: get_xetabase_branch + name: "Get current branch for Xetabase from target branch" + run: | + if [ "$( git ls-remote https://$ZETTA_REPO_ACCESS_TOKEN@github.com/opencb/opencga.git "TASK-6807" )" ] ; then + echo "OPENCGA TASK-6807 branch"; + fi + + if [ "$( git ls-remote https://$ZETTA_REPO_ACCESS_TOKEN@github.com/zetta-genomics/opencga-enterprise.git "$input_branch" )" ] ; then + echo "Here it is TASK-6807 branch"; + fi + chmod +x ./.github/workflows/scripts/get-xetabase-branch.sh + echo "secrets.ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}" | tee -a ${GITHUB_STEP_SUMMARY} + xetabase_branch=$(./.github/workflows/scripts/get-xetabase-branch.sh "TASK-6807" ) + echo "__Xetabase ref:__ \"${xetabase_branch}\"" | tee -a ${GITHUB_STEP_SUMMARY} + echo "xetabase_branch=${xetabase_branch}" >> $GITHUB_OUTPUT + env: + ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }} + + test: + name: "Run all tests before merging" + needs: calculate-xetabase-branch + uses: opencb/java-common-libs/.github/workflows/test-xetabase-workflow.yml@develop + with: + branch: ${{ needs.calculate-xetabase-branch.outputs.xetabase_branch }} + task: TASK-6807 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/test-xetabase-workflow.yml b/.github/workflows/test-xetabase-workflow.yml index 1dfcdc78..ed802879 100644 --- a/.github/workflows/test-xetabase-workflow.yml +++ b/.github/workflows/test-xetabase-workflow.yml @@ -20,10 +20,6 @@ on: description: 'Branch of opencga-enterprise to be tested and built.' required: true -env: - AZCOPY_AUTO_LOGIN_TYPE: "SPN" - - jobs: test: name: Execute JUnit and Jacoco tests @@ -35,16 +31,13 @@ jobs: with: keeper-secret-config: ${{ secrets.KEEPER_SM_GH_OPENCB }} secrets: | - AZCOPY_SPA_CLIENT_SECRET/field/Secret Value > env:AZCOPY_SPA_CLIENT_SECRET - AZCOPY_SPA_APPLICATION_ID/field/Secret Value > env:AZCOPY_SPA_APPLICATION_ID - AZCOPY_TENANT_ID/field/Secret Value > env:AZCOPY_TENANT_ID AZURE_KUBE_CONFIG/field/Secret Value > env:AZURE_KUBE_CONFIG DOCKER_HUB_USER/field/Secret Value > env:DOCKER_HUB_USER DOCKER_HUB_PASSWORD/field/Secret Value > env:DOCKER_HUB_PASSWORD - SSH_TESTING_SERVER_HOST/field/Secret Value > env:SSH_TESTING_SERVER_HOST - SSH_TESTING_SERVER_PORT/field/Secret Value > env:SSH_TESTING_SERVER_PORT - SSH_TESTING_SERVER_USER/field/Secret Value > env:SSH_TESTING_SERVER_USER - SSH_TESTING_SERVER_PASSWORD/field/Secret Value > env:SSH_TESTING_SERVER_PASSWORD + SSH_TESTING_SERVER_HOST/field/Secret Value > env:SSH_HOST + SSH_TESTING_SERVER_PORT/field/Secret Value > env:SSH_PORT + SSH_TESTING_SERVER_USER/field/Secret Value > env:SSH_USER + SSH_TESTING_SERVER_PASSWORD/field/Secret Value > env:SSH_PASS - name: Log inputs run: | echo "__OpenCGA-enterprise branch:__ \"${{ inputs.branch }}\"" | tee -a $GITHUB_STEP_SUMMARY @@ -93,29 +86,25 @@ jobs: chmod +x ./kubectl echo "${{ secrets.AZURE_KUBE_CONFIG }}" > admin.conf ./kubectl -n cellbase-db port-forward services/cellbase-rs0-svc 27018:27017 --kubeconfig ./admin.conf & - - name: Install Azure AZCOPY - uses: kheiakiyama/install-azcopy-action@v1 - with: - version: 'v10' - name: DockerHub login uses: docker/login-action@v3 with: username: ${{ env.DOCKER_HUB_USER }} password: ${{ env.DOCKER_HUB_PASSWORD }} + - name: Install sshpass + run: sudo apt-get install sshpass + - name: Add SSH Host to known_hosts + run: | + mkdir -p ~/.ssh + ssh-keyscan -p ${{ env.SSH_PORT }} ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts + env: + SSH_HOST: ${{ env.SSH_HOST }} + SSH_PORT: ${{ env.SSH_PORT }} - name: Run all OpenCB Junit tests, ie. java-common-libs, biodata, cellbase, opencga and opencga-enterprise run: | - pwd - ls -lrtha - echo "------------------------------------" cd opencga-enterprise - pwd - ls -lrtha - echo "------------------------------------" ln -s ../opencga opencga-home - echo "------------------------------------" - ls -lrtha - #./build.sh -t -l runShortTests,runMediumTests,runLongTests -b -s -f -T ${{ inputs.task }} -c localhost:27018 -H hdp3.1 - ./build.sh -t -l runShortTests -b -s -f -T ${{ inputs.task }} -c localhost:27018 -H hdp3.1 + ./build.sh -t -l runShortTests -b -s -T ${{ inputs.task }} -c localhost:27018 -H hdp3.1 - name: Upload reports results to Github uses: actions/upload-artifact@v4 with: @@ -126,16 +115,6 @@ jobs: with: name: build-log path: ./opencga-enterprise/build.log - - name: Upload junit reports to a remote scp server - uses: garygrossgarten/github-action-scp@release - with: - local: opencga-enterprise/reports/test - remote: /var/www/html/reports/xetabase/${{ inputs.task }}/ - host: ${{ env.SSH_TESTING_SERVER_HOST}} - port: ${{ env.SSH_TESTING_SERVER_PORT}} - username: ${{ env.SSH_TESTING_SERVER_USER }} - password: ${{ env.SSH_TESTING_SERVER_PASSWORD }} - concurrency: 2 - name: Log summary run: | cat ./opencga-enterprise/build.log | tee -a $GITHUB_STEP_SUMMARY