Skip to content

Commit f6b9081

Browse files
authored
Merge branch 'develop' into TASK-7645
2 parents 5816368 + a429a6e commit f6b9081

2 files changed

Lines changed: 167 additions & 0 deletions

File tree

.github/workflows/debug-token.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Debug ZETTA_REPO_ACCESS_TOKEN and Permissions
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
debug-token-and-permissions:
8+
runs-on: ${{ vars.UBUNTU_VERSION }}
9+
env:
10+
ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 1
15+
- name: Show runner and workflow context
16+
run: |
17+
echo "Runner: $(uname -a)"
18+
echo "GitHub Actor: $GITHUB_ACTOR"
19+
echo "Workflow: $GITHUB_WORKFLOW"
20+
echo "Event: $GITHUB_EVENT_NAME"
21+
echo "Repository: $GITHUB_REPOSITORY"
22+
echo "Job: $GITHUB_JOB"
23+
echo "Workspace: $GITHUB_WORKSPACE"
24+
echo "Home: $HOME"
25+
echo "Shell: $SHELL"
26+
echo "GitHub Ref: $GITHUB_REF"
27+
echo "GitHub SHA: $GITHUB_SHA"
28+
echo "GitHub Run ID: $GITHUB_RUN_ID"
29+
echo "GitHub Run Number: $GITHUB_RUN_NUMBER"
30+
31+
- name: Show GitHub Actions permissions
32+
run: |
33+
echo "Permissions JSON:"
34+
cat $GITHUB_EVENT_PATH | jq '.workflow_run?.permissions // .permissions // "No permissions found"'
35+
36+
- name: Check ZETTA_REPO_ACCESS_TOKEN presence and length
37+
run: |
38+
if [ -z "$ZETTA_REPO_ACCESS_TOKEN" ]; then
39+
echo "ZETTA_REPO_ACCESS_TOKEN is NOT set"
40+
exit 1
41+
else
42+
echo "ZETTA_REPO_ACCESS_TOKEN is set"
43+
echo "Length: ${#ZETTA_REPO_ACCESS_TOKEN}"
44+
echo "First 4 chars: ${ZETTA_REPO_ACCESS_TOKEN:0:4}"
45+
fi
46+
- id: get_ci_core_xetabase_branch
47+
name: "Get CI-CORE current branch for Xetabase from target branch"
48+
run: |
49+
chmod +x ./.github/workflows/scripts/get_opencga_enterprise_branch.sh
50+
echo "secrets.ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}"
51+
xetabase_branch=$(./.github/workflows/scripts/get_opencga_enterprise_branch.sh "java-common-libs" "develop" "TASK-8067")
52+
echo "__CI CORE Xetabase ref:__ \"${xetabase_branch}\"" | tee -a ${GITHUB_STEP_SUMMARY}
53+
REPO_URI="https://$ZETTA_REPO_ACCESS_TOKEN@github.com/zetta-genomics/opencga-enterprise.git"
54+
echo "$(git ls-remote "$REPO_URI" "TASK-8067")"
55+
env:
56+
ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}
57+
- id: get_xetabase_branch
58+
name: "Get JCL current branch for Xetabase from target branch"
59+
run: |
60+
chmod +x ./.github/workflows/scripts/get-xetabase-branch.sh
61+
echo "github.event.pull_request.base.ref: develop"
62+
echo "github.event.pull_request.head.ref: TASK-8067"
63+
echo "secrets.ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}"
64+
xetabase_branch=$(./.github/workflows/scripts/get-xetabase-branch.sh "develop" "TASK-8067")
65+
echo "__Xetabase ref:__ \"${xetabase_branch}\"" | tee -a ${GITHUB_STEP_SUMMARY}
66+
env:
67+
ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}
68+
- name: Clone OpenCGA Enterprise branch '${{ inputs.branch }}'
69+
uses: actions/checkout@v4
70+
with:
71+
repository: zetta-genomics/opencga-enterprise
72+
ref: TASK-8067
73+
token: ${{ env.ZETTA_REPO_ACCESS_TOKEN }}
74+
path: xetbase-opencga-enterprise
75+
fetch-depth: "10"
76+
77+
- name: Try to clone the private repo with token
78+
run: |
79+
set -x
80+
git clone https://$ZETTA_REPO_ACCESS_TOKEN@github.com/zetta-genomics/opencga-enterprise.git || true
81+
82+
- name: Show authenticated user (if possible)
83+
run: |
84+
curl -H "Authorization: token $ZETTA_REPO_ACCESS_TOKEN" https://api.github.com/user
85+
86+
- name: Show environment variables (filtered)
87+
run: |
88+
env | grep -E 'GITHUB|ZETTA|RUNNER|CI'
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
REPO_URI="https://$ZETTA_REPO_ACCESS_TOKEN@github.com/zetta-genomics/opencga-enterprise.git"
22+
23+
# 1. If the branch begins with 'TASK' and exists in the opencga-enterprise repository, return it
24+
if [[ $head_ref == TASK* ]]; then
25+
if [ "$(git ls-remote "$REPO_URI" "$head_ref")" ] ; then
26+
echo "$head_ref";
27+
exit 0
28+
fi
29+
fi
30+
31+
# 2. If the base_ref is 'develop', always map to develop
32+
if [[ "$base_ref" == "develop" ]]; then
33+
echo "develop"
34+
exit 0
35+
fi
36+
37+
# 3. release-* branch logic
38+
if [[ "$base_ref" =~ ^release-([0-9]+)\. ]]; then
39+
major="${BASH_REMATCH[1]}"
40+
# Project-specific offset for release branch mapping
41+
case "$project" in
42+
java-common-libs)
43+
offset=3
44+
;;
45+
biodata|opencga)
46+
offset=1
47+
;;
48+
opencga-enterprise)
49+
# If the project is opencga-enterprise, use the branch as-is
50+
echo "$base_ref"
51+
exit 0
52+
;;
53+
*)
54+
echo "ERROR: Unknown project '$project' for release branch mapping" >&2
55+
exit 1
56+
;;
57+
esac
58+
new_major=$((major - offset))
59+
if (( new_major < 1 )); then
60+
echo "ERROR: Computed release branch version < 1 for $project (base_ref: $base_ref, offset: $offset)" >&2
61+
exit 1
62+
fi
63+
# Extract the rest of the version (minor and patch) from base_ref
64+
rest_version=$(echo "$base_ref" | sed -E "s/^release-[0-9]+(\..*)/\1/")
65+
target_branch="release-${new_major}${rest_version}"
66+
# Check if the exact branch exists (fix: do not escape quotes)
67+
if [ "$(git ls-remote --heads "$REPO_URI" "$target_branch")" ]; then
68+
echo "$target_branch"
69+
exit 0
70+
else
71+
echo "ERROR: No matching release branch '$target_branch' found in opencga-enterprise for $project (base_ref: $base_ref, offset: $offset)" >&2
72+
exit 1
73+
fi
74+
fi
75+
76+
# 4. Fallback: fail with clear error
77+
echo "ERROR: Could not resolve opencga-enterprise branch for project '$project' (base_ref: $base_ref, head_ref: $head_ref)" >&2
78+
exit 1
79+

0 commit comments

Comments
 (0)