Skip to content

Commit ee9b028

Browse files
authored
Merge pull request #30 from LeanBitLab/fleet-init-1777570352841
chore: initialize fleet workflows
2 parents ad1be4d + 34b13f6 commit ee9b028

6 files changed

Lines changed: 247 additions & 0 deletions

File tree

.fleet/goals/example.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
milestone: "1"
3+
---
4+
5+
# Example Fleet Goal
6+
7+
Analyze the codebase for potential improvements and create
8+
issues for the engineering team.
9+
10+
## Tools
11+
- Test Coverage: `npx vitest --coverage --json`
12+
13+
## Assessment Hints
14+
- Focus on missing error handling in API routes
15+
- Look for hardcoded configuration values
16+
17+
## Insight Hints
18+
- Report on overall test coverage metrics
19+
- Note any unusually complex functions (cyclomatic complexity)
20+
21+
## Constraints
22+
- Do NOT propose changes already covered by open issues
23+
- Do NOT propose changes rejected in recently closed issues
24+
- Keep tasks small and isolated — one logical change per issue
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Generated by @google/jules-fleet init
2+
# https://github.com/google-labs-code/jules-sdk
3+
4+
name: Fleet Analyze
5+
6+
on:
7+
schedule:
8+
- cron: '0 */6 * * *'
9+
workflow_dispatch:
10+
inputs:
11+
goal:
12+
description: 'Path to goal file (or blank for all)'
13+
type: string
14+
default: ''
15+
milestone:
16+
description: 'Milestone ID override'
17+
type: string
18+
default: ''
19+
20+
concurrency:
21+
group: fleet-analyze
22+
cancel-in-progress: false
23+
24+
jobs:
25+
analyze:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
issues: write
30+
pull-requests: read
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: '22'
36+
- run: npx -y --package=@google/jules-fleet jules-fleet analyze --goal "${{ inputs.goal }}" --milestone "${{ inputs.milestone }}"
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
JULES_API_KEY: ${{ secrets.JULES_API_KEY }}
40+
FLEET_APP_ID: ${{ secrets.FLEET_APP_ID }}
41+
FLEET_APP_PRIVATE_KEY_BASE64: ${{ secrets.FLEET_APP_PRIVATE_KEY_BASE64 }}
42+
FLEET_APP_INSTALLATION_ID: ${{ secrets.FLEET_APP_INSTALLATION_ID }}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Generated by @google/jules-fleet init
2+
# https://github.com/google-labs-code/jules-sdk
3+
4+
name: Fleet Dispatch
5+
6+
on:
7+
schedule:
8+
- cron: '0 3-23/6 * * *'
9+
workflow_dispatch:
10+
inputs:
11+
milestone:
12+
description: 'Milestone ID to dispatch (leave empty to dispatch all)'
13+
type: string
14+
required: false
15+
16+
concurrency:
17+
group: fleet-dispatch
18+
cancel-in-progress: false
19+
20+
jobs:
21+
discover:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
milestones: ${{ steps.list.outputs.milestones }}
25+
steps:
26+
- name: Resolve milestones
27+
id: list
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
INPUT_MILESTONE: ${{ inputs.milestone }}
31+
run: |
32+
if [ -n "$INPUT_MILESTONE" ]; then
33+
echo "milestones=[\"$INPUT_MILESTONE\"]" >> "$GITHUB_OUTPUT"
34+
else
35+
milestones=$(gh api repos/${{ github.repository }}/milestones --jq '[.[].number | tostring]')
36+
echo "milestones=$milestones" >> "$GITHUB_OUTPUT"
37+
fi
38+
39+
dispatch:
40+
needs: discover
41+
runs-on: ubuntu-latest
42+
strategy:
43+
matrix:
44+
milestone: ${{ fromJSON(needs.discover.outputs.milestones) }}
45+
permissions:
46+
contents: read
47+
issues: write
48+
steps:
49+
- uses: actions/checkout@v4
50+
- uses: actions/setup-node@v4
51+
with:
52+
node-version: '22'
53+
- run: npx -y --package=@google/jules-fleet jules-fleet dispatch --milestone ${{ matrix.milestone }}
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
JULES_API_KEY: ${{ secrets.JULES_API_KEY }}
57+
FLEET_APP_ID: ${{ secrets.FLEET_APP_ID }}
58+
FLEET_APP_PRIVATE_KEY_BASE64: ${{ secrets.FLEET_APP_PRIVATE_KEY_BASE64 }}
59+
FLEET_APP_INSTALLATION_ID: ${{ secrets.FLEET_APP_INSTALLATION_ID }}

.github/workflows/fleet-label.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Fleet Label PR
2+
on:
3+
pull_request:
4+
types: [opened, edited, synchronize]
5+
6+
permissions:
7+
pull-requests: write
8+
issues: read
9+
10+
jobs:
11+
label_pr:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check linked issue and apply label/milestone
15+
env:
16+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
PR_URL: ${{ github.event.pull_request.html_url }}
18+
REPO: ${{ github.repository }}
19+
run: |
20+
# Use GitHub's own closing keyword resolution to find linked issues
21+
ISSUE_NUMBER=$(gh pr view "$PR_URL" --json closingIssuesReferences --jq '.closingIssuesReferences[0].number // empty')
22+
23+
if [ -z "$ISSUE_NUMBER" ]; then
24+
echo "No closing issue reference found on this PR. Exiting."
25+
exit 0
26+
fi
27+
28+
echo "Found linked issue: #$ISSUE_NUMBER"
29+
30+
# Check if the linked issue has the 'fleet' label
31+
HAS_FLEET=$(gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json labels --jq '[.labels[].name] | any(. == "fleet")')
32+
33+
if [ "$HAS_FLEET" = "true" ]; then
34+
echo "Linked issue has 'fleet' label. Applying 'fleet-merge-ready' to PR."
35+
gh pr edit "$PR_URL" --add-label "fleet-merge-ready"
36+
37+
# Check if linked issue has a milestone and copy it
38+
MILESTONE_TITLE=$(gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json milestone --jq '.milestone.title // empty')
39+
if [ -n "$MILESTONE_TITLE" ]; then
40+
echo "Applying milestone '$MILESTONE_TITLE' to PR."
41+
gh pr edit "$PR_URL" --milestone "$MILESTONE_TITLE"
42+
fi
43+
else
44+
echo "Linked issue does not have 'fleet' label. Ignoring."
45+
fi

.github/workflows/fleet-merge.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Generated by @google/jules-fleet init
2+
# https://github.com/google-labs-code/jules-sdk
3+
4+
name: Fleet Merge
5+
6+
on:
7+
schedule:
8+
- cron: '0 */3 * * *'
9+
workflow_dispatch:
10+
inputs:
11+
mode:
12+
description: 'PR selection mode'
13+
type: choice
14+
options:
15+
- label
16+
- fleet-run
17+
default: 'label'
18+
fleet_run_id:
19+
description: 'Fleet run ID (required for fleet-run mode)'
20+
type: string
21+
default: ''
22+
redispatch:
23+
description: 'Enable smart conflict resolution'
24+
type: boolean
25+
default: true
26+
27+
concurrency:
28+
group: fleet-merge
29+
cancel-in-progress: true
30+
31+
jobs:
32+
merge:
33+
runs-on: ubuntu-latest
34+
permissions:
35+
contents: write
36+
pull-requests: write
37+
issues: write
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-node@v4
41+
with:
42+
node-version: '22'
43+
- run: |
44+
REDISPATCH_FLAG="--redispatch"
45+
if [ "${{ inputs.redispatch }}" = "false" ]; then
46+
REDISPATCH_FLAG=""
47+
fi
48+
npx -y --package=@google/jules-fleet jules-fleet merge --mode ${{ inputs.mode || 'label' }} --run-id "${{ inputs.fleet_run_id }}" $REDISPATCH_FLAG
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
JULES_API_KEY: ${{ secrets.JULES_API_KEY }}
52+
FLEET_APP_ID: ${{ secrets.FLEET_APP_ID }}
53+
FLEET_APP_PRIVATE_KEY_BASE64: ${{ secrets.FLEET_APP_PRIVATE_KEY_BASE64 }}
54+
FLEET_APP_INSTALLATION_ID: ${{ secrets.FLEET_APP_INSTALLATION_ID }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by @google/jules-fleet init
2+
# This workflow scans PRs for overlapping file changes.
3+
name: Conflict Detection
4+
5+
on:
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: read
12+
13+
jobs:
14+
scan-overlaps:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Scan for overlapping changes
22+
run: |
23+
npx -y --package=@google/jules-merge jules-merge scan --json '{"prs":[${{ github.event.pull_request.number }}],"repo":"${{ github.repository }}","base":"${{ github.event.pull_request.base.ref }}"}'

0 commit comments

Comments
 (0)