chore: sort deps and run pkg fix (#831) #2203
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
| # This action runs lint checks and tests against the code. | |
| name: Check and Test | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read # we just need to checkout the repo | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| jobs: | |
| check-and-test: | |
| name: Check and Test | |
| timeout-minutes: 45 | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| # Tests are split across hosts into groups by package (see | |
| # compute-test-group.mjs). When changing the group count, keep | |
| # TOTAL_GROUPS below in sync with the number of list entries here. | |
| group: [1, 2, 3, 4] | |
| fail-fast: false | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| TOTAL_GROUPS: 4 | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| - name: Sets env vars | |
| if: github.event_name == 'pull_request' | |
| run: echo "SINCE_REF=remotes/origin/main" >> $GITHUB_ENV | |
| shell: bash | |
| # On main we run all the checks with changes since the last commit | |
| - name: Sets env vars (main) | |
| if: github.event_name != 'pull_request' | |
| run: echo "SINCE_REF=HEAD~1" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Install Deps Ubuntu | |
| 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 | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22.21.1 | |
| cache: "npm" | |
| - name: Install npm | |
| run: npm install -g npm@11.16.0 | |
| - name: Use python@3.11 | |
| # Default Python (3.12) doesn't have support for distutils | |
| # https://github.com/nodejs/node-gyp/issues/2869 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Dependencies | |
| run: | | |
| # Dependencies are included when installing as npm workspaces will | |
| # hoist every package in the repo and it's important that the | |
| # dependencies of packages we are planning to test are also prepared | |
| npm run bootstrap-ci -- --scope @mongodb-js/monorepo-tools --stream --include-dependencies | |
| npm run bootstrap-ci -- --stream --include-dependencies | |
| # saslprep source code may have been modified by bootstrapping, | |
| # depending on the OS, so undo that change if it has happened | |
| # (since it can influence subsequent lerna invocations) | |
| git checkout -- packages/saslprep/src/code-points-data.ts | |
| shell: bash | |
| - name: Info | |
| run: | | |
| LERNA_VERSION=$(npm ls lerna --json | jq -r .dependencies.lerna.version) | |
| echo "Packages changed since: ${SINCE_REF}" | |
| npx lerna@${LERNA_VERSION} ls --all --since ${SINCE_REF} | |
| shell: bash | |
| # Checks are not split into groups; run them once per OS on the first group. | |
| - name: Run Checks | |
| if: ${{ matrix.group == 1 }} | |
| run: npm run check-ci -- --stream | |
| shell: bash | |
| - name: Run Tests | |
| run: | | |
| scopes=$(node .github/scripts/compute-test-group.mjs "${{ matrix.group }}" "${TOTAL_GROUPS}") | |
| echo "Testing group ${{ matrix.group }}/${TOTAL_GROUPS} with: ${scopes}" | |
| npm run test-ci -- --stream ${scopes} | |
| shell: bash | |
| # Each group uploads coverage for the packages it tested; the parallel | |
| # build is finalized once by the separate coverage-finalize job below. | |
| - name: Report Coverage | |
| 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 | |
| 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 }} | |
| # Signals to Coveralls that all parallel coverage uploads from the grouped | |
| # check-and-test jobs are complete. | |
| coverage-finalize: | |
| name: Finalize Coverage | |
| needs: check-and-test | |
| if: ${{ always() && needs.check-and-test.result != 'skipped' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Finalize Coveralls parallel build | |
| run: | | |
| curl -L https://coveralls.io/coveralls-linux.tar.gz | tar -xz -C /usr/local/bin | |
| 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 }} | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22.21.1 | |
| - name: Run Lint | |
| run: node .github/scripts/lint-pkg.mjs |