Skip to content

Commit 6f7f04d

Browse files
committed
Add monorepo CI (orchestrators referencing redhat-cne/upstream-ptp-operator-monorepo)
Orchestrator workflows call reusable workflows from redhat-cne/upstream-ptp-operator-monorepo@main. Use .github/scripts/set-workflow-repo.sh to change the upstream reference. hack/gofmt.sh updated to exclude pkg/linuxptp-daemon/vendor and pkg/cloud-event-proxy/vendor. scripts/fetch-upstream-ci.sh added for local testing against upstream.
1 parent fa49e55 commit 6f7f04d

20 files changed

+447
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# Script to set or reset the repository reference in workflow files
3+
#
4+
# Usage:
5+
# ./set-workflow-repo.sh # Reset to default (k8snetworkplumbingwg/ptp-operator)
6+
# ./set-workflow-repo.sh owner/repo # Set to custom repository
7+
# ./set-workflow-repo.sh --current # Show current repository reference
8+
9+
set -e
10+
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
WORKFLOWS_DIR="$SCRIPT_DIR/../workflows"
13+
DEFAULT_REPO="redhat-cne/upstream-ptp-operator-monorepo"
14+
15+
get_current_repo() {
16+
grep -h "uses:.*/_reusable-" "$WORKFLOWS_DIR"/*.y*ml 2>/dev/null | \
17+
head -1 | \
18+
sed 's/.*uses: \([^/]*\/[^/]*\)\/.*/\1/' || echo "unknown"
19+
}
20+
21+
show_current() {
22+
local current=$(get_current_repo)
23+
echo "Current repository reference: $current"
24+
[ "$current" = "$DEFAULT_REPO" ] && echo "Status: Using default" || echo "Status: Custom (default: $DEFAULT_REPO)"
25+
}
26+
27+
set_repo() {
28+
local new_repo="$1"
29+
local current=$(get_current_repo)
30+
31+
[ "$current" = "$new_repo" ] && echo "Already set to: $new_repo" && return 0
32+
33+
echo "Updating: $current -> $new_repo"
34+
35+
local count=0
36+
for f in "$WORKFLOWS_DIR"/*.y*ml; do
37+
[[ "$(basename "$f")" == _reusable-* ]] && continue
38+
if grep -q "uses:.*/_reusable-" "$f"; then
39+
perl -i -pe "s|uses: [^/]+/[^/]+/\.github/workflows/(_reusable-)|uses: $new_repo/.github/workflows/\$1|g" "$f"
40+
((count++))
41+
fi
42+
done
43+
44+
echo "Updated $count files"
45+
show_current
46+
}
47+
48+
case "${1:-}" in
49+
--current|-c) show_current ;;
50+
--help|-h) echo "Usage: $0 [owner/repo | --current]" ;;
51+
"") set_repo "$DEFAULT_REPO" ;;
52+
*) [[ "$1" =~ ^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$ ]] && set_repo "$1" || echo "Error: Invalid format (expected: owner/repo)" ;;
53+
esac
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "cloud-event-proxy: Build and Push Consumer Image"
2+
on:
3+
push:
4+
branches: [main, release-4.18]
5+
paths:
6+
- 'pkg/cloud-event-proxy/**'
7+
8+
jobs:
9+
build:
10+
uses: redhat-cne/upstream-ptp-operator-monorepo/.github/workflows/_reusable-cloud-event-proxy-build.yml@main
11+
with:
12+
version: ${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'release-4.18' && '4.18' || 'unknown' }}
13+
secrets: inherit
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "cloud-event-proxy: CI"
2+
on:
3+
push:
4+
paths:
5+
- 'pkg/cloud-event-proxy/**'
6+
pull_request:
7+
paths:
8+
- 'pkg/cloud-event-proxy/**'
9+
10+
jobs:
11+
ci:
12+
uses: redhat-cne/upstream-ptp-operator-monorepo/.github/workflows/_reusable-cloud-event-proxy-ci.yml@main
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "linuxptp-daemon: Go mod tidy and vendor"
2+
on:
3+
push:
4+
branches: ["main", "one-repo*", "release-*"]
5+
paths:
6+
- 'pkg/linuxptp-daemon/**'
7+
pull_request:
8+
paths:
9+
- 'pkg/linuxptp-daemon/**'
10+
11+
jobs:
12+
check:
13+
uses: redhat-cne/upstream-ptp-operator-monorepo/.github/workflows/_reusable-linuxptp-daemon-check-go-mod-vendor.yml@main
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "linuxptp-daemon: CodeQL Advanced"
2+
on:
3+
push:
4+
branches: ["main", "one-repo*", "release-*"]
5+
paths:
6+
- 'pkg/linuxptp-daemon/**'
7+
pull_request:
8+
paths:
9+
- 'pkg/linuxptp-daemon/**'
10+
schedule:
11+
- cron: '20 21 * * 4'
12+
13+
permissions:
14+
security-events: write
15+
packages: read
16+
actions: read
17+
contents: read
18+
19+
jobs:
20+
analyze:
21+
uses: redhat-cne/upstream-ptp-operator-monorepo/.github/workflows/_reusable-linuxptp-daemon-codeql.yml@main
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "linuxptp-daemon: Go"
2+
on:
3+
push:
4+
branches: ["main", "one-repo*", "release-*"]
5+
paths:
6+
- 'pkg/linuxptp-daemon/**'
7+
pull_request:
8+
paths:
9+
- 'pkg/linuxptp-daemon/**'
10+
11+
jobs:
12+
build:
13+
uses: redhat-cne/upstream-ptp-operator-monorepo/.github/workflows/_reusable-linuxptp-daemon-go.yml@main
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "linuxptp-daemon: Push image on merge to main"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'pkg/linuxptp-daemon/**'
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
push-image:
15+
uses: redhat-cne/upstream-ptp-operator-monorepo/.github/workflows/_reusable-linuxptp-daemon-image-push.yml@main
16+
secrets: inherit
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "linuxptp-daemon: golangci-lint"
2+
on:
3+
push:
4+
branches: ["main", "one-repo*", "release-*"]
5+
paths:
6+
- 'pkg/linuxptp-daemon/**'
7+
pull_request:
8+
paths:
9+
- 'pkg/linuxptp-daemon/**'
10+
11+
permissions:
12+
contents: read
13+
pull-requests: read
14+
15+
jobs:
16+
lint:
17+
uses: redhat-cne/upstream-ptp-operator-monorepo/.github/workflows/_reusable-linuxptp-daemon-linter.yml@main
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "linuxptp-daemon: PR CI Triggers"
2+
on:
3+
pull_request_target:
4+
types: [opened, reopened]
5+
paths:
6+
- 'pkg/linuxptp-daemon/**'
7+
8+
jobs:
9+
triggers:
10+
uses: redhat-cne/upstream-ptp-operator-monorepo/.github/workflows/_reusable-linuxptp-daemon-pr-ci-triggers.yml@main
11+
secrets: inherit
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: "linuxptp-daemon: Run Jobs on PR"
2+
on:
3+
pull_request:
4+
paths:
5+
- 'pkg/linuxptp-daemon/**'
6+
7+
jobs:
8+
pr-update:
9+
uses: redhat-cne/upstream-ptp-operator-monorepo/.github/workflows/_reusable-linuxptp-daemon-pr-update.yml@main
10+
secrets: inherit

0 commit comments

Comments
 (0)