Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit 9bf19c2

Browse files
authored
chore(ci): use circleci for builds (#2098)
1 parent 984e31a commit 9bf19c2

File tree

5 files changed

+189
-96
lines changed

5 files changed

+189
-96
lines changed

.circleci/config.yml

+129-55
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@ version: 2.1
55
aliases:
66
- &environment
77
TZ: /usr/share/zoneinfo/America/Los_Angeles
8+
NODE_OPTIONS: "--max-old-space-size=6144"
89

910
executors:
10-
linux:
11+
linux-node-14-browsers:
1112
resource_class: medium+
1213
docker:
1314
- image: cimg/node:14.18-browsers
15+
linux-node-14:
16+
resource_class: large
17+
docker:
18+
- image: cimg/node:14.18
19+
linux-node-12:
20+
resource_class: large
21+
docker:
22+
- image: cimg/node:12.22.7
1423
windows: win/default
1524

1625
orbs:
@@ -22,26 +31,91 @@ orbs:
2231
# Define a job to be invoked later in a workflow.
2332
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
2433
jobs:
34+
build-and-test:
35+
parameters:
36+
executor:
37+
type: string
38+
executor: << parameters.executor >>
39+
environment: *environment
40+
steps:
41+
- checkout
42+
43+
- restore_cache:
44+
name: Restore yarn cache
45+
keys:
46+
- v3-node-{{ arch }}-<< parameters.executor >>-build-{{ checksum "yarn.lock" }}
47+
- v3-node-{{ arch }}-<< parameters.executor >>-build-
48+
49+
- run:
50+
name: Setup yarn
51+
command: yarn install --immutable --inline-builds
52+
53+
- run:
54+
name: Run yarn build
55+
command: yarn build
56+
57+
- when:
58+
condition:
59+
equal: [<< pipeline.git.branch >>, "master"]
60+
environment:
61+
AWS_DEFAULT_REGION: us-east-1
62+
GITHUB_SHA: << pipeline.git.revision >>
63+
steps:
64+
- run:
65+
name: Upload handler sizes to S3
66+
command: yarn handlers:upload-handler-sizes
67+
68+
- run:
69+
name: Run unit tests
70+
command: yarn test:ci
71+
environment:
72+
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/unit-tests
73+
74+
- run:
75+
name: Run integration tests
76+
command: yarn integration:ci
77+
environment:
78+
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/integration-tests
79+
80+
- run:
81+
name: Upload code coverage
82+
command: npx codecov
83+
84+
- store_test_results:
85+
path: ./reports/junit/unit-tests
86+
87+
- store_test_results:
88+
path: ./reports/junit/integration-tests
89+
90+
- store_artifacts:
91+
path: ./reports/junit
92+
93+
- save_cache:
94+
name: Save yarn cache
95+
key: v3-node-{{ arch }}-<< parameters.executor >>-build-{{ checksum "yarn.lock" }}
96+
paths:
97+
- ~/project/.yarn/cache
98+
2599
run-e2e-tests:
26100
parameters:
27-
os:
101+
executor:
28102
type: string
29103
app:
30104
type: string
31-
executor: << parameters.os >>
105+
executor: << parameters.executor >>
32106
environment: *environment
33107
steps:
34108
- checkout
35109

36110
- when:
37111
condition:
38-
equal: [<< parameters.os >>, "linux"]
112+
equal: [<< parameters.executor >>, "linux-node-14-browsers"]
39113
steps:
40114
- aws-cli-linux/install
41115

42116
- when:
43117
condition:
44-
equal: [<< parameters.os >>, "windows"]
118+
equal: [<< parameters.executor >>, "windows"]
45119
steps:
46120
- run:
47121
name: Install AWS CLI v1
@@ -55,21 +129,15 @@ jobs:
55129

56130
- run:
57131
name: Setup yarn
58-
environment:
59-
NODE_OPTIONS: "--max-old-space-size=6144"
60132
command: yarn install --immutable --inline-builds
61133

62134
- run:
63135
name: Run yarn build
64-
environment:
65-
NODE_OPTIONS: "--max-old-space-size=6144"
66136
command: yarn build
67137

68138
- run:
69139
name: Build serverless-patched
70140
working_directory: ~/project/packages/serverless-patched
71-
environment:
72-
NODE_OPTIONS: "--max-old-space-size=6144"
73141
command: |
74142
yarn install --immutable
75143
yarn build
@@ -91,64 +159,70 @@ jobs:
91159
environment:
92160
AWS_DEFAULT_REGION: us-east-1
93161
WAIT_TIMEOUT: 900
94-
NODE_OPTIONS: "--max-old-space-size=6144"
95162
SERVERLESS_CI: true
96163
command: |
97164
yarn install --immutable
98165
yarn e2e:ci
99166
no_output_timeout: 30m # In case something goes wrong
100167

101168
- save_cache:
102-
name: Save yarn cache for future installs
169+
name: Save yarn cache
103170
key: v3-node-{{ arch }}-<< parameters.app >>-{{ checksum "yarn.lock" }}
104171
paths:
105172
- ~/project/.yarn/cache
106173

107174
# Invoke jobs via workflows
108175
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
109176
workflows:
110-
e2e-tests:
177+
build:
111178
jobs:
112-
- queue/block_workflow:
113-
consider-branch: false
114-
time: "90"
115-
filters:
116-
branches:
117-
ignore: /renovate\/.*/
118-
- run-e2e-tests:
119-
filters:
120-
branches:
121-
ignore: /renovate\/.*/
122-
requires:
123-
- queue/block_workflow
124-
matrix:
125-
parameters:
126-
os:
127-
- linux
128-
app:
129-
# Current minor version of Next.js
130-
- next-app
131-
- next-app-experimental
132-
- next-app-using-serverless-trace
133-
- next-app-with-trailing-slash
134-
- next-app-with-base-path
135-
- next-app-dynamic-routes
136-
- next-app-with-locales
137-
- next-app-with-locales-using-serverless-trace
138-
# Previous minor version of Next.js
139-
- prev-next-app
140-
- prev-next-app-with-trailing-slash
141-
- prev-next-app-with-base-path
142-
- prev-next-app-dynamic-routes
143-
- run-e2e-tests:
144-
filters:
145-
branches:
146-
ignore: /renovate\/.*/
147-
requires:
148-
- queue/block_workflow
179+
- build-and-test:
149180
matrix:
150181
parameters:
151-
os:
152-
- windows
153-
app:
154-
- next-app-windows
182+
executor:
183+
- linux-node-14
184+
- linux-node-12
185+
# e2e-tests:
186+
# - queue/block_workflow:
187+
# consider-branch: false
188+
# time: "90"
189+
# filters:
190+
# branches:
191+
# ignore: /renovate\/.*/
192+
# - run-e2e-tests:
193+
# filters:
194+
# branches:
195+
# ignore: /renovate\/.*/
196+
# requires:
197+
# - queue/block_workflow
198+
# matrix:
199+
# parameters:
200+
# executor:
201+
# - linux-node-14-browsers
202+
# app:
203+
# # Current minor version of Next.js
204+
# - next-app
205+
# - next-app-experimental
206+
# - next-app-using-serverless-trace
207+
# - next-app-with-trailing-slash
208+
# - next-app-with-base-path
209+
# - next-app-dynamic-routes
210+
# - next-app-with-locales
211+
# - next-app-with-locales-using-serverless-trace
212+
# # Previous minor version of Next.js
213+
# - prev-next-app
214+
# - prev-next-app-with-trailing-slash
215+
# - prev-next-app-with-base-path
216+
# - prev-next-app-dynamic-routes
217+
# - run-e2e-tests:
218+
# filters:
219+
# branches:
220+
# ignore: /renovate\/.*/
221+
# requires:
222+
# - queue/block_workflow
223+
# matrix:
224+
# parameters:
225+
# executor:
226+
# - windows
227+
# app:
228+
# - next-app-windows

.github/workflows/CI.yml

+35-40
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [12.x, 14.x]
19+
node-version: [14.x]
2020

2121
steps:
22-
# - name: Cancel Previous Runs
23-
# uses: styfle/[email protected]
24-
# with:
25-
# access_token: ${{ github.token }}
26-
2722
- uses: actions/checkout@v2
2823

2924
- name: Use Node.js ${{ matrix.node-version }}
@@ -55,16 +50,16 @@ jobs:
5550
AWS_DEFAULT_REGION: us-east-1
5651
GITHUB_SHA: ${{ github.sha }}
5752
run: yarn handlers:upload-handler-sizes
58-
59-
- run: yarn test
60-
61-
- run: yarn integration
62-
63-
- name: Upload code coverage
64-
if: ${{ matrix.node-version == '14.x' }}
65-
env:
66-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
67-
run: npx codecov
53+
#
54+
# - run: yarn test
55+
#
56+
# - run: yarn integration
57+
#
58+
# - name: Upload code coverage
59+
# if: ${{ matrix.node-version == '14.x' }}
60+
# env:
61+
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
62+
# run: npx codecov
6863

6964
- name: Calculate and post handler sizes
7065
if: (matrix.node-version == '14.x' && github.event_name == 'pull_request')
@@ -73,28 +68,28 @@ jobs:
7368
GITHUB_BASE_SHA: ${{ github.event.pull_request.base.sha }}
7469
PULL_REQUEST_ID: ${{ github.event.number }}
7570
run: yarn handlers:comment-handler-sizes
76-
# start-e2e-tests:
77-
# # Note: we only run e2e tests automatically if this is a push on master or if PR is not from a fork or renovate, as forks won't have access to secrets
78-
# if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'renovate/') == false && github.event.pull_request.head.repo.full_name == github.repository) }}
79-
# runs-on: ubuntu-latest
80-
81-
# steps:
82-
# - name: Mark end-to-end tests as pending
83-
# uses: Sibz/github-status-action@v1
84-
# with:
85-
# authToken: ${{ secrets.GITHUB_TOKEN }}
86-
# context: "End-to-end Tests"
87-
# description: "Waiting for end-to-end tests to pass"
88-
# state: "pending"
89-
# sha: ${{ github.event.pull_request.head.sha || github.sha }}
71+
start-e2e-tests:
72+
# Note: we only run e2e tests automatically if this is a push on master or if PR is not from a fork or renovate, as forks won't have access to secrets
73+
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'renovate/') == false && github.event.pull_request.head.repo.full_name == github.repository) }}
74+
runs-on: ubuntu-latest
9075

91-
# - name: Trigger end-to-end tests workflow
92-
# uses: benc-uk/workflow-dispatch@v1
93-
# with:
94-
# workflow: End-to-end Tests
95-
# token: ${{ secrets.BOT_GITHUB_TOKEN }}
96-
# ref: ${{ github.event.pull_request.head.ref || github.ref }}
97-
# # FIXME: Passing sha doesn't seem to work, created GitHub ticket here: https://github.community/t/workflow-dispatch-cant-set-ref-to-commit-sha/138132
98-
# # So for now we pass in SHA as an input
99-
# # ref: ${{ github.event.pull_request.head.sha || github.sha }}
100-
# inputs: '{"sha": "${{ github.event.pull_request.head.sha || github.sha }}"}'
76+
steps:
77+
- name: Mark end-to-end tests as pending
78+
uses: Sibz/github-status-action@v1
79+
with:
80+
authToken: ${{ secrets.GITHUB_TOKEN }}
81+
context: "End-to-end Tests"
82+
description: "Waiting for end-to-end tests to pass"
83+
state: "pending"
84+
sha: ${{ github.event.pull_request.head.sha || github.sha }}
85+
86+
- name: Trigger end-to-end tests workflow
87+
uses: benc-uk/workflow-dispatch@v1
88+
with:
89+
workflow: End-to-end Tests
90+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
91+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
92+
# FIXME: Passing sha doesn't seem to work, created GitHub ticket here: https://github.community/t/workflow-dispatch-cant-set-ref-to-commit-sha/138132
93+
# So for now we pass in SHA as an input
94+
# ref: ${{ github.event.pull_request.head.sha || github.sha }}
95+
inputs: '{"sha": "${{ github.event.pull_request.head.sha || github.sha }}"}'

jest.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ module.exports = {
5151
setupFiles: ["<rootDir>/jest.setup.js"],
5252
modulePathIgnorePatterns: ["/sharp_node_modules/"],
5353
testSequencer: "<rootDir>/jest-sequencer.js",
54-
modulePaths: ["<rootDir>/packages/libs/lambda"] // this allows us to use absolute imports from these packages
54+
modulePaths: ["<rootDir>/packages/libs/lambda"], // this allows us to use absolute imports from these packages
55+
reporters: ["default", "jest-junit"]
5556
};

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
"scripts": {
1717
"prepack": "husky install",
1818
"test": "jest --runInBand --coverage",
19+
"test:ci": "jest --runInBand --coverage --ci --reporters=default --reporters=jest-junit",
1920
"test:watch": "yarn test --watch --collect-coverage=false",
2021
"check-gh-token": ": \"${GH_TOKEN:?Please set GH_TOKEN to a GitHub personal token that can create releases.}\"",
2122
"prerelease": "lerna publish --conventional-commits --conventional-prerelease --exact --create-release github --dist-tag alpha",
2223
"graduate": "lerna publish --conventional-commits --conventional-graduate --exact --create-release github",
2324
"publish-from-git": "lerna publish --exact from-git",
2425
"lint": "eslint .",
2526
"integration": "jest --runInBand --config jest.integration.config.json --setupTestFrameworkScriptFile=./jest.integration.setup.js",
27+
"integration:ci": "jest --runInBand --config jest.integration.config.json --setupTestFrameworkScriptFile=./jest.integration.setup.js --ci --reporters=default --reporters=jest-junit",
2628
"build": "lerna run build && opencollective-postinstall",
2729
"clean": "lerna run clean",
2830
"docs": "cd documentation && yarn && yarn build",
@@ -56,6 +58,7 @@
5658
"eslint-plugin-promise": "5.1.1",
5759
"husky": "^7.0.4",
5860
"jest": "^27.3.1",
61+
"jest-junit": "^13.0.0",
5962
"jest-pnp-resolver": "^1.2.2",
6063
"lerna": "^4.0.0",
6164
"lint-staged": "^12.1.1",

0 commit comments

Comments
 (0)