Fix GitLab platform detection for self-hosted instances#8
Fix GitLab platform detection for self-hosted instances#8
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
There was a problem hiding this comment.
Code Review
This pull request enhances the platform detection and CI workflow verification in the verify-harness.sh script. It improves platform identification by checking for the presence of .gitlab-ci.yml or the .github directory, which helps identify self-hosted instances. Additionally, the GitLab CI workflow check now recursively searches for harness jobs within locally included configuration files. I have no feedback to provide.
There was a problem hiding this comment.
Pull request overview
Improves verify-harness.sh’s ability to correctly detect GitLab (including self-hosted instances) and to locate the harness verification job across GitLab CI configurations that use include: local:.
Changes:
- Adjust platform detection to infer GitLab from
.gitlab-ci.ymlpresence when the remote URL doesn’t containgitlab. - Extend GitLab CI verification to scan
include: local:referenced files (including glob patterns) forharness-verify/verify-harness.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Search root file and all include:local files for harness job | ||
| local found_harness=false | ||
| if grep -q "harness-verify\|verify-harness" ".gitlab-ci.yml"; then | ||
| pass 2 "CI harness job found in .gitlab-ci.yml" | ||
| found_harness=true |
There was a problem hiding this comment.
grep -q "harness-verify\|verify-harness" relies on \| alternation in basic regex, which isn’t consistently portable across grep implementations. Consider switching to grep -E with harness-verify|verify-harness (or equivalent) to make the match behavior explicit and reliable.
| done < <(grep -oP 'local:\s*\K\S+' ".gitlab-ci.yml" 2>/dev/null \ | ||
| | sed "s/['\"]//g" || true) |
There was a problem hiding this comment.
The include extraction uses grep -oP with PCRE features (-P, \K). This is not portable (e.g., fails on BSD/macOS grep) and is also brittle for valid GitLab CI YAML forms like local: [a.yml, b.yml] or multi-line lists under local:. Consider replacing this with a more portable parser (e.g., awk/sed with POSIX ERE for the supported subset, or an optional python/ruby YAML parse fallback) and documenting the supported include:local shapes.
| done < <(grep -oP 'local:\s*\K\S+' ".gitlab-ci.yml" 2>/dev/null \ | |
| | sed "s/['\"]//g" || true) | |
| done < <( | |
| awk ' | |
| /^[[:space:]]*local:/ { | |
| # Strip leading spaces and "local:" key | |
| sub(/^[[:space:]]*local:[[:space:]]*/, "", $0) | |
| if ($0 != "") { | |
| # Inline value or list, e.g.: | |
| # local: path.yml | |
| # local: [a.yml, b.yml] | |
| gsub(/[][,\r]/, " ") | |
| for (i = 1; i <= NF; i++) { | |
| print $i | |
| } | |
| next | |
| } | |
| in_local = 1 | |
| local_indent = match($0, /[^ ]/) - 1 | |
| next | |
| } | |
| in_local { | |
| # Stop if blank line | |
| if ($0 ~ /^[[:space:]]*$/) { | |
| in_local = 0 | |
| next | |
| } | |
| # Stop if dedented to same or lower indent | |
| cur_indent = match($0, /[^ ]/) - 1 | |
| if (cur_indent <= local_indent) { | |
| in_local = 0 | |
| next | |
| } | |
| # Handle list items like: | |
| # - a.yml | |
| if ($0 ~ /^[[:space:]]*-[[:space:]]*/) { | |
| sub(/^[[:space:]]*-[[:space:]]*/, "", $0) | |
| if ($0 != "") { | |
| print $0 | |
| } | |
| } | |
| } | |
| ' ".gitlab-ci.yml" 2>/dev/null | sed -E "s/['\"]//g" || true | |
| ) |
Summary
git.netresearch.de) don't contain "gitlab" in the remote URL. Detection now falls back to checking for.gitlab-ci.ymlpresence before defaulting to GitHub.check_ci_workflow()now followsinclude: local:references in.gitlab-ci.yml(including glob patterns likeBuild/GitlabCiTasks/*.yml) when searching for theharness-verifyjob..gitlab/merge_request_templates/check now triggers correctly.Test plan
verify-harness.shin a repo with self-hosted GitLab remote (no "gitlab" in URL) -- should detect GitLab platforminclude: local:file (with glob) -- should find the job