add integration test CI (#32)

pull/315/head
Michael Davis 2022-06-08 17:32:26 +07:00 committed by GitHub
parent a935608722
commit 7b7628230e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 1 deletions

@ -3,7 +3,7 @@ name: CI
on: [push, pull_request]
jobs:
bless:
test:
name: Test
runs-on: ubuntu-latest
@ -35,3 +35,33 @@ jobs:
- name: Check formatting
run: npm run check-formatted
integration-test:
name: Integration Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: "14.x"
- name: Cache npm dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
run: npm ci
- name: Ensure generated parser files are up to date
run: npx tree-sitter generate
- name: Run integration tests
run: ./scripts/integration_test.sh

@ -0,0 +1,24 @@
#! /usr/bin/env bash
set -e
cd "$(dirname "$0")/.."
usage() {
echo "$0"
echo ""
echo "Tests that the parser does not create error nodes"
echo "when tested against real Gleam repos"
echo ""
exit 1
}
if [ $# -ne 0 ]; then
usage
fi
repos="gleam-lang/stdlib gleam-lang/json gleam-lang/http gleam-lang/example-todomvc gleam-lang/bitwise gleam-lang/erlang gleam-lang/otp gleam-lang/cowboy gleam-lang/hackney gleam-lang/httpc gleam-lang/elli gleam-lang/javascript gleam-lang/example-echo-server gleam-lang/plug"
for repo in $repos; do
./scripts/parse_repo.sh $repo
done

@ -0,0 +1,29 @@
#! /usr/bin/env bash
set -e
cd "$(dirname "$0")/.."
usage() {
echo "$0 owner/repository"
echo ""
echo "Runs the parser against Gleam files in a GitHub repository"
echo ""
exit 1
}
if [ $# -ne 1 ]; then
usage
fi
gh_repo="$1"
dir="test/integration/${gh_repo//[\/-]/_}"
if [[ ! -d "$dir" ]]; then
mkdir -p "$(dirname "$dir")"
git clone --depth 1 "https://github.com/$gh_repo.git" "$dir"
fi
echo "Running parser against $gh_repo"
npx tree-sitter parse --quiet --stat "$dir/**/*.gleam"

@ -0,0 +1,2 @@
*
!.gitignore