Skip to content

fix: version command refactor #1107

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

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4275134
fix: version command refactor
saragerion Sep 29, 2022
a574406
fix: captureMethod correctly detect method name when used with extern…
dreamorosi Oct 4, 2022
77025b2
chore(cicd): add lerna commands in github actions - PR checks
saragerion Oct 4, 2022
a3763d4
fix(cicd): lint & test commands for examples and layer
saragerion Oct 4, 2022
69d1fcc
fix(cicd): same cached modules for examples and layer PR lint
saragerion Oct 4, 2022
92a3e8d
fix(cicd): add foreground script to ci
saragerion Oct 4, 2022
83f6efb
feat: publish lib as Lambda Layer (#1095)
flochaz Oct 10, 2022
ee243de
fix: ts-node version for layer-publisher (#1112)
flochaz Oct 10, 2022
5f1da98
doc(layer): bump layer version to 2 to match the one built for latest…
flochaz Oct 11, 2022
0bb77af
Chore(tracer): unit tests to verify decorators await decorated class …
dreamorosi Oct 11, 2022
d4174eb
feat(tracer): specify subsegment name when capturing class method (#1…
dreamorosi Oct 11, 2022
3b5c799
chore(layer): fix bundling and e2e tests by manually setting hash of …
flochaz Oct 13, 2022
6f14fb3
fix(all): update version command to use lint-fix (#1119)
dreamorosi Oct 17, 2022
3a6d791
chore(release): v1.3.0 [skip ci]
github-actions[bot] Oct 17, 2022
9b52de4
docs: update layer version in docs (#1120)
dreamorosi Oct 17, 2022
652b7f0
docs: fix format issues (#1122)
dreamorosi Oct 17, 2022
13ec0c4
fix: version command refactor
saragerion Sep 29, 2022
9f65070
chore(cicd): add lerna commands in github actions - PR checks
saragerion Oct 4, 2022
bcab998
fix(cicd): lint & test commands for examples and layer
saragerion Oct 4, 2022
529c9f3
fix(cicd): same cached modules for examples and layer PR lint
saragerion Oct 4, 2022
cda0ee8
fix(cicd): add foreground script to ci
saragerion Oct 4, 2022
0c700d8
fix: merge conflicts
dreamorosi Oct 18, 2022
b9066a5
Revert "fix: merge conflicts"
dreamorosi Oct 18, 2022
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
8 changes: 8 additions & 0 deletions .github/workflows/pr-run-linting-check-and-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: On PR code update

on:
pull_request:
types: [opened, synchronize]
jobs:
run-linting-check-and-unit-tests:
uses: ./.github/workflows/reusable-run-linting-check-and-unit-tests.yml
8 changes: 0 additions & 8 deletions .github/workflows/pr_lint_and_test.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_call:

jobs:
run-unit-tests-on-utils:
run-linting-check-and-unit-tests:
runs-on: ubuntu-latest
env:
NODE_ENV: dev
Expand All @@ -29,21 +29,21 @@ jobs:
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') }}
key: ${{ matrix.version }}-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# We can skip the install if there was a cache hit
# We can skip the installation 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: 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
# post-install npm hook
if: steps.cache-node-modules.outputs.cache-hit == 'true'
run: |
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
- name: Run linting
run: npm run lint -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics
- name: Run unit tests
run: npm t -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics
Expand All @@ -55,9 +55,6 @@ jobs:
matrix:
example: ["sam", "cdk"]
fail-fast: false
defaults:
run:
working-directory: examples/${{ matrix.example }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -70,25 +67,20 @@ jobs:
id: cache-node-modules
uses: actions/cache@v3
with:
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') }}
path: "./node_modules"
key: cache-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# We can skip the install if there was a cache hit
# We can skip the installation if there was a cache hit
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
run: npm ci --foreground-scripts
- name: Run linting
run: npm run lerna -- run lint --scope ${{ matrix.example }}-example
- name: Run tests
run: npm t
run: npm run lerna -- run test --scope ${{ matrix.example }}-example
check-layer-publisher:
runs-on: ubuntu-latest
env:
NODE_ENV: dev
defaults:
run:
working-directory: layer-publisher
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -101,10 +93,11 @@ jobs:
id: cache-node-modules
uses: actions/cache@v3
with:
path: "./layer-publisher/node_modules"
# Use the combo between example, name, and SHA-256 hash of the layer-publisher lock files as cache key.
key: cache-layer-publisher-node-modules-${{ hashFiles('./layer-publisher/*/package-lock.json') }}
path: "./node_modules"
key: cache-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install Layer publisher
# We can skip the install if there was a cache hit
# We can skip the installation if there was a cache hit
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
run: npm ci --foreground-scripts
- name: Run linting
run: npm run lerna -- run lint --scope layer-publisher
1 change: 0 additions & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lerna-lint-fix
npm run test
Copy link
Contributor

@dreamorosi dreamorosi Oct 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change this to npm test -ws.

Currently, it will run npm run lerna-test which will run tests in all packages, examples, and layer-publisher.
If instead we changed it to the above we'd be running the unit tests only in packages/* and not in the others.

This is on line with what we discussed in the last conversation about the topic and is captured in #1106. If you want to keep this separate I can open a PR later on.

Aside from where the tests are run only difference between npm run test & npm test -ws is that npm workspaces still doesn't run in parallel but sequentially. I don't think it's a big deal at this stage, but if you want to run it in parallel you can use npm t -w packages/commons & npm t -w packages/logger & npm t -w packages/tracer & npm t -w packages/metrics instead.

2 changes: 1 addition & 1 deletion examples/cdk/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "cdk-app",
"name": "cdk-example",
"version": "1.2.1",
"author": {
"name": "Amazon Web Services",
Expand Down
2 changes: 1 addition & 1 deletion examples/sam/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "powertools-typescript-sam-example",
"name": "sam-example",
"version": "1.2.1",
"author": {
"name": "Amazon Web Services",
Expand Down
2 changes: 2 additions & 0 deletions layer-publisher/src/layer-publisher-stack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { CfnOutput, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as lambda from 'aws-cdk-lib/aws-lambda';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { LambdaPowertoolsLayer } from 'cdk-lambda-powertools-python-layer';
import { StringParameter } from 'aws-cdk-lib/aws-ssm';
import { CfnLayerVersionPermission } from 'aws-cdk-lib/aws-lambda';
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@
"test": "npm run lerna-test",
"commit": "commit",
"package": "npm run package",
"setup-local": "npm ci --foreground-scripts && cd examples/cdk && npm ci && cd ../.. && cd examples/sam && npm ci && cd ../.. && npm run init-environment",
"setup-local": "npm ci --foreground-scripts && cd examples/cdk && npm ci && cd ../../examples/sam && npm ci && cd ../../layer-publisher && npm ci && cd ../.. && npm run init-environment",
"lerna" : "lerna",
"lerna-test": "lerna exec -- npm run test",
"lerna-test:unit": "lerna exec -- npm run test:unit",
"lerna-test:e2e": "lerna exec -- npm run test:e2e",
"lerna-package": "lerna exec -- npm run package",
"lerna-package-bundle": "lerna exec -- npm run package-bundle",
"lerna-build": "lerna exec -- tsc",
"lerna-build": "lerna exec -- npm run build",
"lerna-lint": "lerna exec -- npm run lint",
"lerna-lint-fix": "lerna exec -- npm run lint-fix",
"lerna-prepare": "lerna exec -- npm run build",
"lerna-prepublishOnly": "lerna exec -- npm test && lerna exec -- npm run lint",
"lerna-preversion": "lerna exec -- npm run lint",
"lerna-version": "lerna exec -- npm run format && git add -A src",
"postversion": "git push && git push --tags",
"postversion": "git push --tags",
"docs-website-build-run": "npm run docs-buildDockerImage && npm run docs-runLocalDocker",
"docs-buildDockerImage": "docker build -t powertool-typescript/docs ./docs/",
"docs-runLocalDocker": "docker run --rm -it -p 8000:8000 -v ${PWD}:/docs powertool-typescript/docs",
Expand Down
5 changes: 1 addition & 4 deletions packages/commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
"package": "mkdir -p dist/ && npm pack && mv *.tgz dist/",
"package-bundle": "../../package-bundler.sh commons-bundle ./dist",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
"version": "npm run format && git add -A src",
"postversion": "git push && git push --tags"
"postversion": "git push --tags"
},
"homepage": "https://github.com/awslabs/aws-lambda-powertools-typescript/tree/master/packages/metrics#readme",
"license": "MIT-0",
Expand Down
5 changes: 1 addition & 4 deletions packages/idempotency/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
"package": "mkdir -p dist/ && npm pack && mv *.tgz dist/",
"package-bundle": "../../package-bundler.sh logger-bundle ./dist",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
"version": "npm run format && git add -A src",
"postversion": "git push && git push --tags"
"postversion": "git push --tags"
},
"homepage": "https://github.com/awslabs/aws-lambda-powertools-typescript/tree/master/packages/idempotency#readme",
"license": "MIT",
Expand Down
5 changes: 1 addition & 4 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
"package": "mkdir -p dist/ && npm pack && mv *.tgz dist/",
"package-bundle": "../../package-bundler.sh logger-bundle ./dist",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
"version": "npm run format && git add -A src",
"postversion": "git push && git push --tags"
"postversion": "git push --tags"
},
"homepage": "https://github.com/awslabs/aws-lambda-powertools-typescript/tree/master/packages/logging#readme",
"license": "MIT",
Expand Down
5 changes: 1 addition & 4 deletions packages/metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
"package": "mkdir -p dist/ && npm pack && mv *.tgz dist/",
"package-bundle": "../../package-bundler.sh metrics-bundle ./dist",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
"version": "npm run format && git add -A src",
"postversion": "git push && git push --tags"
"postversion": "git push --tags"
},
"homepage": "https://github.com/awslabs/aws-lambda-powertools-typescript/tree/master/packages/metrics#readme",
"license": "MIT-0",
Expand Down
5 changes: 1 addition & 4 deletions packages/tracer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
"lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests",
"lint-fix": "eslint --fix --ext .ts --no-error-on-unmatched-pattern src tests",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
"version": "npm run format && git add -A src",
"postversion": "git push && git push --tags",
"postversion": "git push --tags",
"package": "mkdir -p dist/ && npm pack && mv *.tgz dist/",
"package-bundle": "../../package-bundler.sh tracer-bundle ./dist"
},
Expand Down