core/vm: remove usages of older tracer from instructions #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Test | |
on: | |
push: | |
branches: | |
- main | |
- evm-tracer* | |
pull_request: | |
branches: | |
- main | |
- evm-tracer* | |
concurrency: | |
group: ${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
name: Run tests with coverage | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 | |
with: | |
fetch-depth: 2 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22.10' | |
- name: Run tests with coverage | |
id: coverage | |
env: | |
CFLAGS: "-O -D__BLST_PORTABLE__" | |
GOBIN: "./build/bin" | |
COVERAGE_THRESHOLD: 50 | |
run: | | |
# Generate markdown report for changed files | |
echo "## 📊 Code Coverage Report" > coverage.md | |
# Run tests with coverage | |
CGO_CFLAGS_ALLOW="$CFLAGS" CGO_CFLAGS="$CFLAGS" go test -covermode=set -coverprofile cover.out ./... -tags=blst_enabled,ckzg | |
total_coverage=$(go tool cover -func=cover.out | grep total: | awk '{print $3}') | |
# Remove percentage sign for numeric comparison | |
total_coverage_num=${total_coverage%\%} | |
# For PRs, show coverage for changed lines | |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then | |
echo "::group::Coverage for Changed Lines" | |
# Get changed files using GitHub's GITHUB_SHA and base SHA | |
if [ -n "${{ github.event.pull_request.base.sha }}" ]; then | |
# PR context - use PR base and head SHAs directly | |
BASE_SHA="${{ github.event.pull_request.base.sha }}" | |
HEAD_SHA="${{ github.sha }}" | |
git fetch --depth=1 origin $BASE_SHA | |
CHANGED_FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA | grep '\.go$' || echo "") | |
else | |
# Push context - compare with previous commit | |
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '\.go$' || echo "") | |
fi | |
if [ -n "$CHANGED_FILES" ]; then | |
echo "Changed Go files:" | |
echo "$CHANGED_FILES" | |
echo "" | |
# Filter coverage file to only include changed files | |
if [ -f "cover.out" ]; then | |
# Add the mode line to the filtered coverage file | |
head -n 1 cover.out > cover.filtered.out | |
# For each changed file, find its entries in the coverage file | |
for file in $CHANGED_FILES; do | |
echo "Filtering coverage for file: $file" | |
# Extract just the filename without path | |
filename=$(basename "$file") | |
echo " Looking for filename: $filename" | |
# Various ways to match the file in coverage data | |
grep -F "/$filename:" cover.out | head -n 3 || echo " No direct filename matches" | |
grep -F "/$filename:" cover.out >> cover.filtered.out || true | |
# Try with full path match (both with and without leading slash) | |
grep -F "$file:" cover.out | head -n 3 || echo " No full path matches" | |
grep -F "$file:" cover.out >> cover.filtered.out || true | |
grep -F "/$file:" cover.out | head -n 3 || echo " No full path with slash matches" | |
grep -F "/$file:" cover.out >> cover.filtered.out || true | |
done | |
# Generate HTML report for filtered coverage | |
go tool cover -html=cover.filtered.out -o coverage.html | |
echo "Generated filtered coverage report: coverage.html" | |
# If total coverage is less than threshold, add a warning icon, else add a checkmark icon | |
if [ $total_coverage_num -lt $COVERAGE_THRESHOLD ]; then | |
echo "⚠️ Total coverage: $total_coverage (Below threshold of ${COVERAGE_THRESHOLD}%)" >> coverage.md | |
else | |
echo "✅ Total coverage: $total_coverage (Above threshold of ${COVERAGE_THRESHOLD}%)" >> coverage.md | |
fi | |
echo "" >> coverage.md | |
echo "### 📑 Detailed coverage report:" >> coverage.md | |
echo "| File | Coverage |" >> coverage.md | |
echo "|------|----------|" >> coverage.md | |
# For each changed file, get its coverage percentage | |
for file in $CHANGED_FILES; do | |
# Get coverage percentage using go tool cover, taking only the first match | |
coverage=$(go tool cover -func=cover.filtered.out | grep "$file" | head -n 1 | awk '{print $3}' || echo "N/A") | |
# Only add to report if file exists and has content | |
if [ -s "$file" ] && [ "$coverage" != "N/A" ] && [ -n "$coverage" ]; then | |
echo "| $file | $coverage |" >> coverage.md | |
fi | |
done | |
# Add a summary if no valid coverage data was found | |
if [ ! -s coverage.md ] || [ $(wc -l < coverage.md) -le 3 ]; then | |
echo "No coverage data available for changed files." >> coverage.md | |
fi | |
echo "Generated markdown coverage report: coverage.md" | |
else | |
echo "No coverage file found" | |
fi | |
else | |
echo "No Go files changed in this PR" | |
fi | |
echo "::endgroup::" | |
fi | |
- name: Upload Coverage Report | |
uses: actions/upload-artifact@v4 | |
id: upload-artifact | |
with: | |
name: coverage-report | |
path: | | |
coverage.html | |
coverage.md | |
cover.out | |
cover.filtered.out | |
retention-days: 1 | |
# - name: Post Coverage Report as PR Comment | |
# if: github.event_name == 'pull_request' | |
# uses: actions/github-script@v7 | |
# with: | |
# script: | | |
# const fs = require('fs'); | |
# const report = fs.readFileSync('coverage.md', 'utf8'); | |
# // Get the direct link to the artifact from the upload-artifact step | |
# const artifactUrl = '${{ steps.upload-artifact.outputs.artifact-url }}'; | |
# // Add link to the coverage report artifact | |
# const reportWithLink = report + | |
# '\n\n### 📈 [Download detailed HTML coverage report](' + artifactUrl + ')'; | |
# github.rest.issues.createComment({ | |
# issue_number: context.issue.number, | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# body: reportWithLink | |
# }); |