Build context artifacts #590
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build context artifacts | |
| on: | |
| schedule: | |
| # Every 6 hours — keeps artifacts fresh without hammering the API | |
| - cron: '0 */6 * * *' | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'dataciviclab.config.yml' | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'pyproject.toml' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'pyproject.toml' | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Python setup | |
| uses: dataciviclab/.github/actions/python-setup@main | |
| with: | |
| extra-packages: -e ".[dev]" | |
| - name: Lint | |
| run: ruff check src/ tests/ | |
| - name: Type check | |
| run: mypy src/ tests/ | |
| - name: Test | |
| run: pytest --cov=src/agent_context_builder --cov-report=xml --cov-fail-under=70 | |
| - name: Upload coverage | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| fail_ci_if_error: false | |
| build: | |
| needs: test | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Python setup | |
| uses: dataciviclab/.github/actions/python-setup@main | |
| with: | |
| extra-packages: -e . | |
| - name: Build context artifacts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| agent-context build \ | |
| --config dataciviclab.config.yml \ | |
| --out generated/ \ | |
| --github-token "$GITHUB_TOKEN" | |
| - name: Publish to context branch | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Publish generated/ to the context branch via a regular (non-force) push. | |
| # Agents and the lab-workspace MCP can read from: | |
| # https://raw.githubusercontent.com/dataciviclab/agent-context-builder/context/session_bootstrap.md | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Check out context branch if it exists, otherwise create it | |
| git fetch origin context 2>/dev/null && git checkout context || git checkout --orphan context | |
| # Replace content with freshly generated artifacts | |
| git rm -rf . --quiet 2>/dev/null || true | |
| cp -r generated/. . | |
| git add session_bootstrap.md workspace_triage.json topic_index.json | |
| git commit -m "context: $(date -u +%Y-%m-%dT%H:%M:%SZ) [skip ci]" | |
| git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" context |