Skip to content

Add gRPC-based IR loader #2003

Add gRPC-based IR loader

Add gRPC-based IR loader #2003

name: Build and run tests
on:
push:
branches:
- develop
- neo
pull_request:
branches:
- develop
- neo
workflow_dispatch:
permissions:
contents: read
checks: write
pull-requests: write
jobs:
build:
# Skip duplicate build when pushing to already existing PR
# Note: we decided NOT to skip duplicate builds,
# since we upload test results via 'EnricoMi/publish-unit-test-result-action',
# which requires 'pull_request' trigger for the bot to be able to add a comment to PR.
# if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
name: Run tests on JDK ${{ matrix.jdk }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
jdk: [ 8, 11, 19 ]
steps:
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.jdk }}
distribution: 'zulu'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
# Only write to the cache for builds on the specific branches. (Default is 'main' only.)
# Builds on other branches will only read existing entries from the cache.
cache-read-only: ${{ github.ref != 'refs/heads/develop' && github.ref != 'ref/heads/neo' }}
- name: Set up GraphViz
uses: ts-graphviz/setup-graphviz@v2
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Set up ArkAnalyzer
run: |
REPO_URL="https://gitcode.com/Lipen/arkanalyzer"
DEST_DIR="arkanalyzer"
MAX_RETRIES=10
RETRY_DELAY=3 # Delay between retries in seconds
#BRANCH="neo/2025-04-14"
BRANCH="lipen/grpc-merged"
for ((i=1; i<=MAX_RETRIES; i++)); do
git clone --depth=1 --branch $BRANCH $REPO_URL $DEST_DIR && break
echo "Clone failed, retrying in $RETRY_DELAY seconds..."
sleep "$RETRY_DELAY"
done
if [[ $i -gt $MAX_RETRIES ]]; then
echo "Failed to clone the repository after $MAX_RETRIES attempts."
exit 1
else
echo "Repository cloned successfully."
fi
echo "ARKANALYZER_DIR=$(realpath $DEST_DIR)" >> $GITHUB_ENV
cd $DEST_DIR
npm install
npm run build
- name: Start ArkAnalyzer server
run: |
nohup npm --prefix $ARKANALYZER_DIR run server > grpc-server.log 2>&1 &
echo $! > grpc-server.pid
- name: Wait for gRPC server to start
run: |
echo "Waiting for gRPC server to be ready..."
for i in {1..10}; do
nc -z localhost 50051 && echo "Server is up!" && exit 0
sleep 1
done
echo "Server failed to start" >&2
cat grpc-server.log
exit 1
- name: Generate test resources
run: ./gradlew :jacodb-ets:generateTestResources --scan
- name: Run ETS tests first
run: ./gradlew :jacodb-ets:test --scan
- name: Build and run tests
run: ./gradlew build --scan
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: "**/build/test-results/**/*.xml"
check_name: "Test results on JDK ${{ matrix.jdk }}"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
# - name: Upload test results
# uses: actions/upload-artifact@v4
# with:
# name: test-results
# path: build/test-results/
- name: Upload Gradle reports
if: (!cancelled())
uses: actions/upload-artifact@v4
with:
name: gradle-reports-jdk${{ matrix.jdk }}
path: '**/build/reports/'
retention-days: 1
- name: Upload gRPC server logs
if: (!cancelled())
uses: actions/upload-artifact@v4
with:
name: grpc-server-log-jdk${{ matrix.jdk }}
path: grpc-server.log
- name: Kill gRPC server
if: always()
run: |
if [ -f grpc-server.pid ]; then
PID=$(cat grpc-server.pid)
echo "Killing gRPC server with PID $PID"
kill $PID || echo "Process already terminated"
fi
lifecycleTests:
name: Run lifecycle tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: 8
distribution: 'zulu'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
# Only write to the cache for builds on the specific branches. (Default is 'main' only.)
# Builds on other branches will only read existing entries from the cache.
cache-read-only: ${{ github.ref != 'refs/heads/develop' && github.ref != 'refs/heads/neo' }}
- name: Build and run lifecycle tests
run: ./gradlew lifecycleTest --scan
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: "**/build/test-results/**/*.xml"
check_name: "Lifecycle test results"