Skip to content

Commit e8b2fdc

Browse files
Merge pull request #11 from andrewkaufman/github-ci
CI : Add GitHub Workflows
2 parents ba6b153 + 5cf9061 commit e8b2fdc

File tree

4 files changed

+260
-0
lines changed

4 files changed

+260
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 'Bootstrap'
2+
description: 'Bootstrap the repository'
3+
inputs:
4+
python-version:
5+
description: 'Python version to use'
6+
required: false
7+
default: '3.11'
8+
enable-uv-cache:
9+
description: 'Enable uv cache'
10+
required: false
11+
default: 'true'
12+
cache-dependency-glob:
13+
description: 'Glob pattern for cache dependencies'
14+
required: false
15+
default: 'uv.lock'
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ inputs.python-version }}
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
27+
with:
28+
enable-cache: ${{ inputs.enable-uv-cache }}
29+
cache-dependency-glob: ${{ inputs.cache-dependency-glob }}

.github/codecov.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage:
2+
status:
3+
project: off
4+
patch: off
5+
6+
comment:
7+
layout: "diff, flags, files"
8+
9+
fixes:
10+
- "/var/snap/amazon-ssm-agent/[0-9]+/::"

.github/workflows/benchmark.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Benchmark
2+
3+
on:
4+
pull_request:
5+
types: [labeled]
6+
workflow_dispatch: # Manual trigger from Actions tab
7+
8+
permissions:
9+
contents: read
10+
pull-requests: write # Required to comment on PRs
11+
12+
jobs:
13+
benchmark:
14+
# Run if: labeled with 'benchmark' OR manual trigger
15+
if: |
16+
(github.event_name == 'pull_request' && contains(github.event.label.name, 'benchmark')) ||
17+
github.event_name == 'workflow_dispatch'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Bootstrap
24+
uses: ./.github/actions/bootstrap
25+
26+
- name: Run benchmarks
27+
run: uv run --group dev poe benchmark
28+
29+
- name: Upload benchmark results
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: mujoco-usd-converter-benchmarks-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('{0}', github.ref_name) }}
33+
path: benchmarks/*.*
34+
35+
- name: Comment PR with results
36+
if: github.event_name == 'pull_request'
37+
uses: actions/github-script@v7
38+
with:
39+
script: |
40+
// Wait a bit for artifacts to be fully uploaded
41+
await new Promise(resolve => setTimeout(resolve, 5000));
42+
43+
// Get artifacts from this workflow run
44+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
run_id: context.runId
48+
});
49+
50+
// Find the benchmark-results artifact (with PR number)
51+
const artifactName = `benchmark-results-pr-${context.issue.number}`;
52+
const benchmarkArtifact = artifacts.data.artifacts.find(a => a.name === artifactName);
53+
54+
let comment = `## Benchmark Results\n\n`;
55+
56+
if (benchmarkArtifact) {
57+
const artifactUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/artifacts/${benchmarkArtifact.id}`;
58+
comment += `[Download benchmark results](${artifactUrl})\n\n`;
59+
} else {
60+
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
61+
comment += `[View workflow run](${runUrl})\n\n`;
62+
}
63+
64+
github.rest.issues.createComment({
65+
issue_number: context.issue.number,
66+
owner: context.repo.owner,
67+
repo: context.repo.repo,
68+
body: comment
69+
});

.github/workflows/ci.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags: [ '*' ]
7+
pull_request:
8+
branches: [ main ]
9+
workflow_dispatch: # Manual trigger from Actions tab
10+
11+
permissions:
12+
contents: read
13+
pull-requests: write # Required to comment on PRs
14+
15+
jobs:
16+
check-code-format:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Bootstrap
23+
uses: ./.github/actions/bootstrap
24+
25+
- name: Check uv lock file
26+
run: uv lock --check
27+
28+
- name: Run linting
29+
run: uv run --group dev poe lint
30+
31+
build:
32+
strategy:
33+
matrix:
34+
os: [ubuntu-latest, windows-latest]
35+
runs-on: ${{ matrix.os }}
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
40+
- name: Bootstrap
41+
uses: ./.github/actions/bootstrap
42+
43+
- name: Update README
44+
run: uv run --group dev poe update-readme
45+
46+
- name: Build package
47+
run: uv build
48+
49+
- name: Restore README
50+
run: git restore README.md
51+
52+
- name: Upload artifacts
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: mujoco-usd-converter-dist-${{ matrix.os }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('{0}', github.ref_name) }}
56+
path: dist/
57+
58+
test:
59+
needs: build
60+
strategy:
61+
matrix:
62+
os: [ubuntu-latest, windows-latest]
63+
runs-on: ${{ matrix.os }}
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v4
67+
68+
- name: Bootstrap
69+
uses: ./.github/actions/bootstrap
70+
71+
- name: Download artifacts
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: mujoco-usd-converter-dist-${{ matrix.os }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('{0}', github.ref_name) }}
75+
path: dist/
76+
77+
- name: Run tests
78+
run: uv run --group dev poe test-ci
79+
80+
- name: Upload report artifacts
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: mujoco-usd-converter-coverage-${{ matrix.os }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('{0}', github.ref_name) }}
84+
include-hidden-files: true
85+
path: |
86+
${{ github.workspace }}/.coverage.xml
87+
${{ github.workspace }}/.results.xml
88+
89+
- name: Upload test results to Codecov
90+
if: ${{ !cancelled() }}
91+
uses: codecov/test-results-action@v1
92+
with:
93+
files: ${{ github.workspace }}/.results.xml
94+
token: ${{ secrets.CODECOV_TOKEN }}
95+
96+
- name: Upload coverage reports to Codecov
97+
uses: codecov/codecov-action@v4
98+
with:
99+
files: ${{ github.workspace }}/.coverage.xml
100+
flags: unittests
101+
token: ${{ secrets.CODECOV_TOKEN }}
102+
103+
test-package:
104+
needs: build
105+
strategy:
106+
matrix:
107+
os: [ubuntu-latest, windows-latest]
108+
runs-on: ${{ matrix.os }}
109+
steps:
110+
- name: Checkout repository
111+
uses: actions/checkout@v4
112+
113+
- name: Bootstrap
114+
uses: ./.github/actions/bootstrap
115+
with:
116+
enable-uv-cache: 'false'
117+
118+
- name: Download artifacts
119+
uses: actions/download-artifact@v4
120+
with:
121+
name: mujoco-usd-converter-dist-${{ matrix.os }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('{0}', github.ref_name) }}
122+
path: dist/
123+
124+
- name: Test wheel installation (Linux)
125+
if: runner.os == 'Linux'
126+
run: |
127+
# Create a fresh virtual environment to test the wheel
128+
uv venv /tmp/wheel_test_env
129+
source /tmp/wheel_test_env/bin/activate
130+
131+
# Install the wheel directly using uv
132+
uv pip install --index-strategy unsafe-best-match dist/*.whl
133+
134+
# Test conversion
135+
mkdir -p /tmp/test_outputs
136+
mujoco_usd_converter tests/data/geoms.xml /tmp/test_outputs/geoms_output
137+
138+
- name: Test wheel installation (Windows)
139+
if: runner.os == 'Windows'
140+
shell: powershell
141+
run: |
142+
# Create a fresh virtual environment to test the wheel
143+
uv venv wheel_test_env
144+
wheel_test_env\Scripts\activate.ps1
145+
146+
# Find and install the wheel file
147+
$wheelFile = Get-ChildItem -Path "dist" -Filter "*.whl" | Select-Object -First 1
148+
uv pip install --index-strategy unsafe-best-match $wheelFile.FullName
149+
150+
# Test conversion
151+
New-Item -ItemType Directory -Force -Path test_outputs
152+
mujoco_usd_converter tests/data/geoms.xml test_outputs\geoms_output

0 commit comments

Comments
 (0)