Skip to content

Commit 9e059b6

Browse files
First version of pull-request #TASK-8067
1 parent 7df2f3f commit 9e059b6

File tree

6 files changed

+345
-3
lines changed

6 files changed

+345
-3
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: "Prepare OpenCGA Enterprise"
2+
description: "Checkout enterprise, resolve OpenCGA ref, optionally clone java-common-libs/biodata and compute dependencies_sha"
3+
4+
inputs:
5+
enterprise_ref:
6+
description: "Branch, tag or SHA of opencga-enterprise to checkout"
7+
required: true
8+
clone_dependencies:
9+
description: "Clone java-common-libs and biodata on the same branch for SNAPSHOT builds"
10+
required: false
11+
default: "true"
12+
13+
outputs:
14+
enterprise_version:
15+
description: "project.version from opencga-enterprise"
16+
value: ${{ steps.project_version.outputs.enterprise_version }}
17+
is_release:
18+
description: "true if project.version is a release (no SNAPSHOT)"
19+
value: ${{ steps.project_version.outputs.is_release }}
20+
opencga_branch:
21+
description: "Resolved OpenCGA branch, tag or ref"
22+
value: ${{ steps.opencga_branch.outputs.opencga_branch }}
23+
dependencies_sha:
24+
description: "SHA representing the combination of OpenCGA/java-common-libs/biodata commits"
25+
value: ${{ steps.dependencies_sha.outputs.dependencies_sha }}
26+
27+
runs:
28+
using: "composite"
29+
steps:
30+
- name: Checkout opencga-enterprise
31+
uses: actions/checkout@v4
32+
with:
33+
ref: ${{ inputs.enterprise_ref }}
34+
repository: zetta-genomics/opencga-enterprise
35+
token: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}
36+
path: opencga-enterprise
37+
fetch-depth: 10
38+
- id: project_version
39+
name: Read project.version and determine release flag
40+
shell: bash
41+
run: |
42+
version=$(mvn -q -Dexpression=project.version -DforceStdout help:evaluate)
43+
echo "enterprise_version=$version" >> "$GITHUB_OUTPUT"
44+
echo "enterprise_version=$version" >> "$GITHUB_OUTPUT"
45+
if [[ "$version" == *SNAPSHOT ]]; then
46+
echo "is_release=false" >> "$GITHUB_OUTPUT"
47+
else
48+
echo "is_release=true" >> "$GITHUB_OUTPUT"
49+
fi
50+
- id: opencga_branch
51+
name: Resolve OpenCGA branch or tag from opencga.version and branch
52+
shell: bash
53+
run: |
54+
if [ ! -f "./.github/workflows/scripts/opencga_branch.sh" ]; then
55+
echo "ERROR: .github/workflows/scripts/opencga_branch.sh not found" >&2
56+
exit 1
57+
fi
58+
chmod +x ./.github/workflows/scripts/opencga_branch.sh
59+
branch=$(
60+
./.github/workflows/scripts/opencga_branch.sh \
61+
"${{ steps.project_version.outputs.is_release }}"
62+
)
63+
echo "opencga_branch=$branch" >> "$GITHUB_OUTPUT"
64+
- name: Checkout OpenCGA
65+
uses: actions/checkout@v4
66+
with:
67+
repository: opencb/opencga
68+
ref: ${{ steps.opencga_branch.outputs.opencga_branch }}
69+
path: opencga-home
70+
fetch-depth: 10
71+
- id: dependencies_sha
72+
name: Compute dependencies SHA for OpenCGA/java-common-libs/biodata
73+
shell: bash
74+
run: |
75+
base_sha="${GITHUB_SHA}"
76+
if [[ "${{ inputs.clone_dependencies }}" == "true" && "${{ steps.project_version.outputs.is_release }}" == "false" ]]; then
77+
if [ -f "./.github/workflows/scripts/get_same_branch.sh" ]; then
78+
echo "::group::Clone java-common-libs and biodata and compute dependencies SHA"
79+
chmod +x ./.github/workflows/scripts/get_same_branch.sh
80+
81+
export DEPENDENCIES_SHA="$base_sha"
82+
export WORKSPACE="${WORKSPACE:-/home/runner/work}"
83+
84+
./.github/workflows/scripts/get_same_branch.sh "${{ inputs.enterprise_ref }}"
85+
echo "::endgroup::"
86+
exit 0
87+
else
88+
echo "get_same_branch.sh not found, skipping dependency cloning."
89+
fi
90+
fi
91+
echo "dependencies_sha=$base_sha" >> "$GITHUB_OUTPUT"

.github/actions/setup-java-maven/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
java_version:
66
description: "Java version to use"
77
required: false
8-
default: "11"
8+
default: "8"
99
storage_hadoop:
1010
description: "Hadoop flavour, used as part of the Maven cache key"
1111
required: false

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ jobs:
7979
- name: Maven Build (skip tests)
8080
if: ${{ !inputs.deploy_maven }}
8181
run: mvn -T 2 clean install -DskipTests ${{ inputs.maven_opts }} --no-transfer-progress
82-
8382
- name: Maven Deploy (skip tests, deploy to Maven Central y GitHub Packages)
8483
if: ${{ inputs.deploy_maven }}
8584
run: mvn -T 2 clean deploy -DskipTests -Pdeploy-maven,deploy-github ${{ inputs.maven_opts }} --no-transfer-progress
@@ -98,7 +97,6 @@ jobs:
9897

9998
- name: Get project version
10099
id: get_project_version
101-
102100
# This step extracts the Maven project version and exposes it as an output.
103101
run: |
104102
echo "version=$(mvn help:evaluate -q -Dexpression=project.version -DforceStdout)" >> "$GITHUB_OUTPUT"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# .github/workflows/pull-request-approve.yml
2+
# Workflow to be triggered on PR approval, receives target_branch as input, checks out the repo,
3+
# computes the correct opencga-enterprise branch, and calls test-xetabase with the calculated branch and PR head as task.
4+
5+
name: Xetabase PR Approve Entrypoint
6+
7+
on:
8+
workflow_call:
9+
inputs:
10+
target_branch:
11+
description: 'Target branch of the PR (github.event.pull_request.base.ref)'
12+
required: true
13+
type: string
14+
head_ref:
15+
description: 'Source branch of the PR (github.event.pull_request.head.ref)'
16+
required: true
17+
type: string
18+
secrets:
19+
ZETTA_REPO_ACCESS_TOKEN:
20+
required: true
21+
THIRDPARTY_READ_TOKEN:
22+
required: false
23+
KEEPER_SM_GH_OPENCB:
24+
required: false
25+
26+
jobs:
27+
resolve-and-test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout triggering repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 10
34+
path: triggering-repo
35+
- name: Parse pom.xml to get project artifactId
36+
id: pom
37+
shell: bash
38+
working-directory: triggering-repo
39+
run: |
40+
artifactId=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="artifactId"]/text()' pom.xml)
41+
echo "artifactId=$artifactId" >> "$GITHUB_OUTPUT"
42+
- name: Compute opencga-enterprise branch
43+
id: compute_branch
44+
env:
45+
ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}
46+
shell: bash
47+
working-directory: triggering-repo
48+
run: |
49+
chmod +x ../.github/workflows/scripts/get_opencga_enterprise_branch.sh
50+
branch=$( ../.github/workflows/scripts/get_opencga_enterprise_branch.sh "${{ steps.pom.outputs.artifactId }}" "${{ inputs.target_branch }}" "${{ inputs.head_ref }}" )
51+
echo "branch=$branch" | tee -a $GITHUB_STEP_SUMMARY
52+
echo "branch=$branch" >> $GITHUB_OUTPUT
53+
- name: Checkout opencga-enterprise
54+
uses: actions/checkout@v4
55+
with:
56+
repository: zetta-genomics/opencga-enterprise
57+
ref: ${{ steps.compute_branch.outputs.branch }}
58+
path: opencga-enterprise
59+
token: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}
60+
- name: Call test-xetabase workflow with calculated branch
61+
uses: ./.github/workflows/test-xetabase.yml
62+
with:
63+
branch: ${{ steps.compute_branch.outputs.branch }}
64+
task: ${{ inputs.head_ref }}
65+
secrets:
66+
ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}
67+
THIRDPARTY_READ_TOKEN: ${{ secrets.THIRDPARTY_READ_TOKEN }}
68+
KEEPER_SM_GH_OPENCB: ${{ secrets.KEEPER_SM_GH_OPENCB }}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env bash
2+
# get_opencga_enterprise_branch.sh
3+
#
4+
# This script computes the correct opencga-enterprise branch to use for testing a PR in any Xetabase component repo.
5+
# It unifies the logic previously duplicated in java-common-libs, biodata, and opencga.
6+
#
7+
# Inputs:
8+
# 1. project (artifactId from pom.xml)
9+
# 2. base_ref (target branch of the PR)
10+
# 3. head_ref (source branch of the PR)
11+
#
12+
# Output:
13+
# Prints the resolved opencga-enterprise branch to stdout.
14+
# Exits with non-zero and error message if it cannot resolve a branch.
15+
16+
set -euo pipefail
17+
18+
project="$1"
19+
base_ref="$2"
20+
head_ref="$3"
21+
22+
# Helper: check if a branch exists in the remote opencga-enterprise repo
23+
branch_exists() {
24+
local branch="$1"
25+
REPO_URI="https://$ZETTA_REPO_ACCESS_TOKEN@github.com/zetta-genomics/opencga-enterprise.git"
26+
git ls-remote --heads "$REPO_URI" "$branch" | grep -q refs/heads
27+
}
28+
29+
# 1. TASK-* branch logic: if head_ref starts with TASK- and exists in opencga-enterprise, use it
30+
if [[ "$head_ref" =~ ^TASK- ]]; then
31+
if branch_exists "$head_ref"; then
32+
echo "$head_ref"
33+
exit 0
34+
fi
35+
fi
36+
37+
# 2. develop branch logic: always map to develop
38+
if [[ "$base_ref" == "develop" ]]; then
39+
echo "develop"
40+
exit 0
41+
fi
42+
43+
# 3. release-* branch logic
44+
if [[ "$base_ref" =~ ^release-([0-9]+)\. ]]; then
45+
major="${BASH_REMATCH[1]}"
46+
# Project-specific offset for release branch mapping
47+
case "$project" in
48+
java-common-libs)
49+
offset=3
50+
;;
51+
biodata|opencga)
52+
offset=1
53+
;;
54+
opencga-enterprise)
55+
# If the project is opencga-enterprise, use the branch as-is
56+
echo "$base_ref"
57+
exit 0
58+
;;
59+
*)
60+
echo "ERROR: Unknown project '$project' for release branch mapping" >&2
61+
exit 1
62+
;;
63+
esac
64+
new_major=$((major - offset))
65+
if (( new_major < 1 )); then
66+
echo "ERROR: Computed release branch version < 1 for $project (base_ref: $base_ref, offset: $offset)" >&2
67+
exit 1
68+
fi
69+
# Try to match release-x.x.x, fallback to release-x.x
70+
branch_pattern="release-${new_major}."
71+
# Find the latest matching branch in opencga-enterprise
72+
branch=$(git ls-remote --heads https://github.com/zetta-genomics/opencga-enterprise.git | grep "refs/heads/${branch_pattern}" | awk -F'refs/heads/' '{print $2}' | sort -Vr | head -n1)
73+
if [[ -n "$branch" ]]; then
74+
echo "$branch"
75+
exit 0
76+
else
77+
echo "ERROR: No matching release branch found in opencga-enterprise for $project (pattern: $branch_pattern)" >&2
78+
exit 1
79+
fi
80+
fi
81+
82+
# 4. Fallback: fail with clear error
83+
echo "ERROR: Could not resolve opencga-enterprise branch for project '$project' (base_ref: $base_ref, head_ref: $head_ref)" >&2
84+
exit 1
85+
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: TEST Xetabase and publish report workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
task:
7+
type: string
8+
required: true
9+
branch:
10+
type: string
11+
required: true
12+
workflow_dispatch:
13+
inputs:
14+
task:
15+
type: string
16+
description: 'Task ID to be tested.'
17+
required: true
18+
branch:
19+
type: string
20+
description: 'Branch of opencga-enterprise to be tested and built.'
21+
required: true
22+
23+
jobs:
24+
test:
25+
name: Execute JUnit and Jacoco tests
26+
runs-on: ${{ vars.UBUNTU_VERSION }}
27+
steps:
28+
- name: Retrieve secrets from Keeper
29+
id: ksecrets
30+
uses: Keeper-Security/ksm-action@master
31+
with:
32+
keeper-secret-config: ${{ secrets.KEEPER_SM_GH_OPENCB }}
33+
secrets: |
34+
AZURE_KUBE_CONFIG/field/Secret Value > env:AZURE_KUBE_CONFIG
35+
DOCKER_HUB_USER/field/Secret Value > env:DOCKER_HUB_USER
36+
DOCKER_HUB_PASSWORD/field/Secret Value > env:DOCKER_HUB_PASSWORD
37+
SSH_TESTING_SERVER_HOST/field/Secret Value > env:SSH_HOST
38+
SSH_TESTING_SERVER_PORT/field/Secret Value > env:SSH_PORT
39+
SSH_TESTING_SERVER_USER/field/Secret Value > env:SSH_USER
40+
SSH_TESTING_SERVER_PASSWORD/field/Secret Value > env:SSH_PASS
41+
- name: Prepare enterprise, OpenCGA and dependencies
42+
id: prepare
43+
uses: ./.github/actions/prepare-opencga-enterprise
44+
with:
45+
enterprise_ref: ${{ inputs.branch != '' && inputs.branch || github.ref_name }}
46+
clone_dependencies: "true"
47+
- name: Set up Java and Maven cache
48+
# Uses dependencies_sha to make the cache key sensitive to dependency commits
49+
uses: ./.github/actions/setup-java-maven-cache
50+
with:
51+
storage_hadoop: ${{ inputs.storage_hadoop }}
52+
dependencies_sha: ${{ steps.prepare.outputs.dependencies_sha }}
53+
54+
- name: Install Samtools
55+
run: sudo apt-get install samtools python3-deeptools
56+
- name: Start MongoDB v6.0
57+
uses: supercharge/mongodb-github-action@1.8.0
58+
with:
59+
mongodb-version: 6.0
60+
mongodb-replica-set: rs-test
61+
- name: Install sshpass
62+
run: sudo apt-get install sshpass
63+
- name: Add SSH Host to known_hosts
64+
run: |
65+
mkdir -p ~/.ssh
66+
ssh-keyscan -p ${{ env.SSH_PORT }} ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts
67+
env:
68+
SSH_HOST: ${{ env.SSH_HOST }}
69+
SSH_PORT: ${{ env.SSH_PORT }}
70+
- name: Run all OpenCB Junit tests, ie. java-common-libs, biodata, opencga and opencga-enterprise
71+
run: |
72+
cd opencga-enterprise
73+
ln -s ../opencga opencga-home
74+
./build.sh --test --test-level runShortTests --prepare-branches --test-save-reports --task ${{ inputs.task }} --storage-hadoop ${{ vars.HADOOP_FLAVOUR }} --prepare-hadoop --github
75+
env:
76+
THIRDPARTY_READ_TOKEN: ${{ secrets.THIRDPARTY_READ_TOKEN }}
77+
- name: Upload reports results to Github
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: report-test
81+
path: ./opencga-enterprise/reports/
82+
if-no-files-found: error
83+
- name: Upload log
84+
uses: actions/upload-artifact@v4
85+
## Skip cancelled()
86+
## https://docs.github.com/en/actions/learn-github-actions/expressions#cancelled
87+
if: success() || failure()
88+
with:
89+
name: build-log
90+
path: |
91+
./opencga-enterprise/build.log
92+
./opencga-enterprise/reports/*.log.gz
93+
if-no-files-found: error
94+
- name: Log summary
95+
run: |
96+
cat ./opencga-enterprise/build.log | tee -a $GITHUB_STEP_SUMMARY
97+
98+
99+
100+

0 commit comments

Comments
 (0)