Skip to content

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 7 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/measure-packages-size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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:
- name: Checkout Repo
uses: actions/checkout@v3
- 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 && npm run package-bundle -w packages/logger -w packages/tracer -w packages/metrics && bash -c "mv ./packages/*/dist/* dist/" && ls dist
dist-directory: /dist
pr-number: ${{ inputs.prNumber }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84 changes: 31 additions & 53 deletions .github/workflows/pr_lint_and_test.yml
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
Expand All @@ -12,63 +13,40 @@ 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 npm@8.x
- 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: Install dependencies
# 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
- 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:
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
node-version: 16
- name: Install dependencies
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]' }}
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]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lcov-file: ./coverage/lcov.info
- name: Packages size report
uses: flochaz/[email protected]
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 }}
run: npm t
23 changes: 22 additions & 1 deletion examples/sam/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/sam/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"devDependencies": {
"@types/aws-lambda": "^8.10.86",
"@types/jest": "^27.5.2",
Copy link
Contributor Author

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 the examples/cdk and the main package) is also needed here now.

"@types/node": "18.0.0",
"esbuild": "^0.14.23",
"eslint": "^8.4.0",
Expand All @@ -32,4 +33,4 @@
"@aws-lambda-powertools/tracer": "^1.0.1",
"aws-sdk": "^2.1122.0"
}
}
}