Skip to content

Commit 1989658

Browse files
committed
Add GitHub Actions workflows for Claude Code and Code Review, as well as for release to pypi
1 parent b443ef3 commit 1989658

File tree

6 files changed

+394
-0
lines changed

6 files changed

+394
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
#!/bin/bash -e
3+
4+
# This script is used to build the system dependencies for MacOS
5+
# It is called by test workflow in .github/workflows/
6+
# To build necessary system dependencies for MacOS, run:
7+
8+
# check if os is MacOS using uname
9+
if [ "$(uname)" = "Darwin" ]; then
10+
# install necessary dependencies
11+
echo "installing necessary dependencies..."
12+
brew install libomp
13+
14+
LIBOMP_PREFIX="$(brew --prefix libomp)"
15+
16+
echo "Verifying libomp installation..."
17+
ls "$LIBOMP_PREFIX/lib/libomp.dylib"
18+
19+
{
20+
echo "DYLD_LIBRARY_PATH=$LIBOMP_PREFIX/lib:\$DYLD_LIBRARY_PATH"
21+
echo "LDFLAGS=-L$LIBOMP_PREFIX/lib"
22+
echo "CPPFLAGS=-I$LIBOMP_PREFIX/include"
23+
} >> "$GITHUB_ENV"
24+
else
25+
echo "This script is intended to run on macOS (Darwin)."
26+
fi
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Claude Code Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
# Optional: Only run on specific file changes
7+
# paths:
8+
# - "src/**/*.ts"
9+
# - "src/**/*.tsx"
10+
# - "src/**/*.js"
11+
# - "src/**/*.jsx"
12+
13+
jobs:
14+
claude-review:
15+
# Optional: Filter by PR author
16+
# if: |
17+
# github.event.pull_request.user.login == 'external-contributor' ||
18+
# github.event.pull_request.user.login == 'new-developer' ||
19+
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20+
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
pull-requests: read
25+
issues: read
26+
id-token: write
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 1
33+
34+
- name: Run Claude Code Review
35+
id: claude-review
36+
uses: anthropics/claude-code-action@v1
37+
with:
38+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
39+
prompt: |
40+
REPO: ${{ github.repository }}
41+
PR NUMBER: ${{ github.event.pull_request.number }}
42+
43+
Please review this pull request and provide feedback on:
44+
- Code quality and best practices
45+
- Potential bugs or issues
46+
- Performance considerations
47+
- Security concerns
48+
- Test coverage
49+
50+
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
51+
52+
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
53+
54+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
55+
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options
56+
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'
57+

.github/workflows/claude.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Claude Code
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude:
15+
if: |
16+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
pull-requests: read
24+
issues: read
25+
id-token: write
26+
actions: read # Required for Claude to read CI results on PRs
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Run Claude Code
34+
id: claude
35+
uses: anthropics/claude-code-action@v1
36+
with:
37+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38+
39+
# This is an optional setting that allows Claude to read CI results on PRs
40+
additional_permissions: |
41+
actions: read
42+
43+
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
44+
# prompt: 'Update the pull request description to include a summary of changes.'
45+
46+
# Optional: Add claude_args to customize behavior and configuration
47+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
48+
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options
49+
# claude_args: '--allowed-tools Bash(gh pr:*)'
50+

.github/workflows/mkdocs.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: mkdocs
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
workflow_dispatch:
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.x
16+
- run: pip install mkdocs-material mkdocstrings[python] mkdocs-jupyter
17+
- run: mkdocs gh-deploy --force

.github/workflows/release.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Build wheels and publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
check_tag:
9+
name: Check tag
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v5
14+
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
19+
- shell: bash
20+
run: |
21+
TAG="${{ github.event.release.tag_name }}"
22+
GH_TAG_NAME="${TAG#v}"
23+
PY_VERSION=$(python - <<'PY'
24+
import pathlib, tomllib
25+
data = tomllib.loads(pathlib.Path("pyproject.toml").read_text(encoding="utf-8"))
26+
print(data.get("project").get("version"))
27+
PY
28+
)
29+
if [ "${GH_TAG_NAME}" != "${PY_VERSION}" ]; then
30+
echo "::error::Tag (${GH_TAG_NAME}) does not match pyproject.toml version (${PY_VERSION})."
31+
exit 2
32+
fi
33+
34+
build_wheels:
35+
needs: check_tag
36+
name: Build wheels
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- uses: actions/checkout@v5
41+
42+
- uses: actions/setup-python@v5
43+
with:
44+
python-version: '3.11'
45+
46+
# using pip and not uv for consistency with setuptools build backend
47+
- name: Build wheel
48+
run: |
49+
python -m pip install build
50+
python -m build --wheel --sdist --outdir wheelhouse
51+
52+
- name: Store wheels
53+
uses: actions/upload-artifact@v5
54+
with:
55+
name: wheels
56+
path: wheelhouse/*
57+
58+
test_wheels:
59+
needs: build_wheels
60+
name: Test wheels on ${{ matrix.os }} with ${{ matrix.python-version }}
61+
runs-on: ${{ matrix.os }}
62+
strategy:
63+
fail-fast: false # to not fail all combinations if just one fail
64+
matrix:
65+
os: [windows-latest, ubuntu-latest, macos-latest]
66+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
67+
68+
steps:
69+
- uses: actions/checkout@v5
70+
- uses: actions/setup-python@v5
71+
with:
72+
python-version: ${{ matrix.python-version }}
73+
74+
- name: Set execute permission for OSX install script
75+
if: runner.os == 'macOS'
76+
run: chmod +x .github/scripts/install_osx_dependencies.sh
77+
78+
- name: Install OSX packages
79+
if: runner.os == 'macOS'
80+
shell: bash
81+
run: ./.github/scripts/install_osx_dependencies.sh
82+
83+
- name: Force non-GUI Matplotlib backend (Windows)
84+
if: ${{ matrix.os == 'windows-latest' }}
85+
shell: pwsh
86+
run: echo "MPLBACKEND=Agg" >> $env:GITHUB_ENV
87+
88+
- name: Force non-GUI Matplotlib backend (macOS)
89+
if: ${{ matrix.os == 'macos-latest' }}
90+
shell: bash
91+
run: echo "MPLBACKEND=Agg" >> $GITHUB_ENV
92+
93+
- uses: actions/download-artifact@v5
94+
with:
95+
name: wheels
96+
path: wheelhouse
97+
98+
# Set wheel filename differently for Unix vs Windows
99+
- name: Get wheel filename (Unix)
100+
if: runner.os != 'Windows'
101+
run: echo "WHEELNAME=$(ls ./wheelhouse/lightgbmlss-*none-any.whl)" >> $GITHUB_ENV
102+
103+
- name: Get wheel filename (Windows)
104+
if: runner.os == 'Windows'
105+
run: echo "WHEELNAME=$(Get-ChildItem ./wheelhouse/lightgbmlss-*none-any.whl)" >> $env:GITHUB_ENV
106+
107+
- name: Install wheel and extras
108+
run: python -m pip install "${{ env.WHEELNAME }}[all_extras,test]"
109+
110+
- name: Run tests
111+
run: |
112+
python -m pytest
113+
114+
upload_wheels:
115+
name: Upload wheels to PyPI
116+
runs-on: ubuntu-latest
117+
needs: [build_wheels,test_wheels]
118+
119+
permissions:
120+
id-token: write
121+
122+
steps:
123+
- uses: actions/download-artifact@v5
124+
with:
125+
name: wheels
126+
path: wheelhouse
127+
128+
- name: Publish package to PyPI
129+
uses: pypa/gh-action-pypi-publish@release/v1
130+
with:
131+
132+
packages-dir: wheelhouse/

0 commit comments

Comments
 (0)