Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sync] Sync webhook dependencies #16

Open
wants to merge 4 commits into
base: sync
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/scripts/sync-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

set -e

RANCHER_REPO_DIR=$1

DEPS_TO_SYNC="
github.com/rancher/wrangler
"

rancher_deps=$(cd "$RANCHER_REPO_DIR" && go mod graph)
webhook_deps=$(go mod graph)

rancher_ref=$(cd "$RANCHER_REPO_DIR" && git rev-parse HEAD)
rancher_ref_version=$(go mod download -json "github.com/rancher/rancher/pkg/apis@$rancher_ref" | jq -r '.Version')
echo "Syncing github.com/rancher/rancher/pkg/apis"
go mod edit "-require=github.com/rancher/rancher/pkg/apis@$rancher_ref_version"

for dep in $DEPS_TO_SYNC; do
echo "Rancher Dep $dep $(echo "$rancher_deps" | grep "^$dep@\w*\S")"
echo "Webhook Dep $dep $(echo "$webhook_deps" | grep "^$dep@\w*\S")"
rancher_version=$(echo "$rancher_deps" | grep "^$dep@\w*\S" | head -n 1 | cut -d' ' -f1 | cut -d@ -f2)
webhook_version=$(echo "$webhook_deps" | grep "^$dep@\w*\S" | head -n 1 | cut -d' ' -f1 | cut -d@ -f2)
if [ -z "$webhook_version" ] || [ -z "$rancher_version" ] || [ "$rancher_version" = "$webhook_version" ]; then
continue
fi

echo "Version mismatch for $dep (rancher=$rancher_version, webhook=$webhook_version) detected"
go mod edit -require=$dep@$rancher_version
done

echo "Running go mod tidy"
go mod tidy
77 changes: 77 additions & 0 deletions .github/workflows/sync-deps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Sync dependencies

on:
workflow_dispatch:
inputs:
rancher_ref:
description: "Version of rancher/rancher to compare"
required: true
default: "main"
rancher_repository:
description: "Repository for rancher/rancher"
required: true
default: "rancher/rancher"

env:
RANCHER_REF: "${{ github.event.inputs.rancher_ref }}"
WEBHOOK_REF: "${{ github.ref_name }}"

permissions:
contents: write
pull-requests: write

jobs:
sync:
name: Sync dependencies
runs-on: ubuntu-latest
steps:
- name : Checkout webhook repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: "${{ env.WEBHOOK_REF }}"
path: webhook

- name : Checkout rancher repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: "${{ github.event.inputs.rancher_repository }}"
ref: "${{ env.RANCHER_REF }}"
path: rancher

- name: Install dependencies
run: sudo snap install yq --channel=v4/stable

- name: Configure the committer
run: |
cd webhook
git config --global user.name "Webhook Sync Bot"
git config --global user.email "webhooksyncbot@users.noreply.github.com"

- name: Run sync-deps script
run: |
cd webhook
BRANCH="sync-deps-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
git checkout -b "$BRANCH"
./.github/workflows/scripts/sync-deps.sh ../rancher
git add go.mod go.sum
git commit -m "Sync dependencies"
git push origin "$BRANCH"

- name: Create PR
run: |
cd webhook
body=$(cat <<EOF
# Sync with Rancher

The workflow was triggered by $GITHUB_TRIGGERING_ACTOR.
EOF
)
gh pr create \
--title "[$WEBHOOK_REF] Sync webhook dependencies" \
--body "$body" \
--repo "${{ github.repository }}" \
--head "${{ github.repository_owner }}:$BRANCH" \
--base "$WEBHOOK_REF"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42 changes: 21 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@ require (
github.com/gorilla/mux v1.8.1
github.com/rancher/dynamiclistener v0.6.1
github.com/rancher/lasso v0.0.0-20240924233157-8f384efc8813
github.com/rancher/rancher/pkg/apis v0.0.0-20241107150810-8b9e1881ab4b
github.com/rancher/rke v1.7.0-rc.5
github.com/rancher/rancher/pkg/apis v0.0.0-20241213075100-ca82c9717ceb
github.com/rancher/rke v1.7.1-rc.2
github.com/rancher/wrangler/v3 v3.1.0
github.com/robfig/cron v1.2.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
go.uber.org/mock v0.5.0
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/text v0.19.0
golang.org/x/tools v0.24.0
golang.org/x/text v0.21.0
golang.org/x/tools v0.26.0
k8s.io/api v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/apiserver v0.31.1
k8s.io/client-go v12.0.0+incompatible
k8s.io/kubernetes v1.31.1
k8s.io/pod-security-admission v0.31.1
k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/controller-runtime v0.19.3
sigs.k8s.io/yaml v1.4.0
)

Expand Down Expand Up @@ -109,10 +109,10 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rancher/aks-operator v1.10.0 // indirect
github.com/rancher/eks-operator v1.10.0 // indirect
github.com/rancher/fleet/pkg/apis v0.11.0-rc.2 // indirect
github.com/rancher/gke-operator v1.10.0 // indirect
github.com/rancher/aks-operator v1.10.1-rc.2 // indirect
github.com/rancher/eks-operator v1.10.1-rc.2 // indirect
github.com/rancher/fleet/pkg/apis v0.11.0 // indirect
github.com/rancher/gke-operator v1.10.1-rc.3 // indirect
github.com/rancher/norman v0.0.0-20241001183610-78a520c160ab // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -132,19 +132,19 @@ require (
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/crypto v0.30.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.32.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/time v0.8.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240930140551-af27646dc61f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
Expand Down
Loading