Skip to content

Commit d9b3a58

Browse files
committed
ci: update workflows
1 parent 3d0c5b7 commit d9b3a58

File tree

6 files changed

+80
-145
lines changed

6 files changed

+80
-145
lines changed

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
commit-message:
8+
prefix: "ci"

.github/pull_request_template.md

-9
This file was deleted.

.github/workflows/ci.yml

+33-23
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,44 @@
11
name: CI
2+
23
on:
3-
workflow_dispatch:
44
push:
5-
branches:
6-
- master
5+
branches: ["*"]
6+
paths:
7+
- grammar.js
8+
- src/**
9+
- test/**
10+
- bindings/**
11+
- binding.gyp
712
pull_request:
8-
branches:
9-
- "**"
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
1023

1124
jobs:
1225
test:
13-
runs-on: ${{ matrix.os }}
26+
name: Test parser
27+
runs-on: ${{matrix.os}}
1428
strategy:
15-
fail-fast: true
29+
fail-fast: false
1630
matrix:
17-
os: [macos-latest, ubuntu-latest]
18-
steps:
19-
- uses: actions/checkout@v3
20-
- uses: actions/setup-node@v3
21-
with:
22-
node-version: 18
23-
- run: npm install
24-
- run: npm test
25-
26-
test_windows:
27-
runs-on: windows-latest
31+
os: [ubuntu-latest, windows-latest, macos-14]
2832
steps:
29-
- uses: actions/checkout@v3
30-
- uses: actions/setup-node@v3
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
- name: Set up tree-sitter
36+
uses: tree-sitter/setup-action/cli@v1
37+
- name: Set up examples
38+
run: |-
39+
git config --global core.longpaths true
40+
git clone https://github.com/npm/cli examples/cli --single-branch --depth=1 --filter=blob:none
41+
- name: Run tests
42+
uses: tree-sitter/parser-test-action@v2
3143
with:
32-
node-version: 18
33-
- run: npm install
34-
- run: npm run-script test-windows
44+
test-rust: ${{runner.os == 'Linux'}}

.github/workflows/fuzz.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@ name: Fuzz Parser
22

33
on:
44
push:
5+
branches: [master]
56
paths:
67
- src/scanner.c
78
pull_request:
89
paths:
910
- src/scanner.c
10-
workflow_dispatch:
1111

1212
jobs:
13-
test:
14-
name: Parser fuzzing
13+
fuzz:
1514
runs-on: ubuntu-latest
1615
steps:
17-
- uses: actions/checkout@v3
18-
- uses: vigoux/tree-sitter-fuzz-action@v1
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
- name: Run fuzzer
19+
uses: tree-sitter/fuzz-action@v4
1920
with:
20-
language: javascript
21-
external-scanner: src/scanner.c
22-
time: 60
21+
tree-sitter-version: v0.22.2

.github/workflows/lint.yml

+13-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@ name: Lint
22

33
on:
44
push:
5-
branches:
6-
- master
5+
branches: [master]
6+
paths:
7+
- grammar.js
78
pull_request:
8-
branches:
9-
- "**"
9+
paths:
10+
- grammar.js
1011

1112
jobs:
1213
lint:
1314
runs-on: ubuntu-latest
1415
steps:
15-
- uses: actions/checkout@v3
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
cache: npm
22+
node-version: ${{vars.NODE_VERSION}}
1623
- name: Install modules
17-
run: npm install
24+
run: npm ci --legacy-peer-deps
1825
- name: Run ESLint
1926
run: npm run lint

.github/workflows/publish.yml

+19-99
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,23 @@
1-
name: Release
1+
name: Publish packages
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@v3
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@v3
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_REGISTRY_TOKEN}}
20+
pypi:
21+
uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
22+
secrets:
23+
PYPI_API_TOKEN: ${{secrets.PYPI_API_TOKEN}}

0 commit comments

Comments
 (0)