Skip to content

Fix GitLab platform detection for self-hosted instances#8

Open
Gitsko wants to merge 1 commit intomainfrom
fix/gitlab-include-local-detection
Open

Fix GitLab platform detection for self-hosted instances#8
Gitsko wants to merge 1 commit intomainfrom
fix/gitlab-include-local-detection

Conversation

@Gitsko
Copy link
Copy Markdown

@Gitsko Gitsko commented Apr 1, 2026

Summary

  • Platform detection: Self-hosted GitLab instances (e.g. git.netresearch.de) don't contain "gitlab" in the remote URL. Detection now falls back to checking for .gitlab-ci.yml presence before defaulting to GitHub.
  • include:local resolution: check_ci_workflow() now follows include: local: references in .gitlab-ci.yml (including glob patterns like Build/GitlabCiTasks/*.yml) when searching for the harness-verify job.
  • MR template detection: With correct platform detection, the existing .gitlab/merge_request_templates/ check now triggers correctly.

Test plan

  • Run verify-harness.sh in a repo with self-hosted GitLab remote (no "gitlab" in URL) -- should detect GitLab platform
  • Run in a repo where harness-verify job is in an include: local: file (with glob) -- should find the job
  • Run in a GitHub repo -- no behavior change

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 703a0f5.
Ensure 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 Files

None

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml presence when the remote URL doesn’t contain gitlab.
  • Extend GitLab CI verification to scan include: local: referenced files (including glob patterns) for harness-verify / verify-harness.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +322 to +325
# 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
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +336 to +337
done < <(grep -oP 'local:\s*\K\S+' ".gitlab-ci.yml" 2>/dev/null \
| sed "s/['\"]//g" || true)
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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
)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants