1- # Regenerates a single test file and creates a PR for review
1+ # Regenerates a single test file and creates a PR for review.
2+ # Optionally accepts a dependabot-core branch name to use a custom updater image
3+ # built from that branch, enabling smoke test updates before merging core PRs.
24name : Regenerate Test
35
46on : # yamllint disable-line rule:truthy
@@ -8,6 +10,10 @@ on: # yamllint disable-line rule:truthy
810 description : ' Test name to regenerate (e.g. npm, bundler, go, etc.)'
911 required : true
1012 type : string
13+ core-branch :
14+ description : ' dependabot-core branch to use (leave empty for latest release)'
15+ required : false
16+ type : string
1117
1218permissions :
1319 contents : write
@@ -42,12 +48,78 @@ jobs:
4248 echo "$GITHUB_WORKSPACE" >> $GITHUB_PATH
4349 ./dependabot --version
4450
51+ - name : Resolve updater image
52+ id : resolve_image
53+ if : inputs.core-branch != ''
54+ run : |
55+ # Map test names to ecosystem image suffixes
56+ declare -A ECOSYSTEM_MAP=(
57+ ["actions"]="github-actions"
58+ ["bundler"]="bundler"
59+ ["cargo"]="cargo"
60+ ["composer"]="composer"
61+ ["devcontainers"]="devcontainers"
62+ ["docker"]="docker"
63+ ["dotnet-sdk"]="dotnet-sdk"
64+ ["elm"]="elm"
65+ ["go"]="gomod"
66+ ["gradle"]="gradle"
67+ ["hex"]="mix"
68+ ["maven"]="maven"
69+ ["npm"]="npm"
70+ ["nuget"]="nuget"
71+ ["pub"]="pub"
72+ ["python"]="pip"
73+ ["rust-toolchain"]="rust-toolchain"
74+ ["submodules"]="gitsubmodule"
75+ ["swift"]="swift"
76+ ["terraform"]="terraform"
77+ ["vcpkg"]="vcpkg"
78+ )
79+
80+ # Extract base test name (e.g. npm-group-rules -> npm, dotnet-sdk-security -> dotnet-sdk)
81+ TEST="${{ inputs.test }}"
82+ ECOSYSTEM=""
83+ for key in "${!ECOSYSTEM_MAP[@]}"; do
84+ if [[ "$TEST" == "$key" || "$TEST" == "$key"-* ]]; then
85+ # Pick the longest matching key
86+ if [ ${#key} -gt ${#ECOSYSTEM} ]; then
87+ ECOSYSTEM="${ECOSYSTEM_MAP[$key]}"
88+ MATCH="$key"
89+ fi
90+ fi
91+ done
92+
93+ if [ -z "$ECOSYSTEM" ]; then
94+ echo "Error: Could not determine ecosystem for test '$TEST'"
95+ echo "Supported base test names: ${!ECOSYSTEM_MAP[*]}"
96+ exit 1
97+ fi
98+ echo "Matched test '$TEST' to ecosystem '$ECOSYSTEM' (via key '$MATCH')"
99+
100+ # Get the latest commit SHA from the dependabot-core branch
101+ BRANCH="${{ inputs.core-branch }}"
102+ SHA=$(gh api repos/dependabot/dependabot-core/commits/"$BRANCH" --jq .sha)
103+ if [ -z "$SHA" ]; then
104+ echo "Error: Could not resolve branch '$BRANCH' in dependabot/dependabot-core"
105+ exit 1
106+ fi
107+ echo "Resolved branch '$BRANCH' to SHA: $SHA"
108+
109+ IMAGE="ghcr.io/dependabot/dependabot-updater-${ECOSYSTEM}:${SHA}"
110+ echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
111+ echo "Using updater image: $IMAGE"
112+
45113 - name : Regenerate test
46114 env :
47115 LOCAL_GITHUB_ACCESS_TOKEN : ${{ secrets.GITHUB_TOKEN }}
48116 run : |
49117 TEST_FILE="tests/smoke-${{ inputs.test }}.yaml"
50- script/regen.sh "$TEST_FILE" || true
118+ EXTRA_ARGS=""
119+ if [ -n "${{ steps.resolve_image.outputs.image }}" ]; then
120+ EXTRA_ARGS="--updater-image=${{ steps.resolve_image.outputs.image }}"
121+ fi
122+ dependabot test -f "$TEST_FILE" -o "$TEST_FILE" $EXTRA_ARGS || true
51123
52124 - name : Check for changes
53125 id : check_changes
@@ -77,12 +149,18 @@ jobs:
77149 git commit -m "Regenerate ${{ inputs.test }} test"
78150 git push origin "$BRANCH_NAME"
79151
152+ CORE_BRANCH_NOTE=""
153+ if [ -n "${{ inputs.core-branch }}" ]; then
154+ CORE_BRANCH_NOTE=$'\n**dependabot-core branch:** `${{ inputs.core-branch }}`'
155+ CORE_BRANCH_NOTE+=$'\n**Updater image:** `${{ steps.resolve_image.outputs.image }}`\n'
156+ fi
157+
80158 PR_BODY=$(cat <<EOF
81159 This PR regenerates the \`${{ inputs.test }}\` test file.
82160
83161 **Test regenerated:** \`$TEST_FILE\`
84-
85- The test was regenerated using \`script/regen.sh \` to update it with the latest dependency information.
162+ ${CORE_BRANCH_NOTE}
163+ The test was regenerated using \`dependabot test \` to update it with the latest dependency information.
86164
87165 Please review the changes to ensure they are expected.
88166 EOF
0 commit comments