Skip to content

Commit e8e5625

Browse files
ObserverOfTimeamaanq
authored andcommitted
ci: major overhaul
- Simplify some workflow steps and auxiliary scripts - Build library using cmake when not cross-compiling - Try to fetch fixtures from cache first - Use `actions-rust-lang/setup-rust-toolchain`
1 parent 7715001 commit e8e5625

File tree

11 files changed

+278
-265
lines changed

11 files changed

+278
-265
lines changed

.github/actions/cache/action.yml

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
name: 'Cache'
2-
description: "This action caches fixtures"
1+
name: Cache
2+
3+
description: This action caches fixtures
4+
35
outputs:
46
cache-hit:
5-
description: 'Cache hit'
6-
value: ${{ steps.cache_output.outputs.cache-hit }}
7+
description: Cache hit
8+
value: ${{ steps.cache.outputs.cache-hit }}
9+
710
runs:
8-
using: "composite"
11+
using: composite
912
steps:
1013
- uses: actions/cache@v4
11-
id: cache_fixtures
14+
id: cache
1215
with:
1316
path: |
1417
test/fixtures/grammars
1518
target/release/tree-sitter-*.wasm
1619
key: fixtures-${{ join(matrix.*, '_') }}-${{ hashFiles(
17-
'cli/src/generate/**',
18-
'script/generate-fixtures*',
20+
'cli/generate/src/**',
21+
'xtask/src/*',
1922
'test/fixtures/grammars/*/**/src/*.c',
2023
'.github/actions/cache/action.yml') }}
21-
22-
- run: echo "cache-hit=${{ steps.cache_fixtures.outputs.cache-hit }}" >> $GITHUB_OUTPUT
23-
shell: bash
24-
id: cache_output

.github/scripts/cross.sh

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
#!/bin/bash
1+
#!/bin/bash -eu
22

3-
# set -x
4-
set -e
5-
6-
if [ "$BUILD_CMD" != "cross" ]; then
7-
echo "cross.sh - is a helper to assist only in cross compiling environments" >&2
8-
echo "To use this tool set the BUILD_CMD env var to the \"cross\" value" >&2
9-
exit 111
10-
fi
11-
12-
if [ -z "$CROSS_IMAGE" ]; then
13-
echo "The CROSS_IMAGE env var should be provided" >&2
14-
exit 111
15-
fi
16-
17-
docker run --rm -v /home/runner:/home/runner -w "$PWD" "$CROSS_IMAGE" "$@"
3+
exec docker run --rm -v /home/runner:/home/runner -w "$PWD" "$CROSS_IMAGE" "$@"

.github/scripts/make.sh

+5-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
#!/bin/bash
1+
#!/bin/bash -eu
22

3-
# set -x
4-
set -e
3+
tree_sitter="$ROOT"/target/"$TARGET"/release/tree-sitter
54

6-
if [ "$BUILD_CMD" == "cross" ]; then
7-
if [ -z "$CC" ]; then
8-
echo "make.sh: CC is not set" >&2
9-
exit 111
10-
fi
11-
if [ -z "$AR" ]; then
12-
echo "make.sh: AR is not set" >&2
13-
exit 111
14-
fi
15-
16-
cross.sh make CC=$CC AR=$AR "$@"
5+
if [[ $BUILD_CMD == cross ]]; then
6+
cross.sh make CC="$CC" AR="$AR" "$@"
177
else
18-
make "$@"
8+
exec make "$@"
199
fi

.github/scripts/tree-sitter.sh

+4-23
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
1-
#!/bin/bash
2-
3-
# set -x
4-
set -e
5-
6-
if [ -z "$ROOT" ]; then
7-
echo "The ROOT env var should be set to absolute path of a repo root folder" >&2
8-
exit 111
9-
fi
10-
11-
if [ -z "$TARGET" ]; then
12-
echo "The TARGET env var should be equal to a \`cargo build --target <TARGET>\` command value" >&2
13-
exit 111
14-
fi
1+
#!/bin/bash -eu
152

163
tree_sitter="$ROOT"/target/"$TARGET"/release/tree-sitter
174

18-
if [ "$BUILD_CMD" == "cross" ]; then
19-
if [ -z "$CROSS_RUNNER" ]; then
20-
echo "The CROSS_RUNNER env var should be set to a CARGO_TARGET_*_RUNNER env var value" >&2
21-
echo "that is available in a docker image used by the cross tool under the hood" >&2
22-
exit 111
23-
fi
24-
25-
cross.sh $CROSS_RUNNER "$tree_sitter" "$@"
5+
if [[ $BUILD_CMD == cross ]]; then
6+
cross.sh "$CROSS_RUNNER" "$tree_sitter" "$@"
267
else
27-
"$tree_sitter" "$@"
8+
exec "$tree_sitter" "$@"
289
fi

.github/workflows/backport.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
name: backport
1+
name: Backport Pull Request
2+
23
on:
34
pull_request_target:
45
types: [closed, labeled]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
511
jobs:
612
backport:
7-
permissions:
8-
contents: write
9-
pull-requests: write
10-
name: Backport Pull Request
1113
if: github.event.pull_request.merged
1214
runs-on: ubuntu-latest
1315
steps:
14-
- uses: actions/checkout@v4
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
1518

16-
- uses: actions/create-github-app-token@v1
19+
- name: Create app token
20+
uses: actions/create-github-app-token@v1
1721
id: app-token
1822
with:
1923
app-id: ${{ vars.BACKPORT_APP }}
2024
private-key: ${{ secrets.BACKPORT_KEY }}
2125

2226
- name: Create backport PR
23-
id: backport
2427
uses: korthout/backport-action@v3
2528
with:
2629
pull_title: "${pull_title}"

0 commit comments

Comments
 (0)