forked from typst/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test PR Workflow with sparse checkout (typst#1229)
- Loading branch information
Showing
3 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,51 @@ | ||
name: Test PR | ||
on: | ||
pull_request: {} | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Extract package names and versions from changed files | ||
id: extract_package | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { data: files } = await github.rest.pulls.listFiles({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: context.payload.pull_request.number, | ||
}); | ||
const packages = new Set(); | ||
files.forEach(file => { | ||
const match = file.filename.match(/^packages\/preview\/([^\/]+)\/([^\/]+)\//); | ||
if (match) { | ||
packages.add(`${match[1]}/${match[2]}`); | ||
} | ||
}); | ||
let sparseCheckoutPaths; | ||
if (packages.size === 0) { | ||
sparseCheckoutPaths = "packages/"; | ||
} else { | ||
sparseCheckoutPaths = Array.from(packages).map(pkg => `packages/preview/${pkg}/`).join('\n'); | ||
} | ||
core.setOutput('sparse_checkout_paths', sparseCheckoutPaths); | ||
- uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: | | ||
${{ steps.extract_package.outputs.sparse_checkout_paths }} | ||
bundler/ | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: Swatinem/rust-cache@v2 | ||
with: | ||
workspaces: bundler | ||
|
||
- name: Build bundler | ||
run: cargo build --release --manifest-path bundler/Cargo.toml | ||
|
||
- name: Test packaging | ||
run: bundler/target/release/bundler |