-
Notifications
You must be signed in to change notification settings - Fork 153
chore(build): broke up pr workflow & measure package size #1031
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1585596
chore: broke up pr workflow & measure package size
dreamorosi 0db209f
chore: explicitly set packages where to run cmds
dreamorosi 75df9a3
fix: added missing dependency to examples/sam
dreamorosi 736dbf6
added cache in workflow
dreamorosi b108cfd
chore: updated workflow + removed env var from command
dreamorosi 017c999
chore: updated action version
dreamorosi 8e303d9
fix: removed redundant env variable
dreamorosi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Measure packages size | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
prNumber: | ||
description: "PR Number" | ||
required: true | ||
|
||
jobs: | ||
measure-utils-sizes: | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_ENV: dev | ||
PR_NUMBER: ${{ inputs.prNumber }} | ||
steps: | ||
# Since we are manually triggering the workflow the previous checkout has the main branch. In order to checkout the branch/code of the PR | ||
# we need first to use the PR number to retrieve the PR SHA number. This means we need three steps to: checkout the repo, | ||
# run a custom script to get the SHA, and then finally checkout the PR branch | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
- name: Extract PR details | ||
id: extract_PR_details | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const script = require('.github/scripts/get_pr_info.js'); | ||
await script({github, context, core}); | ||
- name: Checkout PR code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ steps.extract_PR_details.outputs.headSHA }} | ||
- name: Packages size report | ||
uses: flochaz/[email protected] | ||
with: | ||
build-command: mkdir dist && npm run package -w packages/logger -w packages/tracer -w packages/metrics -w packages/commons && npm run package-bundle -w packages/logger -w packages/tracer -w packages/metrics -w packages/commons && bash -c "mv ./packages/*/dist/* dist/" && ls dist | ||
dist-directory: /dist | ||
pr-number: ${{ inputs.prNumber }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
name: pr-lint-and-test | ||
name: On PR code update | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
jobs: | ||
on_push: | ||
run-unit-tests-on-utils: | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_ENV: dev | ||
|
@@ -12,63 +13,70 @@ jobs: | |
version: [12, 14, 16] | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: "Use NodeJS" | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.version }} | ||
- name: Install [email protected] | ||
cache: "npm" | ||
- name: Setup npm | ||
run: npm i -g npm@next-8 | ||
- name: "Setup npm" | ||
run: | | ||
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" | ||
- name: Install monorepo packages | ||
# This installs all the dependencies of ./packages/* | ||
- name: Cache node modules | ||
id: cache-node-modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: "./node_modules" | ||
# Use the combo between node version, name, and SHA-256 hash of the lock file as cache key so that | ||
# if one of them changes the cache is invalidated/discarded | ||
key: ${{ matrix.version }}-cache-utils-node-modules-${{ hashFiles('./package-lock.json') }} | ||
- name: Install dependencies | ||
# We can skip the install if there was a cache hit | ||
if: steps.cache-node-modules.outputs.cache-hit != 'true' | ||
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts | ||
run: npm ci --foreground-scripts | ||
- name: Install CDK example packages | ||
# Since we are not managing the CDK examples with npm workspaces we install | ||
# the dependencies in a separate step | ||
working-directory: ./examples/cdk | ||
run: npm ci | ||
- name: "Setup SAM" | ||
# We use an ad-hoc action so we can specify the SAM CLI version | ||
uses: aws-actions/setup-sam@v2 | ||
with: | ||
version: 1.49.0 | ||
- name: Install SAM example packages | ||
# Since we are not managing the SAM examples with npm workspaces we install | ||
# the dependencies in a separate step | ||
working-directory: ./examples/sam | ||
run: npm ci | ||
- name: Run lint | ||
run: npm run lerna-lint | ||
- name: Run tests | ||
run: npm run lerna-test | ||
- name: Collate Coverage Reports | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
- name: Build packages | ||
# If there's a cache hit we still need to manually build the packages | ||
# this would otherwise have been done automatically as a part of the | ||
# postinstall npm hook | ||
if: steps.cache-node-modules.outputs.cache-hit == 'true' | ||
run: | | ||
for d in ./packages/*/ ; do | ||
mkdir -p coverage | ||
if [[ ! -f coverage/lcov.info ]] | ||
then | ||
continue | ||
fi | ||
filename="$d""coverage/lcov.info" | ||
targetSource="SF:""$d""src" | ||
sed "s|SF:src|$targetSource|g" $filename >> coverage/lcov.info | ||
done | ||
- name: Report Coverage | ||
#Dependabot user will only have read-only perms, so don't try to report coverage | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
uses: romeovs/[email protected] | ||
npm run build -w packages/commons | ||
npm run build -w packages/logger & npm run build -w packages/tracer & npm run build -w packages/metrics | ||
- name: Lint | ||
run: npm run lint -w packages/logger -w packages/tracer -w packages/metrics | ||
- name: Run unit tests | ||
run: npm t -w packages/logger -w packages/tracer -w packages/metrics | ||
check-examples: | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_ENV: dev | ||
strategy: | ||
matrix: | ||
example: ["sam", "cdk"] | ||
fail-fast: false | ||
defaults: | ||
run: | ||
working-directory: examples/${{ matrix.example }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v3 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
lcov-file: ./coverage/lcov.info | ||
- name: Packages size report | ||
uses: flochaz/[email protected] | ||
node-version: 16 | ||
cache: "npm" | ||
- name: Cache node modules | ||
id: cache-node-modules | ||
uses: actions/cache@v3 | ||
with: | ||
build-command: mkdir dist && npm run lerna-package && npm run lerna-package-bundle && bash -c "mv ./packages/*/dist/* dist/" && ls dist | ||
dist-directory: /dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
path: "./examples/${{ matrix.example }}/node_modules" | ||
# Use the combo between example, name, and SHA-256 hash of all example lock files as cache key. | ||
# It's not possible to use the ${{ matrix.example }} key in the hashFiles fn so | ||
# if any of the lock files (wich should be fairly similar anyway) changes the cache is | ||
# invalidated/discarded for all. | ||
key: ${{ matrix.example }}-cache-examples-node-modules-${{ hashFiles('./examples/*/package-lock.json') }} | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Run tests | ||
run: npm t |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 file contains 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 file contains 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 file contains 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 file contains 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This change is needed because we are now running the tests outside of the
lerna
scope. For this reason the dependency (which is present in both theexamples/cdk
and the main package) is also needed here now.