-
Notifications
You must be signed in to change notification settings - Fork 32
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
Chore: Add Circle CI #32
Changes from all commits
b335c79
16614da
1de84d9
f8611ae
f34c021
c148f88
4dcfc8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
version: 2.1 | ||
|
||
executors: | ||
node-executor: | ||
working_directory: ~/repo | ||
docker: | ||
# Jest has issues with node > 16.11.0, please stick node version until the issues are resolved | ||
# https://github.com/facebook/jest/issues/11956 | ||
- image: cimg/node:16.10.0 | ||
|
||
# Set some environment variables like the base SHA of PRs ...etc. | ||
set_env: &set_env | ||
name: Setup Environment Variables | ||
command: | | ||
|
||
echo 'Fetching Base Commit from GitHub' | ||
# Get the PR number from env for different kinds of PR | ||
echo 'export CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"' >> $BASH_ENV | ||
source $BASH_ENV | ||
# Obtain the SHA via Github API | ||
echo "export CIRCLE_PR_BASE_SHA=`curl -s https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${CIRCLE_PR_NUMBER} | jq -r '.base.sha'`" >> $BASH_ENV | ||
# Set the affected args for nx affect xxx commands | ||
echo 'export AFFECTED_ARGS="--base=${CIRCLE_PR_BASE_SHA}"' >> $BASH_ENV | ||
# Set the memory size for node processes | ||
echo 'export NODE_OPTIONS="--max_old_space_size=6144"' >> $BASH_ENV | ||
source $BASH_ENV | ||
echo $AFFECTED_ARGS | ||
|
||
# Retrieve node_modules and the module cache from Circle CI storage. | ||
yarn_cache: &yarn_cache | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
keys: | ||
- node-deps-node16-{{ checksum "yarn.lock" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- node-deps-node16- | ||
|
||
# Install node modules via yarn with the frozen lock file | ||
yarn_install: &yarn_install | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
name: Install Dependencies | ||
command: yarn install --frozen-lockfile --non-interactive | ||
|
||
# Install code cov uploader and check the signature | ||
# https://docs.codecov.com/docs/codecov-uploader | ||
codecov_install: &codecov_install | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great for adding the codecov for showing code coverage after each PR changed and tested 👍 Maybe you could rename the NIT: If possible, maybe we could use circleci codecov orb which like GitHub Action, for making it simple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The script here downloads the binary file from codecov and check the signature, It doesn't upload any data~ We upload data in the last step of test job:
To use 3rd party orb we need to update our organization security policy, it might affect other projects of Canner, so I download the file manually. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohoh, got it! |
||
name: Install codecov | ||
command: | | ||
if [ ! -f ./codecov ]; then | ||
curl -Os https://uploader.codecov.io/v0.1.0_4653/linux/codecov | ||
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import # One-time step | ||
curl -Os https://uploader.codecov.io/latest/linux/codecov | ||
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM | ||
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig | ||
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM | ||
shasum -a 256 -c codecov.SHA256SUM | ||
chmod +x codecov | ||
fi | ||
|
||
jobs: | ||
install: | ||
executor: node-executor | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
<<: *yarn_cache | ||
- run: | ||
<<: *yarn_install | ||
- save_cache: | ||
key: node-deps-node16-{{ checksum "yarn.lock" }} | ||
paths: | ||
- ~/.cache | ||
- node_modules | ||
- restore_cache: | ||
keys: | ||
- codecov-0.1.0_4653 | ||
- run: | ||
<<: *codecov_install | ||
- save_cache: | ||
key: codecov-0.1.0_4653 | ||
paths: | ||
- ./codecov | ||
|
||
lint: | ||
executor: node-executor | ||
steps: | ||
- checkout | ||
- run: | ||
<<: *set_env | ||
- restore_cache: | ||
<<: *yarn_cache | ||
- run: yarn nx workspace-lint | ||
- run: yarn nx affected --target=lint --head=HEAD --maxWarnings=0 ${AFFECTED_ARGS} | ||
|
||
test: | ||
executor: node-executor | ||
steps: | ||
- checkout | ||
- run: | ||
<<: *set_env | ||
- restore_cache: | ||
<<: *yarn_cache | ||
- restore_cache: | ||
keys: | ||
- codecov-0.1.0_4653 | ||
- run: yarn nx affected --target=test --head=HEAD --ci --coverage --maxWorkers=2 --coverageReporters=lcov ${AFFECTED_ARGS} | ||
# --maxWorkers=2 is required because we'll run virtual machine with 32 cores CPU (with actually 4 CPI), jest spawns lots of workers if we don't fix the worker size. | ||
# https://support.circleci.com/hc/en-us/articles/360005442714-Your-test-tools-are-smart-and-that-s-a-problem-Learn-about-when-optimization-goes-wrong- | ||
- run: ./codecov -t ${CODECOV_TOKEN} | ||
|
||
workflows: | ||
version: 2 | ||
pr-check: | ||
jobs: | ||
- install | ||
- lint: | ||
requires: | ||
- install | ||
- test: | ||
requires: | ||
- install |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,19 @@ | |
"sourceTag": "*", | ||
"onlyDependOnLibsWithTags": ["*"] | ||
} | ||
] | ||
], | ||
"allowCircularSelfDependency": true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, why did we add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NX linter blocks the relative imports from ourself if this value = false, e.g. "@vulcan-sql/core/model" from core package. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see, thanks for sharing the source code 🤣 and replying my question 👍 |
||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"extends": ["plugin:@nrwl/nx/typescript"], | ||
"rules": {} | ||
"rules": { | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off" | ||
} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { | ||
DataSource, | ||
PreparedQueryParams, | ||
Pagination, | ||
BindParameters, | ||
} from '@vulcan-sql/core/models'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting to add a simple comment to hint you will use the
set_env
variable which defined some steps options in below steps of jobs.