Skip to content

Commit

Permalink
CI improvements (#33)
Browse files Browse the repository at this point in the history
* check if parser files are generated properly

* don't cancel checks for default branch

* enable CI for drafts

* print tools' versions

* fix syntax

* better logging

* print tools' information before npm install

* better error message

* fix syntax

* show output of git diff-index for better debugging

* remove obsolete ready_for_review trigger

* better handling of failures

* use `npm ci` for reproducible builds

* less confusing message

* update the parser

* pin the tree-sitter version

contributors might generate parser files incompatible with the project's CI
after `npm install` if the version is not pinned

* Revert "update the parser"

This reverts commit d80a8c0.

* update the package lock

* update the parser

* show git diff changes

* Revert "update the parser"

This reverts commit cb91ae8.

* improve CI debugging

* undo artifacts uploading; truncate output for large diffs

* show newline after truncation

* regenerate the parser

* Revert "regenerate the parser"

This reverts commit 88937a3.
  • Loading branch information
resolritter committed Apr 24, 2023
1 parent d1df473 commit 4da0a74
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
46 changes: 38 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,53 @@ on:
- synchronize
- reopened
- unlocked
- ready_for_review

jobs:
test-parsing:
if: github.event.pull_request.draft != true
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
group: ci-${{ github.event.pull_request.number }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Install the tools
run: npm install
- name: Setup tools
run: |
set -x
node -v
npm -v
gcc -v
npm ci
./node_modules/.bin/tree-sitter --version
- name: Run the parsing tests
- name: Generate the parser
run: npm run generate

- name: Check if auto-generated files are committed
run: |
npm run generate
npm run test-parsing
git add .
if output="$(git status --porcelain=v2)"; then
files_changed_msg="$output"
diff="$(git diff --cached --color=never)"
echo "${diff::1000}"
if [ ${#diff} -gt 1000 ]; then
echo "-- TRUNCATED --"$'\n'
fi
else
fail_code=$?
fi
if [ "${fail_code:-}" ]; then
exit $fail_code
elif [ "${files_changed_msg:-}" ]; then
>&2 echo \
"Detected changes after generating parser files:" \
$'\n'"$files_changed_msg"$'\n' \
$'\n'"Please commit those changes locally and push"
exit 1
fi
- name: Run the parsing tests
run: npm run test-parsing
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"nan": "^2.12.1"
},
"devDependencies": {
"tree-sitter-cli": "^0.20.1"
"tree-sitter-cli": "0.20.7"
},
"scripts": {
"test": "tree-sitter test",
Expand Down

0 comments on commit 4da0a74

Please sign in to comment.