Files
strukto-ai--mirage/docs/python/resource/github_ci.mdx
T
wehub-resource-sync bcbd1bdb22
Integ / changes (push) Has been skipped
Pre-commit / pre-commit (push) Failing after 1s
CLI exit codes / changes (push) Has been skipped
Test (Install) / changes (push) Has been skipped
Test (Python) / changes (push) Has been skipped
Test (TypeScript) / changes (push) Has been skipped
CLI exit codes / cli-gate (push) Has been cancelled
Test (Install) / test-install-gate (push) Has been cancelled
Integ / integ-gate (push) Has been cancelled
Test (Python) / test-python-gate (push) Has been cancelled
Test (TypeScript) / test-typescript-gate (push) Has been cancelled
Test (Install) / python-minimal (3.12) (push) Has been cancelled
Test (Install) / python-minimal (3.11) (push) Has been cancelled
Test (Install) / python-extra (agno, mirage.agents.agno) (push) Has been cancelled
Test (Install) / python-extra (chroma, mirage.resource.chroma) (push) Has been cancelled
Test (Install) / python-extra (pdf, mirage.core.filetype.pdf) (push) Has been cancelled
Integ / integ (push) Has been cancelled
Integ / integ-database (push) Has been cancelled
Integ / integ-database-ts (push) Has been cancelled
Integ / integ-data (push) Has been cancelled
Integ / integ-ssh (push) Has been cancelled
Integ / integ-ssh-ts (push) Has been cancelled
Test (Python) / audit (push) Has been cancelled
Test (TypeScript) / test (push) Has been cancelled
Test (TypeScript) / python-fs-shim (push) Has been cancelled
CLI exit codes / Python CLI (push) Has been cancelled
CLI exit codes / TypeScript CLI (push) Has been cancelled
CLI exit codes / Cross-language snapshot interop (push) Has been cancelled
Test (Python) / test (push) Has been cancelled
Test (Python) / import-isolation (deepagents, openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Python) / import-isolation (deepagents, pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Integ / integ-ts (push) Has been cancelled
Integ / integ-fuse (push) Has been cancelled
Test (Install) / python-extra (databricks, mirage.resource.databricks_volume) (push) Has been cancelled
Test (Install) / python-extra (deepagents, mirage.agents.langchain) (push) Has been cancelled
Test (Install) / python-extra (email, mirage.resource.email) (push) Has been cancelled
Test (Install) / python-extra (fuse, mirage.fuse.mount) (push) Has been cancelled
Test (Install) / python-extra (hdf5, mirage.core.filetype.hdf5) (push) Has been cancelled
Test (Install) / python-extra (hf, mirage.resource.hf_buckets) (push) Has been cancelled
Test (Install) / python-extra (lancedb, mirage.resource.lancedb) (push) Has been cancelled
Test (Install) / python-extra (langfuse, mirage.resource.langfuse) (push) Has been cancelled
Test (Install) / python-extra (mongodb, mirage.resource.mongodb) (push) Has been cancelled
Test (Install) / python-extra (nextcloud, mirage.resource.nextcloud) (push) Has been cancelled
Test (Install) / python-extra (openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Install) / python-extra (openhands, mirage.agents.openhands, 3.12) (push) Has been cancelled
Test (Install) / python-extra (parquet, mirage.core.filetype.parquet) (push) Has been cancelled
Test (Install) / python-extra (postgres, mirage.resource.postgres) (push) Has been cancelled
Test (Install) / python-extra (pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Test (Install) / python-extra (qdrant, mirage.resource.qdrant) (push) Has been cancelled
Test (Install) / python-extra (redis, mirage.resource.redis) (push) Has been cancelled
Test (Install) / python-extra (s3, mirage.resource.s3) (push) Has been cancelled
Test (Install) / python-extra (ssh, mirage.resource.ssh) (push) Has been cancelled
Test (Install) / ts-minimal (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:44 +08:00

195 lines
4.7 KiB
Plaintext

---
title: GitHub CI
description: Mount GitHub Actions workflows, runs, jobs, logs, and artifacts as a read-only Mirage filesystem.
icon: circle-play
---
The GitHub CI resource mounts GitHub Actions workflows and runs as a
read-only virtual filesystem.
For token setup, see [GitHub CI Setup](/python/setup/github_ci).
## Config
```python
import os
from mirage import MountMode, Workspace
from mirage.resource.github_ci import GitHubCIConfig, GitHubCIResource
config = GitHubCIConfig(
token=os.environ["GITHUB_TOKEN"],
owner="my-org",
repo="my-repo",
)
resource = GitHubCIResource(config=config)
ws = Workspace({"/ci": resource}, mode=MountMode.READ)
```
## Filesystem Layout
```text
/ci/
workflows/
<workflow-name>_<workflow-id>.json
runs/
<workflow-name>_<run-id>/
run.json
jobs/
<job-name>_<job-id>.json
<job-name>_<job-id>.log
annotations.jsonl
artifacts/
<artifact-name>_<artifact-id>.zip
```
Example:
```text
/ci/
workflows/
CI_12345678.json
Deploy_87654321.json
runs/
CI_9876543210/
run.json
jobs/
build_11111111.json
build_11111111.log
test_22222222.json
test_22222222.log
annotations.jsonl
artifacts/
coverage-report_55555.zip
```
### Workflows
`/ci/workflows/` lists all workflows defined in the repository.
Each `.json` file contains the workflow metadata (name, path, state).
### Runs
`/ci/runs/` lists recent workflow runs within the configured time window
(default 30 days). The `created` API parameter filters server-side.
Each run directory contains:
- `run.json` - run metadata (status, conclusion, event, branch, actor, timing)
- `jobs/` - one `.json` and `.log` pair per job
- `annotations.jsonl` - check annotations (warnings, errors) across all jobs
- `artifacts/` - downloadable build artifacts
### Jobs
Each job has two files:
- `<job-name>_<job-id>.json` - job metadata with steps and timing
- `<job-name>_<job-id>.log` - full job log (plain text)
### Artifacts
Artifacts are served as `.zip` files matching the GitHub API download format.
## Cache
The GitHub CI resource uses `IndexCacheStore` with `remote_time`-based
fingerprinting. Completed runs and jobs are effectively immutable and
benefit from long cache TTL.
## Example
```python
import asyncio
import os
from dotenv import load_dotenv
from mirage import MountMode, Workspace
from mirage.resource.github_ci import GitHubCIConfig, GitHubCIResource
load_dotenv(".env.development")
async def main():
config = GitHubCIConfig(
token=os.environ["GITHUB_TOKEN"],
owner="my-org",
repo="my-repo",
)
resource = GitHubCIResource(config=config)
ws = Workspace({"/ci": resource}, mode=MountMode.READ)
# List top-level
r = await ws.execute("ls /ci/")
print(await r.stdout_str())
# List workflows
r = await ws.execute("ls /ci/workflows/")
print(await r.stdout_str())
# List recent runs
r = await ws.execute("ls /ci/runs/")
print(await r.stdout_str())
# Read run metadata
r = await ws.execute("cat /ci/runs/CI_9876543210/run.json")
print(await r.stdout_str())
# List jobs for a run
r = await ws.execute("ls /ci/runs/CI_9876543210/jobs/")
print(await r.stdout_str())
# Read job log
r = await ws.execute("cat /ci/runs/CI_9876543210/jobs/build_11111111.log")
print(await r.stdout_str())
# Read annotations
r = await ws.execute("cat /ci/runs/CI_9876543210/annotations.jsonl")
print(await r.stdout_str())
# Tree view
r = await ws.execute("tree -L 2 /ci/")
print(await r.stdout_str())
# Find all failed job logs
r = await ws.execute("find /ci/runs/ -name '*.log'")
print(await r.stdout_str())
if __name__ == "__main__":
asyncio.run(main())
```
## Shell Commands
Standard commands available on the mounted GitHub CI tree:
| Command | Notes |
| --------------- | ------------------------------ |
| `ls` | List workflows, runs, jobs |
| `cat` | Read JSON metadata or job logs |
| `head` / `tail` | First/last N lines |
| `wc` | Line/word/byte counts |
| `stat` | File metadata (type, IDs) |
| `find` | Recursive search with `-name` |
| `tree` | Directory tree view |
## Working with CI Data
```bash
# Check run status via jq
cat /ci/runs/CI_9876543210/run.json | jq '.conclusion'
# List all job names
ls /ci/runs/CI_9876543210/jobs/ | grep '.json$'
# Tail a job log for recent output
tail -n 50 /ci/runs/CI_9876543210/jobs/build_11111111.log
# Count annotations
wc -l /ci/runs/CI_9876543210/annotations.jsonl
# Find all .log files
find /ci/ -name "*.log"
```