Skip to content

chore(ci): enable coveralls MONGOSH-2125 #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions .github/workflows/check-test.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# This action runs lint checks and tests against the code.
name: Check and Test

# Controls when the action will run.
on:
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
push:
branches:
Expand All @@ -18,7 +16,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
check-and-test:
name: Check and Test
Expand All @@ -28,10 +25,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

fail-fast: false

# The type of runner that the job will run on
runs-on: ${{ matrix.os }}

# Steps represent a sequence of tasks that will be executed as part of the job
Expand All @@ -51,21 +46,18 @@ jobs:
if: ${{ runner.os == 'Linux' }}
run: sudo apt-get -y update && sudo apt-get -y install libkrb5-dev libsecret-1-dev net-tools libstdc++6 gnome-keyring

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"

- name: Install npm
run: npm install -g npm@9

- name: Use [email protected]
# Default Python (3.12) doesn't have support for distutils
# https://github.com/nodejs/node-gyp/issues/2869
Expand Down Expand Up @@ -95,12 +87,26 @@ jobs:
shell: bash

- name: Run Checks
# We exclude dependents when running eslint and depchecks because
# linting and dependency checking is relevant only for packages where
# the source code was changed
run: npm run check-ci -- --stream
shell: bash

- name: Run Tests
run: npm run test-ci -- --stream
shell: bash

- name: Report Coverage
Copy link
Collaborator

@gagik gagik Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi if you haven't considered it already: coveralls does have an official github action that could be worth considering, didn't look too much into it though, might not fit our setup: https://github.com/marketplace/actions/coveralls-github-action

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I looked at it, but the problem with it is that it's designed to report the results of a single package run, so I'd have to either add 20 steps to report coverage from each of the packages in the monorepo, or completely change how we're running CI to make it run one job per package in a matrix. The official action is using the CLI like we are and I did consult with its implementation when working on our reporting.

if: ${{ runner.os == 'Linux' }}
run: |
curl -L https://coveralls.io/coveralls-linux.tar.gz | tar -xz -C /usr/local/bin
coverage_reports=(packages/*/coverage/lcov.info)
for report in "${coverage_reports[@]}"; do
echo "Processing report: $report"
flag_name=$(sed -E 's/packages\/([^\/]*)\/coverage\/lcov.info/\1/g' <<<$report)
coveralls report --base-path . --job-flag=$flag_name $report --parallel --no-logo
done

coveralls done
env:
COVERALLS_GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
COVERALLS_REPO_TOKEN: ${{ github.token }}
COVERALLS_GIT_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}