Skip to content

Commit

Permalink
Merge pull request #6168 from artsy/araujobarret/feat/ci-test-paralle…
Browse files Browse the repository at this point in the history
…lism

ci(jest): Add CI parallelism
  • Loading branch information
damassi authored Oct 25, 2024
2 parents 4063ba3 + 671ca06 commit c44dc3b
Show file tree
Hide file tree
Showing 103 changed files with 5,273 additions and 5,975 deletions.
23 changes: 15 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
orbs:
hokusai: artsy/hokusai@volatile
horizon: artsy/release@volatile
node: circleci/node@5.3.0
node: circleci/node@6.3.0
yarn: artsy/[email protected]

not_staging_or_release: &not_staging_or_release
Expand Down Expand Up @@ -57,6 +57,18 @@ commands:
- yarn/save_dependencies

jobs:
test:
executor:
name: node/default
tag: "18.15"
parallelism: 6
steps:
- checkout
- yarn_install
- run:
name: Run Jest
command: |
yarn jest --ci --forceExit --logHeapUsage --runInBand --reporters=default --reporters=jest-junit --shard=$(expr $CIRCLE_NODE_INDEX + 1)/$CIRCLE_NODE_TOTAL
ensure-schema-update:
executor:
name: node/default
Expand All @@ -81,13 +93,8 @@ jobs:
workflows:
default:
jobs:
- node/test:
- test:
<<: *not_staging_or_release
name: test-jest
pkg-manager: yarn
test-results-for: jest
version: "18.15"

- node/run:
<<: *not_staging_or_release
name: type-check
Expand All @@ -103,7 +110,7 @@ workflows:
name: push-staging-image
<<: *only_main
requires:
- test-jest
- test

- hokusai/deploy-staging:
name: deploy-staging
Expand Down
23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
},
"author": "Art.sy Inc",
"license": "MIT",
"resolutions": {
"string-width": "4.2.3"
},
"dependencies": {
"@artsy/cohesion": "^4.213.0",
"@artsy/img": "1.0.3",
Expand Down Expand Up @@ -107,29 +110,29 @@
"devDependencies": {
"@artsy/express-reloadable": "1.7.0",
"@artsy/update-repo": "0.6.0",
"@babel/cli": "7.14.8",
"@babel/core": "7.15.0",
"@babel/node": "7.14.9",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.14.5",
"@babel/plugin-proposal-optional-chaining": "7.14.5",
"@babel/preset-env": "7.15.0",
"@babel/preset-typescript": "7.15.0",
"@babel/cli": "^7.25.9",
"@babel/core": "^7.25.9",
"@babel/node": "^7.25.9",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/preset-env": "^7.25.9",
"@babel/preset-typescript": "^7.25.9",
"@cloudflare/workers-types": "^4.20240909.0",
"@graphql-inspector/core": "1.27.0",
"@types/express-rate-limit": "2.9.3",
"@types/google-libphonenumber": "^7.4.22",
"@types/graphql-relay": "0.4.9",
"@types/graphql-upload": "^8.0.11",
"@types/invariant": "2.2.29",
"@types/jest": "23.3.2",
"@types/jest": "^29.5.14",
"@types/lodash": "4.14.86",
"@types/node": "14.17.0",
"@types/node-fetch": "2.1.7",
"@types/qs": "6.5.1",
"@types/request": "2.0.8",
"@typescript-eslint/eslint-plugin": "4.8.1",
"@typescript-eslint/parser": "4.8.1",
"babel-jest": "24.8.0",
"babel-jest": "^29.7.0",
"babel-plugin-module-resolver": "4.1.0",
"danger": "^11.2.1",
"deep-equal": "1.0.1",
Expand All @@ -141,7 +144,7 @@
"eslint-plugin-promise": "4.0.1",
"expect.js": "0.3.1",
"husky": "3.1.0",
"jest": "24.9.0",
"jest": "^29.7.0",
"jest-extended": "0.11.5",
"jest-junit": "^16.0.0",
"lint-staged": "7.3.0",
Expand Down
52 changes: 0 additions & 52 deletions patches/@types/graphql+0.13.4.patch

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib/__tests__/apis/fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jest.mock("request", () => jest.fn())
import request, { Request } from "request"
const mockRequest = (request as any) as jest.Mock<Request>
import request from "request"
const mockRequest = (request as any) as jest.Mock

import fetch from "../../apis/fetch"
import { constructUrlAndParams } from "../../apis/fetch"
Expand Down
8 changes: 3 additions & 5 deletions src/lib/__tests__/artworkToSubmissionMapping.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ describe("artworkToSubmissionMapping", () => {

const submission = artworkToSubmissionMapping(artwork)

expect(submission).toMatchInlineSnapshot(
`
Object {
expect(submission).toMatchInlineSnapshot(`
{
"artistID": "artist-id",
"attributionClass": "ATTRIBUTION_CLASS",
"category": "PHOTOGRAPHY",
Expand All @@ -60,8 +59,7 @@ describe("artworkToSubmissionMapping", () => {
"width": "10",
"year": "2020",
}
`
)
`)
})
})

Expand Down
1 change: 1 addition & 0 deletions src/lib/__tests__/graphqlTimeoutMiddleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ describe("graphQLTimeoutMiddleware", () => {
describe("concerning clearing timeouts", () => {
beforeAll(() => {
jest.useFakeTimers()
jest.spyOn(global, "clearTimeout")
})

afterAll(() => {
Expand Down
12 changes: 6 additions & 6 deletions src/lib/__tests__/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ describe("camelCaseKeys", () => {
}

expect(camelCaseKeys(object)).toMatchInlineSnapshot(`
Object {
{
"age": 42,
"favoritePlant": "cactus",
"firstName": "John",
Expand All @@ -356,8 +356,8 @@ describe("camelCaseKeys", () => {
}

expect(camelCaseKeys(object)).toMatchInlineSnapshot(`
Object {
"artistIDs": Array [
{
"artistIDs": [
"123",
],
"id": "123",
Expand All @@ -377,7 +377,7 @@ describe("snakeCaseKeys", () => {
}

expect(snakeCaseKeys(object)).toMatchInlineSnapshot(`
Object {
{
"age": 42,
"favorite_plant": "cactus",
"first_name": "John",
Expand All @@ -394,8 +394,8 @@ describe("snakeCaseKeys", () => {
}

expect(snakeCaseKeys(object)).toMatchInlineSnapshot(`
Object {
"artist_ids": Array [
{
"artist_ids": [
"123",
],
"id": "123",
Expand Down
5 changes: 2 additions & 3 deletions src/lib/loaders/__tests__/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import { apiLoaderWithoutAuthenticationFactory } from "lib/loaders/api/loader_wi

import cache from "lib/cache"
import { StaticPathLoader } from "../api/loader_interface"
import { API } from "../api"
import { LoaderFactory } from "../index"

describe("API loaders", () => {
let api: jest.Mock<API>
let api: jest.Mock
let apiLoader: LoaderFactory
let loader: StaticPathLoader<any>

beforeEach(() => {
api = jest.fn<API>((path, accessToken, options) =>
api = jest.fn((path, accessToken, options) =>
Promise.resolve({ body: { path, accessToken, options } })
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("artworkOrEditionSet", () => {
],
}

const artworkLoader = jest.fn(() => Promise.resolve(artwork))
const artworkLoader = jest.fn().mockResolvedValue(artwork)

const context: Partial<ResolverContext> = {
artworkLoader,
Expand Down
94 changes: 47 additions & 47 deletions src/lib/stitching/vortex/__tests__/partnerStatsSales.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ describe("PartnerStatsSales type", () => {
`
const result = await runQuery(query, context)
expect(result).toMatchInlineSnapshot(`
Object {
"partner": Object {
"analytics": Object {
"sales": Object {
"partnerId": "5748d153cd530e2d5100031c",
"timeSeries": Array [
Object {
"endTime": "2019-05-05T00:00:00Z",
"startTime": "2019-05-04T00:00:00Z",
"totalCents": 0,
{
"partner": {
"analytics": {
"sales": {
"partnerId": "5748d153cd530e2d5100031c",
"timeSeries": [
{
"endTime": "2019-05-05T00:00:00Z",
"startTime": "2019-05-04T00:00:00Z",
"totalCents": 0,
},
{
"endTime": "2019-05-06T00:00:00Z",
"startTime": "2019-05-05T00:00:00Z",
"totalCents": 280000,
},
],
"totalCents": 3682500,
},
},
Object {
"endTime": "2019-05-06T00:00:00Z",
"startTime": "2019-05-05T00:00:00Z",
"totalCents": 280000,
},
],
"totalCents": 3682500,
},
},
},
}
`)
},
}
`)
})

it("exposes formatted total fields", async () => {
Expand Down Expand Up @@ -86,31 +86,31 @@ Object {
`
const result = await runQuery(query, context)
expect(result).toMatchInlineSnapshot(`
Object {
"partner": Object {
"analytics": Object {
"sales": Object {
"partnerId": "5748d153cd530e2d5100031c",
"timeSeries": Array [
Object {
"endTime": "2019-05-05T00:00:00Z",
"startTime": "2019-05-04T00:00:00Z",
"total": "0。000 ¥",
"totalCents": 0,
{
"partner": {
"analytics": {
"sales": {
"partnerId": "5748d153cd530e2d5100031c",
"timeSeries": [
{
"endTime": "2019-05-05T00:00:00Z",
"startTime": "2019-05-04T00:00:00Z",
"total": "0。000 ¥",
"totalCents": 0,
},
{
"endTime": "2019-05-06T00:00:00Z",
"startTime": "2019-05-05T00:00:00Z",
"total": "2|800。000 ¥",
"totalCents": 280000,
},
],
"total": "$36,825",
"totalCents": 3682500,
},
},
Object {
"endTime": "2019-05-06T00:00:00Z",
"startTime": "2019-05-05T00:00:00Z",
"total": "2|800。000 ¥",
"totalCents": 280000,
},
],
"total": "$36,825",
"totalCents": 3682500,
},
},
},
}
`)
},
}
`)
})
})
Loading

0 comments on commit c44dc3b

Please sign in to comment.