diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 679401620..6d8d23bc9 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -11,6 +11,14 @@ on: required: false default: "" type: string + 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 @@ -59,17 +67,26 @@ jobs: if [ -z "${branch}" ]; then branch="${{ fromJson(steps.request.outputs.data).head.ref }}" fi + 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}, 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}" ${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 24d3a0bd7..dcca9965e 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' + use_pr_source_url: true use_prbranch_as_build_branch: true diff --git a/bin/zopen-build b/bin/zopen-build index 0109bcbaa..00a0dd858 100755 --- a/bin/zopen-build +++ b/bin/zopen-build @@ -50,6 +50,8 @@ Required: stable build URL (either git or tarball). Optional: + 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. (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_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" + 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_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" + 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..8d471bc4c 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_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: @@ -52,6 +53,9 @@ fi if [ ! -z "$BUILD_BRANCH" ]; then export ZOPEN_GIT_BRANCH="$BUILD_BRANCH" fi +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} # Always run tests and update dependencies and generate pax file