Skip to content

Commit

Permalink
ci(GitHub Actions): Shard no-docker tests (#16509)
Browse files Browse the repository at this point in the history
* chore(ci): shard no-docker tests

Uses new jest feature which allows to shard test suite by the machine.
It's used on functional test suite for no-docker jobs.

* Update .github/workflows/test.yml

Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>

* Update .github/workflows/test.yml

Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>

* Update .github/workflows/test.yml

Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>

* Update .github/workflows/test.yml

Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>

Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
  • Loading branch information
SevInf and Jolg42 committed Nov 30, 2022
1 parent ca98e87 commit 203ea6c
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 2 deletions.
73 changes: 71 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,75 @@ jobs:
# (PostgreSQL and MongoDB are provided by GitHub Actions out of the box), and
# minimize the time spent waiting for a free runner.
#
no-docker-client-functional:
timeout-minutes: 40
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
node: [14]
queryEngine: ['library', 'binary']
shard: ['1', '2']

needs: detect_jobs_to_run
if: |
${{
contains(needs.detect_jobs_to_run.outputs.jobs, '-all-') ||
contains(needs.detect_jobs_to_run.outputs.jobs, '-client-')
}}
steps:
- uses: actions/checkout@v3

- name: Prerequisites
shell: bash
run: |
echo "TEST_SKIP_MSSQL=true" >> $GITHUB_ENV
echo "TEST_SKIP_MONGODB=true" >> $GITHUB_ENV
echo "TEST_SKIP_COCKROACHDB=true" >> $GITHUB_ENV
echo "TEST_MONGO_URI_MIGRATE=mongodb://localhost:27017/tests-migrate" >> $GITHUB_ENV
echo "PRISMA_CLI_QUERY_ENGINE_TYPE=${{ matrix.queryEngine }}" >> $GITHUB_ENV
echo "PRISMA_CLIENT_ENGINE_TYPE=${{ matrix.queryEngine }}" >> $GITHUB_ENV
- name: Set up PostgreSQL
run: bash .github/workflows/scripts/setup-postgres.sh

- name: Set up MySQL
run: bash .github/workflows/scripts/setup-mysql.sh

- uses: pnpm/action-setup@v2.2.4
with:
version: 7

- uses: actions/setup-node@v3
with:
cache: 'pnpm'
node-version: ${{ matrix.node }}

- run: bash .github/workflows/scripts/setup.sh
env:
CI: true
SKIP_GIT: true
GITHUB_CONTEXT: ${{ toJson(github) }}

- name: Test packages/client
run: pnpm run test:functional:code --shard=${{matrix.shard}}/2
working-directory: packages/client
env:
CI: true
SKIP_GIT: true
GITHUB_CONTEXT: ${{ toJson(github) }}
# allow Node.js to allocate at most 14GB of heap on macOS and 7GB on Windows
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
NODE_OPTIONS: "${{ matrix.os == 'macos-latest' && '--max-old-space-size=14336' || '--max-old-space-size=7168' }}"
JEST_JUNIT_SUITE_NAME: '${{ github.job }}/client/functional/${{ matrix.os }}/node-${{ matrix.node }}/${{ matrix.queryEngine }}'

- uses: codecov/codecov-action@v3
with:
files: ./packages/client/src/__tests__/coverage/clover.xml
flags: client,${{ matrix.os }},${{ matrix.queryEngine }}
name: client-functional-${{ matrix.os }}-${{ matrix.queryEngine }}

no-docker:
timeout-minutes: 40
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -1029,9 +1098,9 @@ jobs:
flags: internals,${{ matrix.os }},${{ matrix.queryEngine }}
name: internals-${{ matrix.os }}-${{ matrix.queryEngine }}

- name: Test packages/client
- name: Test packages/client (old suite)
if: ${{ contains(needs.detect_jobs_to_run.outputs.jobs, '-all-') || contains(needs.detect_jobs_to_run.outputs.jobs, '-client-') }}
run: pnpm run test:functional:code && pnpm run test-notypes --testTimeout=40000
run: pnpm run test-notypes --testTimeout=40000
working-directory: packages/client
env:
CI: true
Expand Down
5 changes: 5 additions & 0 deletions packages/client/helpers/functional-test/run-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const args = arg(
'--changedSince': String,
// Passes the same flag to Jest to only run tests related to changed files
'--changedFilesWithAncestor': Boolean,
// Passes the same flag to Jest to shard tests between multiple machines
'--shard': String,
},
true,
true,
Expand Down Expand Up @@ -120,6 +122,9 @@ async function main(): Promise<number | void> {
if (args['--changedSince']) {
jestArgs.push('--changedSince', args['--changedSince'])
}
if (args['--shard']) {
jestArgs.push('--shard', args['--shard'])
}
const codeTestCli = jestCli.withArgs(jestArgs)

try {
Expand Down

0 comments on commit 203ea6c

Please sign in to comment.