Skip to content

chore(docs): bring examples into npm workspace #1434

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 11 commits into from
May 4, 2023
36 changes: 36 additions & 0 deletions .github/actions/cached-node-modules/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'Cached Node Modules'
description: 'A simple action to cache node_modules or install them if they are not cached'
inputs:
nodeVersion: # id of input
description: 'Node.js version to use in the cache key'
default: '18'
outputs:
cache-hit:
description: "Whether the cache was hit or not"
value: ${{ steps.cache-node-modules.outputs.cache-hit }}
runs:
using: "composite"
steps:
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
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: ${{ inputs.nodeVersion }}-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# 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
shell: bash
- 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
# 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 & npm run build -w packages/parameters & npm run build -w packages/idempotency
shell: bash
31 changes: 10 additions & 21 deletions .github/workflows/make-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,20 @@ jobs:
with:
node-version: "18"
cache: "npm"
- name: Setup npm
run: |
npm i -g npm@next-8
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
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: 18-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Build packages
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 & npm run build -w packages/parameters
- name: "Version and publish"
env:
GH_TOKEN: ${{ secrets.GH_PUBLISH_TOKEN }}
- name: Setup auth tokens
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/$GITHUB_REPOSITORY
npx lerna version --conventional-commits --force-publish --yes
git remote set-url origin https://x-access-token:${{ secrets.GH_PUBLISH_TOKEN }}@github.com/$GITHUB_REPOSITORY
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
- name: Setup dependencies
uses: ./.github/actions/cached-node-modules
- name: Version
run: |
npm run version
git push --tags
- name: Publish to npm
run: |
npx lerna publish from-git --yes
- name: Set release version
id: set-release-version
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/publish_layer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,8 @@ jobs:
LATEST_TAG=$(git describe --tag --abbrev=0)
RELEASE_TAG_VERSION=${RELEASE_INPUT:-$LATEST_TAG}
echo "RELEASE_TAG_VERSION=${RELEASE_TAG_VERSION:1}" >> $GITHUB_ENV
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
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: 18-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# 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: Setup dependencies
uses: ./.github/actions/cached-node-modules
- name: Create layer files
run: |
export VERSION=$RELEASE_TAG_VERSION
Expand Down
23 changes: 2 additions & 21 deletions .github/workflows/reusable-publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,8 @@ jobs:
with:
node-version: "18"
cache: "npm"
# 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
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
with:
path: "./node_modules"
key: 18-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# 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
# 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: Setup dependencies
uses: ./.github/actions/cached-node-modules
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
81 changes: 10 additions & 71 deletions .github/workflows/reusable-run-linting-check-and-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,11 @@ jobs:
node-version: ${{ matrix.version }}
cache: "npm"
- name: Setup npm
run: npm i -g npm@next-8
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
run: npm i -g npm@latest
- name: Setup dependencies
uses: ./.github/actions/cached-node-modules
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-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# 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
# 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 & npm run build -w packages/parameters & npm run build -w packages/idempotency
nodeVersion: ${{ matrix.version }}
- name: Run linting
run: npm run lint -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics -w packages/parameters -w packages/idempotency
- name: Run unit tests
Expand All @@ -66,20 +49,8 @@ jobs:
with:
node-version: 18
cache: "npm"
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
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') }}
- name: Install dependencies
# We can skip the installation if there was a cache hit
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Setup dependencies
uses: ./.github/actions/cached-node-modules
- name: Run linting
run: npm run lint
- name: Run tests
Expand All @@ -96,19 +67,8 @@ jobs:
with:
node-version: 18
cache: "npm"
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
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: 18-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# 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: Setup dependencies
uses: ./.github/actions/cached-node-modules
- name: Run linting
run: npm run lint -w layers
- name: Create layer files
Expand All @@ -129,28 +89,7 @@ jobs:
with:
node-version: 18
cache: "npm"
- name: Setup npm
run: npm i -g npm@next-8
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
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: 18-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# 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
# 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 & npm run build -w packages/parameters & npm run build -w packages/idempotency & npm run build -w docs/snippets
- name: Setup dependencies
uses: ./.github/actions/cached-node-modules
- name: Run linting
run: npm run lint -w docs/snippets
15 changes: 2 additions & 13 deletions .github/workflows/reusable_deploy_layer_stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
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: 18-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# 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: Setup dependencies
uses: ./.github/actions/cached-node-modules
- name: Download artifact
uses: actions/download-artifact@v3
with:
Expand Down
67 changes: 0 additions & 67 deletions examples/cdk/.eslintrc.js

This file was deleted.

4 changes: 3 additions & 1 deletion examples/cdk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ node_modules
# CDK asset staging directory
.cdk.staging
cdk.out
lib
lib
# npm lock file - this is managed by the npm workspace
package-lock.json
6 changes: 0 additions & 6 deletions examples/cdk/.npmignore

This file was deleted.

Loading