Skip to content

Commit

Permalink
Test PR Workflow with sparse checkout (typst#1229)
Browse files Browse the repository at this point in the history
  • Loading branch information
quachpas authored Nov 6, 2024
1 parent 56b8f94 commit a3ad395
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Download the whole history for the package timestamps
fetch-depth: 0
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ name: Test
on:
push:
branches: ['*', '!main']
pull_request: {}

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/test_pr.yml
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

0 comments on commit a3ad395

Please sign in to comment.