From 4d9ffc123098990cb19e9cbcbc55c930673f550b Mon Sep 17 00:00:00 2001 From: sachintu47 Date: Thu, 7 May 2026 12:53:34 -0400 Subject: [PATCH 1/2] feat: support external source URL for build testing --- .github/workflows/build_and_test.yml | 13 +++++++++++-- .github/workflows/jenkins-test.yml | 1 + bin/zopen-build | 22 ++++++++++++++++------ cicd/build.groovy | 4 ++++ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 679401620..e95afd31e 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -11,6 +11,10 @@ on: required: false default: "" type: string + git_source_url: + required: false + default: "" + type: string use_prbranch_as_build_branch: required: false default: false @@ -59,17 +63,22 @@ jobs: if [ -z "${branch}" ]; then branch="${{ fromJson(steps.request.outputs.data).head.ref }}" fi + git_source_url="${{ inputs.git_source_url }}" + GIT_SOURCE_URL_OPT="" + if [ -n "${git_source_url}" ]; then + GIT_SOURCE_URL_OPT="-F PORT_GIT_SOURCE_URL=${git_source_url}" + fi BUILD_BRANCH_OPT="" if ${{ inputs.use_prbranch_as_build_branch }}; then BUILD_BRANCH_OPT="-F BUILD_BRANCH=${branch}" branch="main" fi - CAUSE="Triggered by GH Action from PR: ${{ github.event.issue.pull_request.url || github.event.pull_request.url }} - Repo ${repo}, Branch: ${branch}, Build Opts: ${BUILD_BRANCH_OPT}" + CAUSE="Triggered by GH Action from PR: ${{ github.event.issue.pull_request.url || github.event.pull_request.url }} - Repo ${repo}, Branch: ${branch}, Git Source URL: ${git_source_url}, Build Opts: ${BUILD_BRANCH_OPT}" ENCODED_CAUSE=$(echo -n "$CAUSE" | jq -s -R -r @uri) JENKINS_JOB_URL="${{ vars.JENKINS_HOST_URL }}/job/Port-Build/buildWithParameters?token=jenkinstest&cause=${ENCODED_CAUSE}" - RESPONSE=$(curl -k -X POST -s -i -u "${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_API_TOKEN }}" "${JENKINS_JOB_URL}" -F PORT_GITHUB_REPO="${repo}" -F PORT_DESCRIPTION="Github CI Test of ${repo}" -F PORT_BRANCH="${branch}" ${BUILD_BRANCH_OPT}) + RESPONSE=$(curl -k -X POST -s -i -u "${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_API_TOKEN }}" "${JENKINS_JOB_URL}" -F PORT_GITHUB_REPO="${repo}" -F PORT_DESCRIPTION="Github CI Test of ${repo}" -F PORT_BRANCH="${branch}" ${GIT_SOURCE_URL_OPT} ${BUILD_BRANCH_OPT}) # Extract the build URL from the response headers BUILD_URL=$(echo "$RESPONSE" | grep -oP "location: \K(.*)" | tr -d '\r') diff --git a/.github/workflows/jenkins-test.yml b/.github/workflows/jenkins-test.yml index 24d3a0bd7..627b996b4 100644 --- a/.github/workflows/jenkins-test.yml +++ b/.github/workflows/jenkins-test.yml @@ -25,4 +25,5 @@ jobs: secrets: inherit with: repo: 'https://github.com/zopencommunity/metaport.git' + git_source_url: ${{ github.event.pull_request.head.repo.clone_url }} use_prbranch_as_build_branch: true diff --git a/bin/zopen-build b/bin/zopen-build index 0109bcbaa..6cefc8a9f 100755 --- a/bin/zopen-build +++ b/bin/zopen-build @@ -50,6 +50,8 @@ Required: stable build URL (either git or tarball). Optional: + ZOPEN_EXTERNAL_URL If set, use this as ZOPEN_URL before checking + ZOPEN_DEV_URL or ZOPEN_STABLE_URL. ZOPEN_EXTRA_CFLAGS C compiler flags to append to CFLAGS (defaults to ''). ZOPEN_EXTRA_CPPFLAGS C,C++ pre-processor flags to append to CPPFLAGS. (defaults to '') @@ -628,10 +630,14 @@ checkEnv() printError "Building from dev, but ZOPEN_DEV_DEPS not specified" fi ZOPEN_DEPS="${ZOPEN_DEV_DEPS}" - if [ -z "${ZOPEN_DEV_URL}" ]; then - printError "Building from dev, but ZOPEN_DEV_URL not specified" + if [ ! -z "${ZOPEN_EXTERNAL_URL}" ]; then + ZOPEN_URL="${ZOPEN_EXTERNAL_URL}" + else + if [ -z "${ZOPEN_DEV_URL}" ]; then + printError "Building from dev, but ZOPEN_DEV_URL not specified" + fi + ZOPEN_URL="${ZOPEN_DEV_URL}" fi - ZOPEN_URL="${ZOPEN_DEV_URL}" if [ ! -z "${ZOPEN_DEV_BRANCH}" ]; then export ZOPEN_GIT_BRANCH="${ZOPEN_DEV_BRANCH}" fi @@ -653,10 +659,14 @@ checkEnv() printError "Building from stable, but ZOPEN_STABLE_DEPS not specified" fi ZOPEN_DEPS="${ZOPEN_STABLE_DEPS}" - if [ -z "${ZOPEN_STABLE_URL}" ]; then - printError "Building from stable, but ZOPEN_STABLE_URL not specified" + if [ ! -z "${ZOPEN_EXTERNAL_URL}" ]; then + ZOPEN_URL="${ZOPEN_EXTERNAL_URL}" + else + if [ -z "${ZOPEN_STABLE_URL}" ]; then + printError "Building from stable, but ZOPEN_STABLE_URL not specified" + fi + ZOPEN_URL="${ZOPEN_STABLE_URL}" fi - ZOPEN_URL="${ZOPEN_STABLE_URL}" if [ ! -z "${ZOPEN_STABLE_BRANCH}" ]; then export ZOPEN_GIT_BRANCH="${ZOPEN_STABLE_BRANCH}" fi diff --git a/cicd/build.groovy b/cicd/build.groovy index 75cfdcdb3..ed04caccf 100755 --- a/cicd/build.groovy +++ b/cicd/build.groovy @@ -5,6 +5,7 @@ # Inputs: # - PORT_GITHUB_REPO : e.g: https://github.com/zopencommunity/makeport.git # - PORT_BRANCH : (default: main) +# - PORT_GIT_SOURCE_URL : optional alternate source URL passed through to zopen-build as ZOPEN_EXTERNAL_URL # - BUILD_LINE: dev or stable # - FORCE_CLANG : Build using clang # Output: @@ -52,6 +53,9 @@ fi if [ ! -z "$BUILD_BRANCH" ]; then export ZOPEN_GIT_BRANCH="$BUILD_BRANCH" fi +if [ ! -z "$PORT_GIT_SOURCE_URL" ]; then + export ZOPEN_EXTERNAL_URL="$PORT_GIT_SOURCE_URL" +fi git clone -b "${PORT_BRANCH}" "${PORT_GITHUB_REPO}" ${PORT_NAME} && cd ${PORT_NAME} # Always run tests and update dependencies and generate pax file From d1b94901d1365c416793f2d35573f8c6e3107fe5 Mon Sep 17 00:00:00 2001 From: Sachin T Date: Fri, 8 May 2026 07:46:22 +0530 Subject: [PATCH 2/2] feat: add source_url parameter to build workflows for testing from forked repositories --- .github/workflows/build_and_test.yml | 22 +++++++++++++++------- .github/workflows/jenkins-test.yml | 2 +- bin/zopen-build | 10 +++++----- cicd/build.groovy | 6 +++--- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index e95afd31e..6d8d23bc9 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -11,10 +11,14 @@ on: required: false default: "" type: string - git_source_url: + source_url: required: false default: "" type: string + use_pr_source_url: + required: false + default: false + type: boolean use_prbranch_as_build_branch: required: false default: false @@ -63,22 +67,26 @@ jobs: if [ -z "${branch}" ]; then branch="${{ fromJson(steps.request.outputs.data).head.ref }}" fi - git_source_url="${{ inputs.git_source_url }}" - GIT_SOURCE_URL_OPT="" - if [ -n "${git_source_url}" ]; then - GIT_SOURCE_URL_OPT="-F PORT_GIT_SOURCE_URL=${git_source_url}" + if ${{ inputs.use_pr_source_url }}; then + source_url="${{ fromJson(steps.request.outputs.data).head.repo.clone_url }}" + else + source_url="${{ inputs.source_url }}" + fi + SOURCE_URL_OPT="" + if [ -n "${source_url}" ]; then + SOURCE_URL_OPT="-F PORT_SOURCE_URL=${source_url}" fi BUILD_BRANCH_OPT="" if ${{ inputs.use_prbranch_as_build_branch }}; then BUILD_BRANCH_OPT="-F BUILD_BRANCH=${branch}" branch="main" fi - CAUSE="Triggered by GH Action from PR: ${{ github.event.issue.pull_request.url || github.event.pull_request.url }} - Repo ${repo}, Branch: ${branch}, Git Source URL: ${git_source_url}, Build Opts: ${BUILD_BRANCH_OPT}" + CAUSE="Triggered by GH Action from PR: ${{ github.event.issue.pull_request.url || github.event.pull_request.url }} - Repo ${repo}, Branch: ${branch}, Source URL: ${source_url}, Build Opts: ${BUILD_BRANCH_OPT}" ENCODED_CAUSE=$(echo -n "$CAUSE" | jq -s -R -r @uri) JENKINS_JOB_URL="${{ vars.JENKINS_HOST_URL }}/job/Port-Build/buildWithParameters?token=jenkinstest&cause=${ENCODED_CAUSE}" - RESPONSE=$(curl -k -X POST -s -i -u "${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_API_TOKEN }}" "${JENKINS_JOB_URL}" -F PORT_GITHUB_REPO="${repo}" -F PORT_DESCRIPTION="Github CI Test of ${repo}" -F PORT_BRANCH="${branch}" ${GIT_SOURCE_URL_OPT} ${BUILD_BRANCH_OPT}) + RESPONSE=$(curl -k -X POST -s -i -u "${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_API_TOKEN }}" "${JENKINS_JOB_URL}" -F PORT_GITHUB_REPO="${repo}" -F PORT_DESCRIPTION="Github CI Test of ${repo}" -F PORT_BRANCH="${branch}" ${SOURCE_URL_OPT} ${BUILD_BRANCH_OPT}) # Extract the build URL from the response headers BUILD_URL=$(echo "$RESPONSE" | grep -oP "location: \K(.*)" | tr -d '\r') diff --git a/.github/workflows/jenkins-test.yml b/.github/workflows/jenkins-test.yml index 627b996b4..dcca9965e 100644 --- a/.github/workflows/jenkins-test.yml +++ b/.github/workflows/jenkins-test.yml @@ -25,5 +25,5 @@ jobs: secrets: inherit with: repo: 'https://github.com/zopencommunity/metaport.git' - git_source_url: ${{ github.event.pull_request.head.repo.clone_url }} + use_pr_source_url: true use_prbranch_as_build_branch: true diff --git a/bin/zopen-build b/bin/zopen-build index 6cefc8a9f..00a0dd858 100755 --- a/bin/zopen-build +++ b/bin/zopen-build @@ -50,7 +50,7 @@ Required: stable build URL (either git or tarball). Optional: - ZOPEN_EXTERNAL_URL If set, use this as ZOPEN_URL before checking + ZOPEN_SOURCE_URL If set, use this as ZOPEN_URL before checking ZOPEN_DEV_URL or ZOPEN_STABLE_URL. ZOPEN_EXTRA_CFLAGS C compiler flags to append to CFLAGS (defaults to ''). ZOPEN_EXTRA_CPPFLAGS C,C++ pre-processor flags to append to CPPFLAGS. @@ -630,8 +630,8 @@ checkEnv() printError "Building from dev, but ZOPEN_DEV_DEPS not specified" fi ZOPEN_DEPS="${ZOPEN_DEV_DEPS}" - if [ ! -z "${ZOPEN_EXTERNAL_URL}" ]; then - ZOPEN_URL="${ZOPEN_EXTERNAL_URL}" + if [ ! -z "${ZOPEN_SOURCE_URL}" ]; then + ZOPEN_URL="${ZOPEN_SOURCE_URL}" else if [ -z "${ZOPEN_DEV_URL}" ]; then printError "Building from dev, but ZOPEN_DEV_URL not specified" @@ -659,8 +659,8 @@ checkEnv() printError "Building from stable, but ZOPEN_STABLE_DEPS not specified" fi ZOPEN_DEPS="${ZOPEN_STABLE_DEPS}" - if [ ! -z "${ZOPEN_EXTERNAL_URL}" ]; then - ZOPEN_URL="${ZOPEN_EXTERNAL_URL}" + if [ ! -z "${ZOPEN_SOURCE_URL}" ]; then + ZOPEN_URL="${ZOPEN_SOURCE_URL}" else if [ -z "${ZOPEN_STABLE_URL}" ]; then printError "Building from stable, but ZOPEN_STABLE_URL not specified" diff --git a/cicd/build.groovy b/cicd/build.groovy index ed04caccf..8d471bc4c 100755 --- a/cicd/build.groovy +++ b/cicd/build.groovy @@ -5,7 +5,7 @@ # Inputs: # - PORT_GITHUB_REPO : e.g: https://github.com/zopencommunity/makeport.git # - PORT_BRANCH : (default: main) -# - PORT_GIT_SOURCE_URL : optional alternate source URL passed through to zopen-build as ZOPEN_EXTERNAL_URL +# - PORT_SOURCE_URL : optional alternate source URL passed through to zopen-build as ZOPEN_SOURCE_URL # - BUILD_LINE: dev or stable # - FORCE_CLANG : Build using clang # Output: @@ -53,8 +53,8 @@ fi if [ ! -z "$BUILD_BRANCH" ]; then export ZOPEN_GIT_BRANCH="$BUILD_BRANCH" fi -if [ ! -z "$PORT_GIT_SOURCE_URL" ]; then - export ZOPEN_EXTERNAL_URL="$PORT_GIT_SOURCE_URL" +if [ ! -z "$PORT_SOURCE_URL" ]; then + export ZOPEN_SOURCE_URL="$PORT_SOURCE_URL" fi git clone -b "${PORT_BRANCH}" "${PORT_GITHUB_REPO}" ${PORT_NAME} && cd ${PORT_NAME}