Skip to content

Commit

Permalink
ci: use upstream actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime authored and amaanq committed Apr 10, 2024
1 parent 6909efa commit 2c97326
Show file tree
Hide file tree
Showing 12 changed files with 1,331 additions and 198 deletions.
136 changes: 107 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,138 @@ name: CI

on:
push:
branches: ["*"]
branches: [master]
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp
pull_request:
branches: ["*"]
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp

concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true

jobs:
grammar:
name: Test grammar
test:
name: Test parser
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up NodeJS
uses: actions/setup-node@v4
- name: Set up tree-sitter
uses: tree-sitter/setup-action/cli@v1
- name: Clone Svelte repo
uses: actions/checkout@v4
with:
node-version: 20
- name: Install dependencies
run: npm install
- name: Generate parser
if: inputs.generate == true
continue-on-error: true
run: |-
node_modules/.bin/tree-sitter generate
git diff --exit-code HEAD -- src/parser.c
- name: Run tests (Windows)
if: matrix.os == 'windows-latest'
run: npm run test-windows

path: examples/svelte
repository: sveltejs/svelte
sparse-checkout: |-
packages/svelte/tests/
documentation/examples/
sites/svelte.dev/src/
- name: Run tests
if: matrix.os != 'windows-latest'
run: npm test
uses: tree-sitter/parser-test-action@v2
with:
test-rust: ${{runner.os == 'Linux'}}
- name: Parse examples
uses: tree-sitter/parse-action@v4
with:
files: |-
examples/svelte/**/*.svelte
!examples/svelte/packages/svelte/tests/parser-legacy/samples/implicitly-closed-li-block/input.svelte
!examples/svelte/packages/svelte/tests/parser-legacy/samples/no-error-if-before-closing/input.svelte
!examples/svelte/packages/svelte/tests/parser-legacy/samples/textarea-end-tag/input.svelte
!examples/svelte/packages/svelte/tests/preprocess/samples/script-self-closing/input.svelte
!examples/svelte/packages/svelte/tests/preprocess/samples/style-self-closing/input.svelte
!examples/svelte/packages/svelte/tests/compiler-errors/samples/runes-invalid-each-binding/main.svelte
!examples/svelte/packages/svelte/tests/runtime-legacy/samples/await-catch-no-expression/main.svelte
!examples/svelte/packages/svelte/tests/runtime-legacy/samples/binding-input-checkbox-with-event-in-each/main.svelte
!examples/svelte/packages/svelte/tests/runtime-legacy/samples/each-block-deconflict-name-context/main.svelte
!examples/svelte/packages/svelte/tests/runtime-legacy/samples/each-block-scope-shadow-self/main.svelte
!examples/svelte/packages/svelte/tests/runtime-legacy/samples/escape-template-literals/main.svelte
!examples/svelte/packages/svelte/tests/runtime-legacy/samples/event-handler-removal/main.svelte
!examples/svelte/packages/svelte/tests/runtime-legacy/samples/store-each-binding/main.svelte
!examples/svelte/packages/svelte/tests/runtime-legacy/samples/store-each-binding-deep/main.svelte
!examples/svelte/packages/svelte/tests/runtime-legacy/samples/store-each-binding-destructuring/main.svelte
!examples/svelte/packages/svelte/tests/runtime-legacy/samples/unchanged-expression-escape/main.svelte
invalid-files: |-
examples/svelte/packages/svelte/tests/compiler-errors/samples/attribute-empty/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/catch-before-closing/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/catch-without-await/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/comment-unclosed/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/else-before-closing/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/else-before-closing-2/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/else-before-closing-3/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/else-if-before-closing/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/else-if-before-closing-2/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/else-if-without-if/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/empty-attribute-shorthand/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/empty-classname-binding/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/empty-directive-name/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/illegal-expression/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/raw-mustaches-whitespace/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/script-unclosed/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/script-unclosed-eof/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/style-unclosed/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/style-unclosed-eof/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/svelte-selfdestructive/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/then-before-closing/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/then-without-await/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unclosed-attribute-self-close-tag/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unexpected-end-of-input/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unexpected-end-of-input-b/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unexpected-end-of-input-c/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unexpected-end-of-input-d/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unmatched-closing-tag/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unmatched-closing-tag-autoclose/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unmatched-closing-tag-autoclose-2/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/void-closing/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/window-children/main.svelte
examples/svelte/packages/svelte/tests/validator/samples/attribute-expected-equals/input.svelte
examples/svelte/packages/svelte/tests/validator/samples/attribute-invalid-name/input.svelte
rust-lib:
name: Test Rust library
fuzz:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Run tests
run: cargo test
fetch-depth: 2
- name: Check for scanner changes
id: scanner-changes
run: |-
if git diff --quiet HEAD^ -- src/scanner.c; then
printf 'changed=false\n' >> "$GITHUB_OUTPUT"
else
printf 'changed=true\n' >> "$GITHUB_OUTPUT"
fi
- name: Fuzz parser
uses: tree-sitter/fuzz-action@v4
if: steps.scanner-changes.outputs.changed == 'true'

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version: ${{vars.NODE_VERSION}}
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run ESLint
run: npm run lint
21 changes: 18 additions & 3 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@ name: Update dependencies

on:
schedule:
- cron: '0 0 * * 0'
- cron: "0 0 * * 0" # every week
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
test:
uses: tree-sitter-grammars/.github/.github/workflows/dependencies.yml@main
update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up NodeJS
uses: actions/setup-node@v4
with:
cache: npm
node-version: ${{vars.NODE_VERSION}}
- name: Update dependencies
uses: tree-sitter/[email protected]
17 changes: 0 additions & 17 deletions .github/workflows/fuzz.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/lint.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

name: Publish package

on:
push:
tags: ["*"]

jobs:
npm:
uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
with:
package-name: "@tree-sitter-grammars/tree-sitter-yaml"
secrets:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
crates:
uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
with:
package-name: tree-sitter-svelte-ng
secrets:
CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_TOKEN}}
pypi:
uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
secrets:
PYPI_API_TOKEN: ${{secrets.PYPI_TOKEN}}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Cargo.lock
node_modules
build
package-lock.json
/target/
.build/
.build/
1 change: 1 addition & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
svelte/
1 change: 0 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* @file Svelte grammar for tree-sitter
* @author Amaan Qureshi <[email protected]>
* @license MIT
* @see {@link https://svelte.dev/|Official website}
*/

// eslint-disable-next-line spaced-comment
Expand Down
Loading

0 comments on commit 2c97326

Please sign in to comment.