Repository navigation
Move setup-baml and baml-action into the monorepo #5537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,253 @@ | ||
| # Tests the public GitHub Actions in packaging/github-actions. Also called by | ||
| # sync-github-actions-mirror.yml, so a mirror only moves after these pass. | ||
|
|
||
| name: GitHub Actions CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - "packaging/github-actions/**" | ||
| - ".github/workflows/github-actions-ci.yml" | ||
| - ".github/workflows/sync-github-actions-mirror.yml" | ||
| workflow_call: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-tests-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| setup-baml-lint-and-test: | ||
| name: setup-baml lint and test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| sparse-checkout: packaging/github-actions | ||
| filter: blob:none | ||
|
|
||
| - name: Test wrapper output parsing | ||
| working-directory: packaging/github-actions/setup-baml | ||
| run: npm test | ||
|
|
||
| - name: Lint Bash | ||
| working-directory: packaging/github-actions/setup-baml | ||
| run: shellcheck scripts/setup.sh | ||
|
|
||
| - name: Parse PowerShell | ||
| working-directory: packaging/github-actions/setup-baml | ||
| shell: pwsh | ||
| run: | | ||
| $tokens = $null | ||
| $errors = $null | ||
| [System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path scripts/setup.ps1), [ref]$tokens, [ref]$errors) | Out-Null | ||
| if ($errors.Count -gt 0) { throw ($errors | Out-String) } | ||
|
|
||
| setup-baml-cross-platform: | ||
| name: setup-baml exact version (${{ matrix.os }}) | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
| - macos-latest | ||
| - windows-latest | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| sparse-checkout: packaging/github-actions | ||
| filter: blob:none | ||
|
|
||
| - name: Write conflicting project selector | ||
| shell: pwsh | ||
| run: | | ||
| @("[toolchain]", 'channel = "canary"') | Set-Content -Path baml.toml | ||
|
|
||
| - name: Set up BAML | ||
| id: baml | ||
| uses: ./packaging/github-actions/setup-baml | ||
| with: | ||
| toolchain: 0.16.0 | ||
|
|
||
| - name: Verify setup outputs and PATH | ||
| shell: pwsh | ||
| env: | ||
| RESOLVED_VERSION: ${{ steps.baml.outputs.version }} | ||
| WRAPPER_PATH: ${{ steps.baml.outputs.path }} | ||
| TOOLCHAIN_PATH: ${{ steps.baml.outputs.toolchain-path }} | ||
| run: | | ||
| baml --version | ||
| if ($env:RESOLVED_VERSION -ne "0.16.0") { throw "unexpected version: $($env:RESOLVED_VERSION)" } | ||
| if (-not (Test-Path -LiteralPath $env:WRAPPER_PATH -PathType Leaf)) { throw "wrapper output does not exist" } | ||
| if (-not (Test-Path -LiteralPath $env:TOOLCHAIN_PATH -PathType Leaf)) { throw "toolchain output does not exist" } | ||
|
|
||
| setup-baml-project-selector: | ||
| name: setup-baml resolves baml.toml | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| sparse-checkout: packaging/github-actions | ||
| filter: blob:none | ||
|
|
||
| - name: Write project selector | ||
| run: printf '[toolchain]\nchannel = "nightly"\n' > baml.toml | ||
|
|
||
| - name: Set up BAML from project | ||
| id: baml | ||
| uses: ./packaging/github-actions/setup-baml | ||
|
|
||
| - name: Verify nightly resolution | ||
| env: | ||
| RESOLVED_VERSION: ${{ steps.baml.outputs.version }} | ||
| run: | | ||
| test -n "$RESOLVED_VERSION" | ||
| test "$(baml toolchain list | node packaging/github-actions/setup-baml/lib/wrapper-output.mjs selector)" = "nightly" | ||
| baml --version | ||
|
|
||
| setup-baml-canary-selector: | ||
| name: setup-baml installs canary | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| sparse-checkout: packaging/github-actions | ||
| filter: blob:none | ||
|
|
||
| - name: Write conflicting project selector | ||
| run: printf '[toolchain]\nchannel = "nightly"\n' > baml.toml | ||
|
|
||
| - name: Set up BAML canary | ||
| id: baml | ||
| uses: ./packaging/github-actions/setup-baml | ||
| with: | ||
| toolchain: canary | ||
|
|
||
| - name: Verify canary resolution | ||
| env: | ||
| RESOLVED_VERSION: ${{ steps.baml.outputs.version }} | ||
| run: | | ||
| test -n "$RESOLVED_VERSION" | ||
| test "$(baml toolchain list | node packaging/github-actions/setup-baml/lib/wrapper-output.mjs selector)" = "canary" | ||
| baml --version | ||
|
|
||
| baml-action-lint-and-test: | ||
| name: baml-action lint and test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| sparse-checkout: | | ||
| .github/workflows | ||
| packaging/github-actions | ||
| filter: blob:none | ||
|
|
||
| - name: Set up BAML | ||
| uses: ./packaging/github-actions/setup-baml | ||
| with: | ||
| toolchain: nightly | ||
|
|
||
| # Unset BAML_VERSION so the renderer's own baml.toml picks its toolchain, | ||
| # as it does when the action runs it. | ||
| - name: Test comment rendering | ||
| run: env -u BAML_VERSION baml --agent-skill-check off --color never --no-progress --project packaging/github-actions/baml-action/codequality test | ||
|
|
||
| - name: Lint Bash | ||
| working-directory: packaging/github-actions/baml-action | ||
| run: shellcheck scripts/*.sh | ||
|
|
||
| - name: Lint workflows and action metadata | ||
| uses: docker://rhysd/actionlint:1.7.12 | ||
| with: | ||
| args: -color .github/workflows/github-actions-ci.yml .github/workflows/sync-github-actions-mirror.yml | ||
|
|
||
| baml-action-passing: | ||
| name: baml-action passing project (${{ matrix.os }}) | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
| - macos-latest | ||
| - windows-latest | ||
| runs-on: ${{ matrix.os }} | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| sparse-checkout: packaging/github-actions | ||
| filter: blob:none | ||
|
|
||
| - name: Run BAML | ||
| id: baml | ||
| uses: ./packaging/github-actions/baml-action | ||
| with: | ||
| toolchain: nightly | ||
| project: packaging/github-actions/baml-action/test/fixtures/passing | ||
| # Only one matrix leg posts, so the comment isn't rewritten three times. | ||
| comment: ${{ matrix.os == 'ubuntu-latest' }} | ||
|
|
||
| - name: Verify version output | ||
| shell: bash | ||
| env: | ||
| VERSION: ${{ steps.baml.outputs.version }} | ||
| run: test -n "$VERSION" | ||
|
|
||
| baml-action-failing: | ||
| name: baml-action failing projects report each failure | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| sparse-checkout: packaging/github-actions | ||
| filter: blob:none | ||
|
|
||
| - name: Failing tests | ||
| id: failing | ||
| continue-on-error: true | ||
| uses: ./packaging/github-actions/baml-action | ||
| with: | ||
| toolchain: nightly | ||
| project: packaging/github-actions/baml-action/test/fixtures/failing | ||
| comment: false | ||
|
|
||
| - name: Type error | ||
| id: invalid | ||
| continue-on-error: true | ||
| uses: ./packaging/github-actions/baml-action | ||
| with: | ||
| toolchain: nightly | ||
| project: packaging/github-actions/baml-action/test/fixtures/invalid | ||
| test: false | ||
| fmt: false | ||
| codequality: false | ||
| comment: false | ||
|
|
||
| - name: No tests | ||
| id: empty | ||
| uses: ./packaging/github-actions/baml-action | ||
| with: | ||
| toolchain: nightly | ||
| project: packaging/github-actions/baml-action/test/fixtures/empty | ||
| comment: false | ||
|
|
||
| - name: Verify outcomes | ||
| env: | ||
| FAILING: ${{ steps.failing.outcome }} | ||
| INVALID: ${{ steps.invalid.outcome }} | ||
| run: | | ||
| test "$FAILING" = failure | ||
| test "$INVALID" = failure |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # Sync the public GitHub Actions to their read-only mirror repos. | ||
| # | ||
| # Actions are edited in packaging/github-actions and consumed from the mirrors, | ||
| # because a runner downloads the entire repository of every action it uses and | ||
| # GitHub Marketplace only lists an action at the root of its own repository. | ||
| # The mirrors must never be edited by hand: | ||
| # | ||
| # packaging/github-actions/setup-baml -> BoundaryML/setup-baml | ||
| # packaging/github-actions/baml-action -> BoundaryML/baml-action | ||
| # | ||
| # Each mirror also gets a copy of this repository's root LICENSE. | ||
| # | ||
| # Every content change moves the mirror's major tag, so a merge to canary | ||
| # reaches `@v1` consumers as soon as the tests pass. A breaking change needs a | ||
| # new `major` below. baml-action pins setup-baml by commit in its action.yml, so | ||
| # a setup-baml change reaches baml-action only when that pin is bumped. | ||
| # | ||
| # Auth: uses the shared GitHub token synced from Infisical's | ||
| # gh-baml-language-release environment. The token needs Contents write access | ||
| # to both mirrors, and Workflows write access for any change under a mirror's | ||
| # .github/workflows. | ||
|
|
||
| name: Sync GitHub Actions mirror | ||
|
|
||
| on: | ||
| push: | ||
| branches: [canary] | ||
| paths: | ||
| - "LICENSE" | ||
| - "packaging/github-actions/**" | ||
| - ".github/workflows/github-actions-ci.yml" | ||
| - ".github/workflows/sync-github-actions-mirror.yml" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: sync-github-actions-mirror | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test actions | ||
| uses: ./.github/workflows/github-actions-ci.yml | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| sync: | ||
| name: Sync to BoundaryML/${{ matrix.action }} | ||
| needs: test | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| action: [setup-baml, baml-action] | ||
| major: [v1] | ||
| runs-on: ubuntu-latest | ||
| environment: infisical-github-baml-language-release | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| persist-credentials: false | ||
| sparse-checkout: packaging/github-actions | ||
| filter: blob:none | ||
|
|
||
| - name: Clone mirror | ||
| env: | ||
| GH_TOKEN: ${{ secrets.SAM_GITHUB_BOUNDARYML_READWRITE2 }} | ||
| ACTION: ${{ matrix.action }} | ||
| run: | | ||
| set -euo pipefail | ||
| test -n "$GH_TOKEN" | ||
| gh auth setup-git | ||
| git clone --depth 50 "https://github.com/BoundaryML/${ACTION}.git" /tmp/mirror-repo | ||
|
|
||
| - name: Diff against mirror | ||
| id: diff | ||
| env: | ||
| ACTION: ${{ matrix.action }} | ||
| run: | | ||
| set -euo pipefail | ||
| rsync -a --delete --exclude .git "packaging/github-actions/${ACTION}/" /tmp/mirror-repo/ | ||
| cp LICENSE /tmp/mirror-repo/LICENSE | ||
| if [ -n "$(git -C /tmp/mirror-repo status --porcelain)" ]; then | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| git -C /tmp/mirror-repo status --porcelain | ||
| else | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| echo "Mirror already up to date." | ||
| fi | ||
|
|
||
| - name: Push and move major tag | ||
| if: steps.diff.outputs.changed == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.SAM_GITHUB_BOUNDARYML_READWRITE2 }} | ||
| MAJOR: ${{ matrix.major }} | ||
| SOURCE_SHA: ${{ github.sha }} | ||
| run: | | ||
| set -euo pipefail | ||
| cd /tmp/mirror-repo | ||
| git add -A | ||
| git -c user.name="github-actions[bot]" \ | ||
| -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \ | ||
| commit -m "Sync from BoundaryML/baml@${SOURCE_SHA}" | ||
| git tag --force "${MAJOR}" | ||
| # --atomic: main must never advance without its tag, or the next run | ||
| # would see no content diff and leave the tag behind. | ||
| git push --atomic origin main "+refs/tags/${MAJOR}" | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| node_modules/ | ||
| .DS_Store | ||
| *.log |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.