Skip to content

Commit 5337bf2

Browse files
committed
ci: configure workflows to be package-by-package
Copied generate script from `charmbracelet/x`.
1 parent 67ff539 commit 5337bf2

7 files changed

Lines changed: 295 additions & 22 deletions

File tree

.github/workflows/ai.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# auto-generated by scripts/builds. DO NOT EDIT.
2+
name: ai
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
paths:
10+
- ai/**
11+
- .github/workflows/ai.yml
12+
13+
jobs:
14+
build:
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
runs-on: ${{ matrix.os }}
19+
defaults:
20+
run:
21+
working-directory: ./ai
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-go@v5
25+
with:
26+
go-version-file: ./ai/go.mod
27+
cache: true
28+
cache-dependency-path: ./ai/go.sum
29+
- run: go build -v ./...
30+
- run: go test -race -v ./...
31+
32+
dependabot:
33+
needs: [build]
34+
runs-on: ubuntu-latest
35+
permissions:
36+
pull-requests: write
37+
contents: write
38+
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
39+
steps:
40+
- id: metadata
41+
uses: dependabot/fetch-metadata@v2
42+
with:
43+
github-token: "${{ secrets.GITHUB_TOKEN }}"
44+
- run: |
45+
gh pr review --approve "$PR_URL"
46+
gh pr merge --squash --auto "$PR_URL"
47+
env:
48+
PR_URL: ${{github.event.pull_request.html_url}}
49+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
50+
51+
lint:
52+
uses: charmbracelet/meta/.github/workflows/lint.yml@main
53+
with:
54+
directory: ./ai/...
55+
golangci_path: .golangci.yml
56+

.github/workflows/anthropic.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# auto-generated by scripts/builds. DO NOT EDIT.
2+
name: anthropic
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
paths:
10+
- providers/anthropic/**
11+
- .github/workflows/anthropic.yml
12+
13+
jobs:
14+
build:
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
runs-on: ${{ matrix.os }}
19+
defaults:
20+
run:
21+
working-directory: ./providers/anthropic
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-go@v5
25+
with:
26+
go-version-file: ./providers/anthropic/go.mod
27+
cache: true
28+
cache-dependency-path: ./providers/anthropic/go.sum
29+
- run: go build -v ./...
30+
- run: go test -race -v ./...
31+
32+
dependabot:
33+
needs: [build]
34+
runs-on: ubuntu-latest
35+
permissions:
36+
pull-requests: write
37+
contents: write
38+
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
39+
steps:
40+
- id: metadata
41+
uses: dependabot/fetch-metadata@v2
42+
with:
43+
github-token: "${{ secrets.GITHUB_TOKEN }}"
44+
- run: |
45+
gh pr review --approve "$PR_URL"
46+
gh pr merge --squash --auto "$PR_URL"
47+
env:
48+
PR_URL: ${{github.event.pull_request.html_url}}
49+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
50+
51+
lint:
52+
uses: charmbracelet/meta/.github/workflows/lint.yml@main
53+
with:
54+
directory: ./providers/anthropic/...
55+
golangci_path: .golangci.yml
56+

.github/workflows/build.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/examples.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# auto-generated by scripts/builds. DO NOT EDIT.
2+
name: examples
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
paths:
10+
- examples/**
11+
- .github/workflows/examples.yml
12+
13+
jobs:
14+
build:
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
runs-on: ${{ matrix.os }}
19+
defaults:
20+
run:
21+
working-directory: ./examples
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-go@v5
25+
with:
26+
go-version-file: ./examples/go.mod
27+
cache: true
28+
cache-dependency-path: ./examples/go.sum
29+
- run: go build -v ./...
30+
- run: go test -race -v ./...
31+
32+
dependabot:
33+
needs: [build]
34+
runs-on: ubuntu-latest
35+
permissions:
36+
pull-requests: write
37+
contents: write
38+
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
39+
steps:
40+
- id: metadata
41+
uses: dependabot/fetch-metadata@v2
42+
with:
43+
github-token: "${{ secrets.GITHUB_TOKEN }}"
44+
- run: |
45+
gh pr review --approve "$PR_URL"
46+
gh pr merge --squash --auto "$PR_URL"
47+
env:
48+
PR_URL: ${{github.event.pull_request.html_url}}
49+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
50+
51+
lint:
52+
uses: charmbracelet/meta/.github/workflows/lint.yml@main
53+
with:
54+
directory: ./examples/...
55+
golangci_path: .golangci.yml
56+

.github/workflows/lint.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/openai.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# auto-generated by scripts/builds. DO NOT EDIT.
2+
name: openai
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
paths:
10+
- providers/openai/**
11+
- .github/workflows/openai.yml
12+
13+
jobs:
14+
build:
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
runs-on: ${{ matrix.os }}
19+
defaults:
20+
run:
21+
working-directory: ./providers/openai
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-go@v5
25+
with:
26+
go-version-file: ./providers/openai/go.mod
27+
cache: true
28+
cache-dependency-path: ./providers/openai/go.sum
29+
- run: go build -v ./...
30+
- run: go test -race -v ./...
31+
32+
dependabot:
33+
needs: [build]
34+
runs-on: ubuntu-latest
35+
permissions:
36+
pull-requests: write
37+
contents: write
38+
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
39+
steps:
40+
- id: metadata
41+
uses: dependabot/fetch-metadata@v2
42+
with:
43+
github-token: "${{ secrets.GITHUB_TOKEN }}"
44+
- run: |
45+
gh pr review --approve "$PR_URL"
46+
gh pr merge --squash --auto "$PR_URL"
47+
env:
48+
PR_URL: ${{github.event.pull_request.html_url}}
49+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
50+
51+
lint:
52+
uses: charmbracelet/meta/.github/workflows/lint.yml@main
53+
with:
54+
directory: ./providers/openai/...
55+
golangci_path: .golangci.yml
56+

scripts/generate_ci

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
3+
# shellcheck disable=SC2016
4+
find . -type f -name go.mod | sort | while read -r mod; do
5+
dir="$(dirname "$mod")"
6+
name="$(basename "$dir")"
7+
# get the parent directory when the module is nested semver-style
8+
if [[ "$name" =~ ^v[0-9]+.*$ ]]; then
9+
ver="$(basename "$dir")"
10+
dir="$(dirname "$dir")"
11+
name="$(basename "$dir")-$ver"
12+
fi
13+
14+
sum="$dir/go.sum"
15+
echo "# auto-generated by scripts/builds. DO NOT EDIT.
16+
name: $name
17+
18+
on:
19+
push:
20+
branches:
21+
- main
22+
pull_request:
23+
paths:
24+
- $(dirname "$mod" | cut -f2- -d/)/**
25+
- .github/workflows/${name}.yml
26+
27+
jobs:
28+
build:
29+
strategy:
30+
matrix:
31+
os: [ubuntu-latest, macos-latest, windows-latest]
32+
runs-on: \${{ matrix.os }}
33+
defaults:
34+
run:
35+
working-directory: $(dirname "$mod")
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: actions/setup-go@v5
39+
with:
40+
go-version-file: $mod
41+
cache: true
42+
cache-dependency-path: $sum
43+
- run: go build -v ./...
44+
- run: go test -race -v ./...
45+
46+
dependabot:
47+
needs: [build]
48+
runs-on: ubuntu-latest
49+
permissions:
50+
pull-requests: write
51+
contents: write
52+
if: \${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
53+
steps:
54+
- id: metadata
55+
uses: dependabot/fetch-metadata@v2
56+
with:
57+
github-token: \"\${{ secrets.GITHUB_TOKEN }}\"
58+
- run: |
59+
gh pr review --approve \"\$PR_URL\"
60+
gh pr merge --squash --auto \"\$PR_URL\"
61+
env:
62+
PR_URL: \${{github.event.pull_request.html_url}}
63+
GITHUB_TOKEN: \${{secrets.GITHUB_TOKEN}}
64+
65+
lint:
66+
uses: charmbracelet/meta/.github/workflows/lint.yml@main
67+
with:
68+
directory: $(dirname "$mod")/...
69+
golangci_path: .golangci.yml
70+
" >"./.github/workflows/${name}.yml"
71+
done

0 commit comments

Comments
 (0)