add workflow trigger for bridge e2e tests #3675
This file contains 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: Coverage | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
env: | |
NODE_OPTIONS: "--max-old-space-size=12288" | |
GRCOV_VERSION: 0.8.18 | |
jobs: | |
####### Check files and formatting ####### | |
set-tags: | |
runs-on: ubuntu-latest | |
outputs: | |
git_ref: ${{ steps.check-git-ref.outputs.git_ref }} | |
coverage_dir: ${{ steps.check-git-ref.outputs.coverage_dir }} | |
coverage_report: ${{ steps.check-git-ref.outputs.coverage_report }} | |
git_branch: ${{ steps.check-git-ref.outputs.git_branch }} | |
git_target_branch: ${{ steps.check-git-ref.outputs.git_target_branch }} | |
steps: | |
- name: Check git ref | |
id: check-git-ref | |
# if PR | |
# else if manual PR | |
# else (push) | |
run: | | |
if [[ -n "${{ github.event.pull_request.head.sha }}" ]]; then | |
echo "git_branch=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_OUTPUT | |
echo "git_target_branch=$(echo ${GITHUB_BASE_REF})" >> $GITHUB_OUTPUT | |
echo "git_ref=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT | |
echo "coverage_dir=tanssi-coverage/pulls/${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT | |
echo "coverage_report=true" >> $GITHUB_OUTPUT | |
else | |
echo "git_branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT | |
echo "git_target_branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT | |
echo "git_ref=$GITHUB_REF" >> $GITHUB_OUTPUT | |
echo "coverage_dir=tanssi-coverage/branches/master" >> $GITHUB_OUTPUT | |
echo "coverage_report=false" >> $GITHUB_OUTPUT | |
fi | |
build-and-coverage: | |
runs-on: | |
labels: self-hosted | |
needs: ["set-tags"] | |
env: | |
RUSTC_WRAPPER: "sccache" | |
CARGO_INCREMENTAL: "0" | |
SCCACHE_CACHE_SIZE: "100GB" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.set-tags.outputs.git_ref }} | |
- name: Setup Variables | |
shell: bash | |
run: | | |
echo "RUSTFLAGS=-C opt-level=3 -D warnings -C instrument-coverage -C linker=clang -C link-arg=-fuse-ld=$(pwd)/mold/bin/mold" >> $GITHUB_ENV | |
# Disable coverage when building | |
echo "LLVM_PROFILE_FILE=/dev/null" >> $GITHUB_ENV | |
- name: Setup grcov | |
run: | | |
wget https://github.com/mozilla/grcov/releases/download/v${{ env.GRCOV_VERSION }}/grcov-x86_64-unknown-linux-gnu.tar.bz2 | |
tar xvf grcov-x86_64-unknown-linux-gnu.tar.bz2 | |
chmod +x grcov | |
- name: Cargo build | |
uses: ./.github/workflow-templates/cargo-build | |
with: | |
features: "fast-runtime" | |
- name: Enable coverage gathering | |
run: | | |
# Enable coverage when running tests | |
echo "LLVM_PROFILE_FILE=$(pwd)/proffiles/default_%m_%p.profraw" >> $GITHUB_ENV | |
- name: Upload runtimes | |
uses: actions/upload-artifact@v4 | |
with: | |
name: runtimes | |
path: runtimes | |
- name: Upload binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries | |
path: binaries | |
- name: Unit tests | |
run: | | |
cargo test --release --all --features=fast-runtime --exclude tc-consensus | |
- name: Typescript Tests Tanssi (Dev Service) | |
uses: ./.github/workflow-templates/typescript-tests-moonwall | |
with: | |
moonwall-environment: dev_tanssi | |
force-pass: true | |
- name: Typescript Tests Frontier Template (Dev Service) | |
uses: ./.github/workflow-templates/typescript-tests-moonwall | |
with: | |
moonwall-environment: dev_frontier_template | |
force-pass: true | |
- name: Typescript Tests Simple Template (Dev Service) | |
uses: ./.github/workflow-templates/typescript-tests-moonwall | |
with: | |
moonwall-environment: dev_simple_template | |
force-pass: true | |
- name: Typescript Tests Tanssi Relay (Dev Service) | |
uses: ./.github/workflow-templates/typescript-tests-moonwall | |
with: | |
moonwall-environment: dev_tanssi_relay | |
force-pass: true | |
- name: Install llvm tools | |
run: | |
rustup component add llvm-tools-preview | |
- name: Retrieve coverage | |
id: coverage | |
run: | | |
du -sh proffiles | |
echo "Executing grcov" | |
mkdir -p coverage | |
./grcov proffiles/ -s ./ --binary-path ./target/release/ \ | |
-t html,covdir --branch --ignore-not-existing --ignore "target/release/build/*" \ | |
--ignore "*mock.rs" --ignore "*tests.rs" --ignore "$HOME/.cargo/**" \ | |
-o coverage/ --llvm 2>&1 \ | |
| tee grcov.log | |
cat grcov.log | |
ls coverage | |
INVALID="$(grep invalid grcov.log | \ | |
grep -o '[^\ /]*raw' | \ | |
sed 's/_1\.profraw/\.profraw/g' || echo '')" | |
echo "Invalid files: $INVALID" | |
if [ -n "$INVALID" ]; then | |
echo "Removing invalid files: $INVALID" | |
cd proffiles/ | |
rm $INVALID | |
cd .. | |
./grcov proffiles/ -s ./ --binary-path ./target/release/ \ | |
-t html,covdir --branch --ignore-not-existing --ignore "target/release/build/*" \ | |
--ignore "*mock.rs" --ignore "*tests.rs" --ignore "$HOME/.cargo/**" \ | |
-o coverage/ --llvm | |
fi | |
if [ "${{ (needs.set-tags.outputs.coverage_report == 'true') && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') }}" == "true" ]; then | |
echo "Generating coverage report" | |
wget ${{ vars.S3_BUCKET_URL }}/tanssi-coverage/branches/master/covdir \ | |
-O base_covdir || true | |
python3 .github/scripts/coverage-report.py \ | |
--base-covdir ./base_covdir \ | |
--incoming-covdir ./coverage/covdir \ | |
--base-branch ${{ needs.set-tags.outputs.git_target_branch }} \ | |
--incoming-branch ${{ needs.set-tags.outputs.git_branch }} \ | |
--base-html-url ${{ vars.S3_BUCKET_URL }}/${{ needs.set-tags.outputs.coverage_dir }} \ | |
> coverage_report.md | |
echo "coverage_date=\"$(date)\"" >> $GITHUB_OUTPUT | |
fi | |
rm -rf proffiles/ | |
- name: Upload coverate to gha | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage | |
path: coverage | |
- name: Upload coverage s3 | |
if: ${{(github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') }} | |
uses: mario-sangar/upload-s3-action@master | |
id: S3 | |
with: | |
aws_key_id: ${{ secrets.S3_COVERAGE_ID }} | |
aws_secret_access_key: ${{ secrets.S3_COVERAGE_KEY }} | |
aws_bucket: ${{ vars.S3_COVERAGE_BUCKET }} | |
destination_dir: "${{ needs.set-tags.outputs.coverage_dir }}" | |
source_dir: "coverage" | |
acl: "none" | |
- name: Link To Report | |
if: ${{(github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') }} | |
run: | | |
echo "${{steps.S3.outputs.object_key}}" | |
echo "${{ vars.S3_BUCKET_URL }}/${{steps.S3.outputs.object_key}}/html/index.html" | |
- name: Create coverage report comment | |
if: ${{ (needs.set-tags.outputs.coverage_report == 'true') && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') }} | |
run: | | |
mv coverage_report.md temp_coverage_report.md | |
echo "## [Coverage Report](${{ vars.S3_BUCKET_URL }}/${{steps.S3.outputs.object_key}}/html/index.html)" > coverage_report.md | |
echo "[(master)](${{ vars.S3_BUCKET_URL }}/tanssi-coverage/branches/master/html/index.html)" >> coverage_report.md | |
cat temp_coverage_report.md >> coverage_report.md | |
rm temp_coverage_report.md | |
echo "> Coverage generated ${{ steps.coverage.outputs.coverage_date }}" >> coverage_report.md | |
echo "Generated coverage report comment" | |
cat coverage_report.md | |
- name: Find Comment | |
if: ${{ (needs.set-tags.outputs.coverage_report == 'true') && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') }} | |
uses: peter-evans/find-comment@v2 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: "github-actions[bot]" | |
body-includes: Coverage generated | |
- name: Create or update comment | |
if: ${{ (needs.set-tags.outputs.coverage_report == 'true') && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') }} | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body-path: coverage_report.md | |
edit-mode: replace |