diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4c39a33 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "ci" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 61a0e90..0000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,9 +0,0 @@ - - -Checklist: -- [ ] All tests pass in CI. -- [ ] There are sufficient tests for the new fix/feature. -- [ ] Grammar rules have not been renamed unless absolutely necessary. -- [ ] The conflicts section hasn't grown too much. -- [ ] The parser size hasn't grown too much (check the value of STATE_COUNT in src/parser.c). - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7062cf..691261a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,32 +2,58 @@ name: CI on: push: - branches: - - master + 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: test: - runs-on: ${{ matrix.os }} + name: Test parser + runs-on: ${{matrix.os}} strategy: - fail-fast: true + fail-fast: false matrix: - os: [macos-latest, ubuntu-latest] + os: [ubuntu-latest, windows-latest, macos-14] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up tree-sitter + uses: tree-sitter/setup-action/cli@v1 + - name: Set up examples + run: |- + git clone https://github.com/elastic/elasticsearch examples/elasticsearch --single-branch --depth=1 --filter=blob:none + git clone https://github.com/google/guava examples/guava --single-branch --depth=1 --filter=blob:none + git clone https://github.com/ReactiveX/RxJava examples/RxJava --single-branch --depth=1 --filter=blob:none + git clone https://github.com/apache/flink examples/flink --single-branch --depth=1 --filter=blob:none + git clone https://github.com/apache/logging-log4j2 examples/log4j2 --single-branch --depth=1 --filter=blob:none + git clone https://github.com/apache/cassandra examples/cassandra --single-branch --depth=1 --filter=blob:none + - name: Run tests + uses: tree-sitter/parser-test-action@v2 with: - node-version: 18 - - run: npm install - - run: npm test - test_windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + test-rust: ${{runner.os == 'Linux'}} + - name: Parse examples + id: examples + continue-on-error: true + uses: tree-sitter/parse-action@v4 + with: + files: examples/**/*.java + - uses: actions/upload-artifact@v4 + if: steps.examples.outputs.failures != '' with: - node-version: 18 - - run: npm install - - run: npm run-script test-windows + name: failures-${{matrix.os}} + path: ${{steps.examples.outputs.failures}} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..96f1a4d --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,26 @@ +name: Lint + +on: + push: + branches: [master] + paths: + - grammar.js + pull_request: + paths: + - grammar.js + +jobs: + 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 modules + run: npm ci --legacy-peer-deps + - name: Run ESLint + run: npm run lint diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 54c12f9..cb7e16b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,74 +1,23 @@ -name: Publish +name: Publish packages on: push: - tags: - - v* + tags: ["*"] -env: - CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: 0 +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true jobs: - publish-crate: - - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - - - name: Verify crate - run: cargo publish --dry-run - - - name: Publish crate - run: cargo publish - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - publish-npm: - - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install Node - uses: actions/setup-node@v3 - with: - node-version: 18 - registry-url: "https://registry.npmjs.org" - - - name: Verify package - run: npm publish --dry-run - - - name: Publish package - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npm publish - - create-release: - - runs-on: ubuntu-latest - - permissions: - contents: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Create GitHub release - uses: ncipollo/release-action@v1 - with: - body: | - Find tree-sitter-java ${{ github.ref_name }} on [crates.io](https://crates.io/crates/tree-sitter-java) or [NPM](https://www.npmjs.com/package/tree-sitter-java). - token: ${{ secrets.GITHUB_TOKEN }} + npm: + uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main + secrets: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + crates: + uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main + secrets: + CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}} + pypi: + uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main + secrets: + PYPI_API_TOKEN: ${{secrets.PYPI_API_TOKEN}}