Skip to content

test: use insta for JS parser #2098

test: use insta for JS parser

test: use insta for JS parser #2098

# Test coverage job. It is run on pull request because it prints the results via comment
name: Parser conformance and comparison
on:
pull_request:
branches:
- main
paths:
- 'crates/biome_js_syntax/**'
- 'crates/biome_js_factory/**'
- 'crates/biome_js_semantic/**'
- 'crates/biome_js_parser/**'
- 'crates/biome_rowan/**'
- 'xtask/**'
env:
RUST_LOG: info
RUST_BACKTRACE: 1
jobs:
coverage:
permissions:
pull-requests: write
name: Parser conformance
runs-on: ubuntu-latest
steps:
- name: Checkout PR Branch
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Support longpaths
run: git config core.longpaths true
- name: Checkout PR Branch
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
submodules: recursive
- name: Free Disk Space
uses: ./.github/actions/free-disk-space
- name: Install toolchain
uses: moonrepo/setup-rust@e013866c4215f77c925f42f60257dec7dd18836e # v1.2.1
with:
cache-target: release
cache-base: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Compile
run: cargo build --release --locked -p xtask_coverage
- name: Run Test suites
continue-on-error: true
run: cargo coverage --json > new_results.json
- name: Checkout main Branch
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
clean: false
ref: main
submodules: recursive
- name: Run Test suites on main branch
continue-on-error: true
run: cargo coverage --json > base_results.json
- name: Compare results on ${{ matrix.os }}
if: github.event_name == 'pull_request'
id: comparison
shell: bash
run: |
echo "## Parser conformance results on ${{ matrix.os }}" > output
cargo coverage compare ./base_results.json ./new_results.json --markdown >> output
cat output
echo "comment<<EOF" >> $GITHUB_OUTPUT
cat output >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Get the PR number
if: github.event_name == 'pull_request'
id: pr-number
uses: kkak10/pr-number-action@8f5358941366822cd0825e04dfe68437f2f5f15b # v1.3
- name: Find Previous Comment
if: github.event_name == 'pull_request'
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
id: previous-comment
with:
issue-number: ${{ steps.pr-number.outputs.pr }}
body-includes: Parser conformance results on ${{ matrix.os }}
- name: Update existing comment
if: github.event_name == 'pull_request' && steps.previous-comment.outputs.comment-id
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
continue-on-error: true
with:
comment-id: ${{ steps.previous-comment.outputs.comment-id }}
body: |
${{ steps.comparison.outputs.comment }}
edit-mode: replace
- name: Write a new comment
if: github.event_name == 'pull_request' && !steps.previous-comment.outputs.comment-id
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
continue-on-error: true
with:
issue-number: ${{ steps.pr-number.outputs.pr }}
body: |
${{ steps.comparison.outputs.comment }}
- name: Clean cache
run: cargo cache --autoclean