Skip to content
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

Configure CI #41

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches: [main]
pull_request:

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

jobs:
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 tree-sitter
uses: tree-sitter/setup-action/cli@v1
- name: Run tests
uses: tree-sitter/parser-test-action@v2
with:
test-rust: ${{runner.os == 'Linux'}}
- name: Parse examples
id: examples
continue-on-error: true
uses: tree-sitter/parse-action@v4
with:
files: examples/*
- uses: actions/upload-artifact@v4
if: steps.examples.outputs.failures != ''
with:
name: failures-${{matrix.os}}
path: ${{steps.examples.outputs.failures}}

6 changes: 3 additions & 3 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "tree_sitter/parser.h"

#define MAX_HEREDOCS 10
#define DEL_SPACE 512

typedef struct {
bool in_heredoc;
Expand Down Expand Up @@ -147,8 +148,7 @@ static bool scan_marker(scanner_state *state, TSLexer *lexer) {
// usually only need a few bytes. We're also limited to less than 1024 bytes
// by tree-sitter since our state has to fit in
// TREE_SITTER_SERIALIZATION_BUFFER_SIZE.
const unsigned int del_space = 512;
char delimiter[del_space];
char delimiter[DEL_SPACE];

// We start recording the actual string at position 1 since we store whether
// it's a stripping heredoc in the first position (with either a dash or a
Expand All @@ -174,7 +174,7 @@ static bool scan_marker(scanner_state *state, TSLexer *lexer) {
// advancing the lexer to ensure that we at least parse the marker
// correctly. Reserve two bytes: one for the strip indicator and
// one for the terminating null byte.
if (del_idx >= del_space - 2) {
if (del_idx >= DEL_SPACE - 2) {
del_idx = 0;
}
}
Expand Down