CI: build-pages job in pre-merge pipeline fails for source branch in forked project
Summary
A "sanity-check" variant of the "build-pages" job (the results aren't published on https://opencpi.gitlab.io) gets run in pre-merge pipelines. The job fails for the particular use case of the source branch coming from a forked project repo (contribution from a partner, the community, etc.), and will cause the entire associated pre-merge pipeline to fail.
The job fails because the forked project source branch isn't present/available to checkout after cloning our repo.
Steps to reproduce
N/A. See "Summary" section above.
Context
Was attempting to perform due diligence on a partner-contributed patch set associated with MR !760 (merged).
Expected correct behavior
The "build-pages" job should detect/catch the non-existent branch use case, emit a warning message, and "succeed" (not cause the rest of the pipeline to fail).
Relevant logs and/or screenshots
Here's a "build-pages" job log excerpt showing the failure associated with the MR !760 (merged) pre-merge pipeline:
(...)
* [new tag] v2.3.0 -> v2.3.0
* [new tag] v2.3.0-rc.1 -> v2.3.0-rc.1
* [new tag] v2.3.1 -> v2.3.1
$ git checkout develop
Previous HEAD position was cb006ca... Merge branch '14-ocpi-comp-sdr-tests-failing' into 'develop'
Switched to a new branch 'develop'
Branch develop set up to track remote branch develop from origin.
$ if [[ "$REF_NAME" == "$CI_COMMIT_REF_NAME" && "$REF_NAME" != 'develop' ]]; then # collapsed multi-line command
error: pathspec '14-ocpi-comp-sdr-tests-failing' did not match any file(s) known to git.
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 1
Environment info
- OpenCPI Version used: current "develop" (post-v2.3.1)
- Type of install (Source or RPM): Source
- Environment vars (
env | grep -i ocpi | sort
): - Operating System and version (ex. CentOS 7): CentOS 7
- Link to your project on GitLab (optional):
Possible fixes
Maybe modify the build-pages.py
script to perform the suggested action mentioned in the "Expected correct behavior" section above. Need to ensure a branch is unavailable for an allowable (legitimate) reason.