From b18eea05a44478da6860dd52efdfb0d9c61fc09a Mon Sep 17 00:00:00 2001 From: Antros Economides Date: Mon, 28 Aug 2023 18:32:49 +0300 Subject: [PATCH] Bootstrap in stages This requires the `bootstrap/1` tag, which we have to fetch explicitly on the test runners (see https://github.com/actions/checkout/issues/701). --- .github/workflows/graphene_tests.yml | 4 +++- bootstrap.sh | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/graphene_tests.yml b/.github/workflows/graphene_tests.yml index 8d914c3b..a2dadae2 100644 --- a/.github/workflows/graphene_tests.yml +++ b/.github/workflows/graphene_tests.yml @@ -38,6 +38,8 @@ jobs: sudo ./llvm.sh ${{ matrix.llvm-version }} sudo apt-get install -y llvm-${{ matrix.llvm-version }}-runtime - name: Bootstrap the parser - run: ./bootstrap.sh + run: | + git fetch --tags origin + ./bootstrap.sh - name: Run tests run: python tests/run_tests.py diff --git a/bootstrap.sh b/bootstrap.sh index 2a11676f..362be3a8 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,4 +1,19 @@ #!/usr/bin/env bash -# Atm this is easy... it becomes harder once we remove lark +set -ex + +# Attempt to get the current location. Prefer a branch name if available, +# otherwise fall back to the current commit's hash if we are in "detached HEAD" +# state. +git_location=$(git branch --show) +if [[ "$git_location" == "" ]]; then + git_location=$(git rev-parse HEAD) +fi + +# Stage 1; last commit where the Lark parser can parse the native parser. +git checkout bootstrap/1 ./glang ./parser/parser.c3 -o ./parser/parser --bootstrap -O3 + +# Stage 2; build native parser at current commit +git checkout "$git_location" +./glang ./parser/parser.c3 -o ./parser/parser -O3