Skip to content

Commit

Permalink
Issue/232 switch to yarn / fix api gateway deps (#238)
Browse files Browse the repository at this point in the history
* issue/232 - Fix Peer Deps / Edge-Only Custom Name

Fixes #232
Fixes #231

* Update superchain image ref

* Remove unused patch

* Remove another patch, stop changing perms

* Install jsii

* Fix aws-cdk-lib version

* Fix org

* Try to fix deps

* Ugh

* try yarn to solve deps problem

* Remove --if-present

* remove types that get in the way

* Update projen

* Set test env for tests

* Extract version earlier

* Debugging

* Fix

* Fix

* Remove unused authorizer param

* Fix path to apps
  • Loading branch information
huntharo authored May 20, 2022
1 parent 394c47d commit ef66078
Show file tree
Hide file tree
Showing 42 changed files with 17,494 additions and 61,539 deletions.
96 changes: 50 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
outputs:
prSuffix: ${{ steps.prSuffix.outputs.prSuffix }}
prSuffixPackageVersion: ${{ steps.prSuffix.outputs.prSuffixPackageVersion }}
releaseAppPackageVersion: ${{ steps.appVersions.outputs.releaseAppPackageVersion }}
nextjsDemoAppPackageVersion: ${{ steps.appVersions.outputs.nextjsDemoAppPackageVersion }}
steps:
- uses: actions/checkout@v2

Expand All @@ -47,23 +49,36 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install Node Modules
run: npm ci
run: yarn install --frozen-lockfile

- name: Post Install Patch of api-gatewayv2
run: npm run postinstall
- name: Extract App NPM Versions
id: appVersions
run: |
# find . -type d -name microapps-app-nextjs-demo-cdk
echo 'NEXTJS_DEMO_APP_PACKAGE_VERSION='$(node -p -e "(require('./packages/cdk/node_modules/@pwrdrvr/microapps-app-nextjs-demo-cdk/package.json')).version") >> $GITHUB_ENV
echo 'RELEASE_APP_PACKAGE_VERSION='$(node -p -e "(require('./packages/cdk/node_modules/@pwrdrvr/microapps-app-release-cdk/package.json')).version") >> $GITHUB_ENV
echo "::set-output name=nextjsDemoAppPackageVersion::$(node -p -e "(require('./packages/cdk/node_modules/@pwrdrvr/microapps-app-nextjs-demo-cdk/package.json')).version")"
echo "::set-output name=releaseAppPackageVersion::$(node -p -e "(require('./packages/cdk/node_modules/@pwrdrvr/microapps-app-release-cdk/package.json')).version")"
- name: Versions
run: |
echo 'NEXTJS_DEMO_APP_PACKAGE_VERSION='${NEXTJS_DEMO_APP_PACKAGE_VERSION}
echo 'RELEASE_APP_PACKAGE_VERSION='${RELEASE_APP_PACKAGE_VERSION}
- name: Build All TypeScript
run: npm run build --if-present
run: yarn build

- name: Run Lint
run: npm run lint
run: yarn lint

- name: Run Node Tests
run: npm run test
env:
NODE_ENV: test
run: yarn test

deploy:
strategy:
Expand Down Expand Up @@ -108,19 +123,14 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install Node Modules
run: npm ci

- name: Extract App NPM Versions
run: |
echo 'RELEASE_APP_PACKAGE_VERSION='$(node -p -e "require('./node_modules/@pwrdrvr/microapps-app-release-cdk/package.json').version") >> $GITHUB_ENV
echo 'NEXTJS_DEMO_APP_PACKAGE_VERSION='$(node -p -e "require('./node_modules/@pwrdrvr/microapps-app-nextjs-demo-cdk/package.json').version") >> $GITHUB_ENV
run: yarn install --frozen-lockfile

- name: Build All TypeScript
run: npm run build --if-present
run: yarn build

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -132,13 +142,13 @@ jobs:
- name: Stitch Prefix into Nextjs Demo App
run: |
if [ -n "${PREFIX}" ] ; then
npx replace-in-file "/\/${NEXTJS_DEMO_APP_NAME}\/${NEXTJS_DEMO_APP_PACKAGE_VERSION}/g" ${PREFIX}/${NEXTJS_DEMO_APP_NAME}/${NEXTJS_DEMO_APP_PACKAGE_VERSION} --configFile=.nextjs-demo-replace.config.js --isRegex
npx replace-in-file "/\/${NEXTJS_DEMO_APP_NAME}\/${{ needs.build.outputs.nextjsDemoAppPackageVersion }}/g" ${PREFIX}/${NEXTJS_DEMO_APP_NAME}/${{ needs.build.outputs.nextjsDemoAppPackageVersion }} --configFile=.nextjs-demo-replace.config.js --isRegex
fi
- name: Stitch Prefix into Release App
run: |
if [ -n "${PREFIX}" ] ; then
npx replace-in-file "/\/${RELEASE_APP_NAME}\/${RELEASE_APP_PACKAGE_VERSION}/g" ${PREFIX}/${RELEASE_APP_NAME}/${RELEASE_APP_PACKAGE_VERSION} --configFile=.release-replace.config.js --isRegex
npx replace-in-file "/\/${RELEASE_APP_NAME}\/${{ needs.build.outputs.releaseAppPackageVersion }}/g" ${PREFIX}/${RELEASE_APP_NAME}/${{ needs.build.outputs.releaseAppPackageVersion }} --configFile=.release-replace.config.js --isRegex
fi
- name: Set Hotswap Flag
Expand Down Expand Up @@ -178,31 +188,31 @@ jobs:
- name: Publish Nextjs Demo App to MicroApps
run: |
npx microapps-publish publish -a ${NEXTJS_DEMO_APP_NAME} -n ${NEXTJS_DEMO_APP_PACKAGE_VERSION} -d ${DEPLOYER_LAMBDA_NAME} -l ${NEXTJS_DEMO_APP_LAMBDA_NAME} -s node_modules/@pwrdrvr/microapps-app-nextjs-demo-cdk/lib/.static_files/nextjs-demo/${NEXTJS_DEMO_APP_PACKAGE_VERSION}/ --overwrite --noCache
npx microapps-publish publish -a ${NEXTJS_DEMO_APP_NAME} -n ${{ needs.build.outputs.nextjsDemoAppPackageVersion }} -d ${DEPLOYER_LAMBDA_NAME} -l ${NEXTJS_DEMO_APP_LAMBDA_NAME} -s packages/cdk/node_modules/@pwrdrvr/microapps-app-nextjs-demo-cdk/lib/.static_files/nextjs-demo/${{ needs.build.outputs.nextjsDemoAppPackageVersion }}/ --overwrite --noCache
- name: Test Nextjs Demo App
run: |
echo Testing App Frame Loading
curl --fail https://${EDGE_DOMAIN}${PREFIX}/${NEXTJS_DEMO_APP_NAME}/
echo Testing App HTML Loading
curl --fail https://${EDGE_DOMAIN}${PREFIX}/${NEXTJS_DEMO_APP_NAME}/${NEXTJS_DEMO_APP_PACKAGE_VERSION}
curl --fail https://${EDGE_DOMAIN}${PREFIX}/${NEXTJS_DEMO_APP_NAME}/${{ needs.build.outputs.nextjsDemoAppPackageVersion }}
echo Testing Post Page Loading
curl --fail https://${EDGE_DOMAIN}${PREFIX}/${NEXTJS_DEMO_APP_NAME}/${NEXTJS_DEMO_APP_PACKAGE_VERSION}/posts/pre-rendering
curl --fail https://${EDGE_DOMAIN}${PREFIX}/${NEXTJS_DEMO_APP_NAME}/${{ needs.build.outputs.nextjsDemoAppPackageVersion }}/posts/pre-rendering
echo Testing Image Rendering
curl --fail -o /dev/null https://${EDGE_DOMAIN}${PREFIX}/${NEXTJS_DEMO_APP_NAME}/${NEXTJS_DEMO_APP_PACKAGE_VERSION}/_next/image?url=%2Fimages%2Fprofile.jpg&w=384&q=75
curl --fail -o /dev/null https://${EDGE_DOMAIN}${PREFIX}/${NEXTJS_DEMO_APP_NAME}/${{ needs.build.outputs.nextjsDemoAppPackageVersion }}/_next/image?url=%2Fimages%2Fprofile.jpg&w=384&q=75
- name: Publish Release App to MicroApps
run: |
npx microapps-publish publish -a ${RELEASE_APP_NAME} -n ${RELEASE_APP_PACKAGE_VERSION} -d ${DEPLOYER_LAMBDA_NAME} -l ${RELEASE_APP_LAMBDA_NAME} -s node_modules/@pwrdrvr/microapps-app-release-cdk/lib/.static_files/release/${RELEASE_APP_PACKAGE_VERSION}/ --overwrite --noCache
npx microapps-publish publish -a ${RELEASE_APP_NAME} -n ${{ needs.build.outputs.releaseAppPackageVersion }} -d ${DEPLOYER_LAMBDA_NAME} -l ${RELEASE_APP_LAMBDA_NAME} -s packages/cdk/node_modules/@pwrdrvr/microapps-app-release-cdk/lib/.static_files/release/${{ needs.build.outputs.releaseAppPackageVersion }}/ --overwrite --noCache
- name: Test Release App
run: |
echo Testing App Frame Loading
curl --fail https://${EDGE_DOMAIN}${PREFIX}/${RELEASE_APP_NAME}/
echo Testing App HTML Loading
curl --fail https://${EDGE_DOMAIN}${PREFIX}/${RELEASE_APP_NAME}/${RELEASE_APP_PACKAGE_VERSION}
curl --fail https://${EDGE_DOMAIN}${PREFIX}/${RELEASE_APP_NAME}/${{ needs.build.outputs.releaseAppPackageVersion }}
echo Testing App Method Invocation
curl --fail https://${EDGE_DOMAIN}${PREFIX}/${RELEASE_APP_NAME}/${RELEASE_APP_PACKAGE_VERSION}/api/refresh/${DEMO_APP_NAME}
curl --fail https://${EDGE_DOMAIN}${PREFIX}/${RELEASE_APP_NAME}/${{ needs.build.outputs.releaseAppPackageVersion }}/api/refresh/${DEMO_APP_NAME}
delete-apps:
if: github.event_name == 'pull_request' && false
Expand Down Expand Up @@ -236,19 +246,14 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install Node Modules
run: npm ci

- name: Extract App NPM Versions
run: |
echo 'RELEASE_APP_PACKAGE_VERSION='$(node -p -e "require('./node_modules/@pwrdrvr/microapps-app-release-cdk/package.json').version") >> $GITHUB_ENV
echo 'NEXTJS_DEMO_APP_PACKAGE_VERSION='$(node -p -e "require('./node_modules/@pwrdrvr/microapps-app-nextjs-demo-cdk/package.json').version") >> $GITHUB_ENV
run: yarn install --frozen-lockfile

- name: Build All TypeScript
run: npm run build --if-present
run: yarn build

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -263,11 +268,11 @@ jobs:
- name: Delete Nextjs Demo App from MicroApps
run: |
npx microapps-publish delete -a ${NEXTJS_DEMO_APP_NAME} -n ${RELEASE_APP_PACKAGE_VERSION} -d ${DEPLOYER_LAMBDA_NAME}
npx microapps-publish delete -a ${NEXTJS_DEMO_APP_NAME} -n ${{ needs.build.outputs.nextjsDemoAppPackageVersion }} -d ${DEPLOYER_LAMBDA_NAME}
- name: Delete Release App from MicroApps
run: |
npx microapps-publish delete -a ${RELEASE_APP_NAME} -n ${RELEASE_APP_PACKAGE_VERSION} -d ${DEPLOYER_LAMBDA_NAME}
npx microapps-publish delete -a ${RELEASE_APP_NAME} -n ${{ needs.build.outputs.releaseAppPackageVersion }} -d ${DEPLOYER_LAMBDA_NAME}
build-jsii:
runs-on: ubuntu-latest
Expand All @@ -278,33 +283,32 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install Node Modules
run: npm ci
run: yarn install --frozen-lockfile

# - name: Generate Projen Files
# working-directory: packages/microapps-cdk/
# run: |
# npx projen --version
# npm run projen
# yarn projen

- name: Modify microapps-cdk tsconfig.json
run: |
mv packages/microapps-cdk/tsconfig.json packages/microapps-cdk/tsconfig.jsii.json
jq ".compilerOptions += { \"skipLibCheck\": true }" packages/microapps-cdk/tsconfig.jsii.json > packages/microapps-cdk/tsconfig.json
- name: Build All TypeScript
run: npm run build --if-present
run: yarn build

# - name: Move root modules out of the way for CDK Construct build
# run: mv node_modules node_modules_hide

- name: Install CDK Construct Deps
working-directory: packages/microapps-cdk/
run: |
npm ci
run: yarn install --frozen-lockfile

# - name: Post Install Patch of api-gatewayv2
# working-directory: packages/microapps-cdk/
Expand All @@ -313,10 +317,10 @@ jobs:
- name: Build CDK Construct
working-directory: packages/microapps-cdk/
run: |
npm run build
yarn build
- name: Confirm No Doc Changes
working-directory: packages/microapps-cdk/
run: |
npm run post-compile
yarn post-compile
git diff --ignore-space-at-eol --exit-code
46 changes: 25 additions & 21 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,39 +35,40 @@ jobs:
git config user.name "Automation"
git config user.email "[email protected]"
- name: Fix Permissions
run: |
chown -R root ./
chmod -R 777 ./
# - name: Fix Permissions
# run: |
# chown -R root ./
# chmod -R 777 ./

- name: Use Node.js 16
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install dependencies
run: npm ci
run: yarn install --frozen-lockfile

# - name: Generate Projen Files
# working-directory: packages/microapps-cdk/
# run: |
# npm run projen
# yarn projen

- name: Build All TypeScript
run: npm run build --if-present
run: yarn build

- name: Run Node Tests
run: npm run test
env:
NODE_ENV: test
run: yarn test

# - name: Move root NPM modules out of the way
# run: mv node_modules node_modules_hide

- name: Install CDK Construct Deps
working-directory: packages/microapps-cdk/
run: |
npm ci
run: yarn install

# - name: Post Install Patch of api-gatewayv2
# working-directory: packages/microapps-cdk/
Expand All @@ -76,7 +77,7 @@ jobs:
- name: Build CDK Construct
working-directory: packages/microapps-cdk/
run: |
npm run build
yarn build
- name: Check for new commits
id: git_remote
Expand All @@ -90,7 +91,9 @@ jobs:
name: cdk-construct-dist
path: packages/microapps-cdk/dist
container:
image: jsii/superchain
# https://hub.docker.com/r/jsii/superchain
image: jsii/superchain:1-buster-slim-node16


#
# Publish Tool
Expand All @@ -109,27 +112,27 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Check for new commits
id: git_remote
run: echo ::set-output name=latest_commit::"$(git ls-remote origin -h ${{
github.ref }} | cut -f1)"

- name: Install Node Modules
run: npm ci
run: yarn install --frozen-lockfile

# - name: Generate Projen Files
# working-directory: packages/microapps-cdk/
# run: |
# npm run projen
# yarn projen

- name: Build Publish TypeScript
run: npm run build:publish --if-present
run: yarn build:publish

- name: Run Lint
run: npm run lint
run: yarn lint

- name: Upload Publish Tool artifact
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -194,4 +197,5 @@ jobs:
npm publish --dry-run
container:
image: jsii/superchain
# https://hub.docker.com/r/jsii/superchain
image: jsii/superchain:1-buster-slim-node16
Loading

0 comments on commit ef66078

Please sign in to comment.