Skip to content

Commit 64619c4

Browse files
committed
ci: use new upstream workflows
1 parent 27f866b commit 64619c4

9 files changed

+1270
-221
lines changed

.github/workflows/ci.yml

+66-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,78 @@
11
name: CI
22

33
on:
4-
pull_request:
5-
branches:
6-
- "**"
74
push:
8-
branches:
9-
- "master"
5+
branches: ["*"]
6+
paths:
7+
- grammar.js
8+
- src/**
9+
- test/**
10+
- bindings/**
11+
- binding.gyp
12+
pull_request:
13+
paths:
14+
- grammar.js
15+
- src/**
16+
- test/**
17+
- bindings/**
18+
- binding.gyp
19+
20+
concurrency:
21+
group: ${{github.workflow}}-${{github.ref}}
22+
cancel-in-progress: true
23+
1024
jobs:
1125
test:
12-
runs-on: ${{ matrix.os }}
26+
name: Test parser
27+
runs-on: ${{matrix.os}}
1328
strategy:
14-
fail-fast: true
29+
fail-fast: false
1530
matrix:
16-
os: [macos-latest, ubuntu-latest]
31+
os: [ubuntu-latest, windows-latest, macos-14]
32+
include:
33+
- examples:
34+
- { repo: 'numpy/numpy', path: 'examples/numpy' }
35+
- { repo: 'django/django', path: 'examples/django' }
36+
- { repo: 'pallets/flask', path: 'examples/flask' }
37+
- { repo: 'python/cpython', path: 'examples/python' }
1738
steps:
18-
- uses: actions/checkout@v4
19-
- uses: actions/setup-node@v4
39+
- name: Set up the repo
40+
uses: tree-sitter/[email protected]
41+
with:
42+
node-version: ${{vars.NODE_VERSION}}
43+
- name: Set up examples
44+
uses: actions/checkout@v4
45+
with:
46+
repository: ${{matrix.examples.repo}}
47+
path: ${{matrix.examples.path}}
48+
clean: false
49+
- name: Run tests
50+
uses: tree-sitter/[email protected]
2051
with:
21-
node-version: 18
22-
- run: npm install
23-
- run: npm test
24-
test_windows:
25-
runs-on: windows-latest
52+
lint: true
53+
test-library: ${{runner.os == 'Linux'}}
54+
examples: |
55+
examples/examples/**/*.py
56+
!examples/cpython/Lib/test/badsyntax_3131.py
57+
!examples/cpython/Lib/test/badsyntax_future8.py
58+
!examples/cpython/Lib/test/test_compile.py
59+
!examples/cpython/Tools/build/generate_re_casefix.py
60+
fuzz:
61+
name: Fuzz parser
62+
runs-on: ubuntu-latest
2663
steps:
27-
- uses: actions/checkout@v4
28-
- uses: actions/setup-node@v4
64+
- name: Checkout repository
65+
uses: actions/checkout@v4
2966
with:
30-
node-version: 18
31-
- run: npm install
32-
- run: npm run-script test-windows
67+
fetch-depth: 2
68+
- name: Check for scanner changes
69+
id: scanner-changes
70+
run: |-
71+
if git diff --quiet HEAD^ -- src/scanner.c; then
72+
printf 'changed=false\n' >> "$GITHUB_OUTPUT"
73+
else
74+
printf 'changed=true\n' >> "$GITHUB_OUTPUT"
75+
fi
76+
- name: Fuzz parser
77+
uses: tree-sitter/fuzz-action@v4
78+
if: steps.scanner-changes.outputs.changed == 'true'

.github/workflows/fuzz.yml

-22
This file was deleted.

.github/workflows/lint.yml

-19
This file was deleted.

.github/workflows/release.yml

+15-99
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,19 @@
1-
name: Release
1+
name: Publish package
22

33
on:
4-
workflow_run:
5-
workflows: ["CI"]
6-
branches:
7-
- master
8-
types:
9-
- completed
4+
push:
5+
tags: ["*"]
106

11-
jobs:
12-
release:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
17-
with:
18-
fetch-depth: 0
19-
20-
- name: Get previous commit SHA
21-
id: get_previous_commit
22-
run: |
23-
LATEST_TAG=$(git describe --tags --abbrev=0)
24-
if [[ -z "$LATEST_TAG" ]]; then
25-
echo "No tag found. Failing..."
26-
exit 1
27-
fi
28-
echo "latest_tag=${LATEST_TAG#v}" >> "$GITHUB_ENV" # Remove 'v' prefix from the tag
29-
30-
- name: Check if version changed and is greater than the previous
31-
id: version_check
32-
run: |
33-
# Compare the current version with the version from the previous commit
34-
PREVIOUS_NPM_VERSION=${{ env.latest_tag }}
35-
CURRENT_NPM_VERSION=$(jq -r '.version' package.json)
36-
CURRENT_CARGO_VERSION=$(awk -F '"' '/^version/ {print $2}' Cargo.toml)
37-
if [[ "$CURRENT_NPM_VERSION" != "$CURRENT_CARGO_VERSION" ]]; then # Cargo.toml and package.json versions must match
38-
echo "Mismatch: NPM version ($CURRENT_NPM_VERSION) and Cargo.toml version ($CURRENT_CARGO_VERSION)"
39-
echo "version_changed=false" >> "$GITHUB_ENV"
40-
else
41-
if [[ "$PREVIOUS_NPM_VERSION" == "$CURRENT_NPM_VERSION" ]]; then
42-
echo "version_changed=" >> "$GITHUB_ENV"
43-
else
44-
IFS='.' read -ra PREVIOUS_VERSION_PARTS <<< "$PREVIOUS_NPM_VERSION"
45-
IFS='.' read -ra CURRENT_VERSION_PARTS <<< "$CURRENT_NPM_VERSION"
46-
VERSION_CHANGED=false
47-
for i in "${!PREVIOUS_VERSION_PARTS[@]}"; do
48-
if [[ ${CURRENT_VERSION_PARTS[i]} -gt ${PREVIOUS_VERSION_PARTS[i]} ]]; then
49-
VERSION_CHANGED=true
50-
break
51-
elif [[ ${CURRENT_VERSION_PARTS[i]} -lt ${PREVIOUS_VERSION_PARTS[i]} ]]; then
52-
break
53-
fi
54-
done
55-
56-
echo "version_changed=$VERSION_CHANGED" >> "$GITHUB_ENV"
57-
echo "current_version=${CURRENT_NPM_VERSION}" >> "$GITHUB_ENV"
58-
fi
59-
fi
60-
61-
- name: Display result
62-
run: |
63-
echo "Version bump detected: ${{ env.version_changed }}"
7+
concurrency:
8+
group: ${{github.workflow}}-${{github.ref}}
9+
cancel-in-progress: true
6410

65-
- name: Fail if version is lower
66-
if: env.version_changed == 'false'
67-
run: exit 1
68-
69-
- name: Setup Node
70-
if: env.version_changed == 'true'
71-
uses: actions/setup-node@v4
72-
with:
73-
node-version: 18
74-
registry-url: "https://registry.npmjs.org"
75-
- name: Publish to NPM
76-
if: env.version_changed == 'true'
77-
env:
78-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
79-
run: npm publish
80-
81-
- name: Setup Rust
82-
if: env.version_changed == 'true'
83-
uses: actions-rs/toolchain@v1
84-
with:
85-
profile: minimal
86-
toolchain: stable
87-
override: true
88-
- name: Publish to Crates.io
89-
if: env.version_changed == 'true'
90-
uses: katyo/publish-crates@v2
91-
with:
92-
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
93-
94-
- name: Tag versions
95-
if: env.version_changed == 'true'
96-
run: |
97-
git checkout master
98-
git config user.name github-actions[bot]
99-
git config user.email github-actions[bot]@users.noreply.github.com
100-
git tag -d "v${{ env.current_version }}" || true
101-
git push origin --delete "v${{ env.current_version }}" || true
102-
git tag -a "v${{ env.current_version }}" -m "Version ${{ env.current_version }}"
103-
git push origin "v${{ env.current_version }}"
11+
jobs:
12+
npm:
13+
uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
14+
secrets:
15+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
16+
crates:
17+
uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
18+
secrets:
19+
CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_TOKEN}}

.gitignore

+35-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,36 @@
1-
Cargo.lock
2-
package-lock.json
3-
node_modules
4-
build
5-
*.log
6-
/examples/*/
1+
# Rust artifacts
2+
/Cargo.lock
73
/target/
4+
5+
# Node artifacts
6+
/build/
7+
/node_modules/
8+
9+
# Swift artifacts
10+
/.build/
11+
12+
# Python artifacts
13+
/dist/
14+
*.egg-info
15+
*.whl
16+
17+
# Zig artifacts
18+
/zig-cache/
19+
/zig-out/
20+
21+
# C artifacts
22+
*.a
23+
*.so
24+
*.so.*
25+
*.dylib
26+
*.dll
27+
*.pc
28+
29+
# Example dirs
30+
/examples/*/
31+
32+
# Grammar volatiles
33+
dsl.d.ts
34+
*.wasm
35+
*.obj
36+
*.o

0 commit comments

Comments
 (0)