From 27d0eb0f0757582fc057072ef2017b006c8f8b25 Mon Sep 17 00:00:00 2001 From: Daniel Schroeder Date: Wed, 10 Apr 2024 11:55:19 +0200 Subject: [PATCH] ci: Fix publish (#114) --- .github/workflows/publish.yml | 5 ++++- .github/workflows/test.yml | 12 +++++++++++- .npmignore | 1 + Makefile | 18 ++++++++++++++++++ package.json | 6 +++++- test/Makefile | 3 +-- test/lib/index.ts | 3 +-- 7 files changed, 41 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dfcda29..051d7a4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,7 +31,10 @@ jobs: sudo apt-get install -y tree - name: Build source w/ jsii - run: npx jsii + run: | + lambda/build + npx jsii + make validate-package - name: Build packages w/ jsii-pacmak run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 04b8cf1..f4a8b80 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,10 +50,20 @@ jobs: run: | set -euo pipefail make install - (cd test && make install) sudo apt-get update sudo apt-get install -y tree + - name: Build source w/ jsii + run: | + lambda/build + npx jsii + make validate-package + + - name: Install test dependencies + run: | + cd test + make install + - name: Deploy & Destroy run: cd test && make deploy DESTROY env: diff --git a/.npmignore b/.npmignore index fa8244c..df18fc8 100644 --- a/.npmignore +++ b/.npmignore @@ -29,3 +29,4 @@ tsconfig* lambda/* !lambda/code.zip .npm +publish_output.txt diff --git a/Makefile b/Makefile index cb42f6a..9d0596f 100644 --- a/Makefile +++ b/Makefile @@ -22,3 +22,21 @@ eslint: @echo -e "$(TARGET_COLOR)Running eslint $$(npx eslint --version)$(NO_COLOR)" @npx eslint .; \ echo "Passed" + +validate-package: + @echo -e "$(TARGET_COLOR)Checking package content$(NO_COLOR)" + @npm publish --dry-run 2>&1 | tee publish_output.txt + @\ + FILES_TO_CHECK="lambda/code.zip lib/index.d.ts lib/index.js lib/lambda.d.ts lib/lambda.js lib/namedQuery.d.ts lib/namedQuery.js lib/types.d.ts lib/types.js lib/workGroup.d.ts lib/workGroup.js"; \ + MISSING_FILES=""; \ + for file in $$FILES_TO_CHECK; do \ + if ! grep -q $$file publish_output.txt; then \ + MISSING_FILES="$$MISSING_FILES $$file"; \ + fi; \ + done; \ + if [ -n "$$MISSING_FILES" ]; then \ + echo "❌ The following files are NOT included in the package:$$MISSING_FILES"; \ + rm publish_output.txt; \ + exit 1; \ + fi + @rm publish_output.txt diff --git a/package.json b/package.json index 37f4b4d..68716a6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,11 @@ "distName": "cdk-athena", "module": "cdk_athena" } - } + }, + "excludeTypescript": [ + "lambda/**/*.ts", + "test/**/*" + ] }, "devDependencies": { "@aws-sdk/client-athena": "3.552.0", diff --git a/test/Makefile b/test/Makefile index 537203a..9d2cad6 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,7 +5,6 @@ clean: install: package @echo Installing dependencies... - @cd .. && make install @npm install ../cdk-athena-test.tgz --no-save --prefer-offline --cache ../.npm @npm list @@ -33,6 +32,6 @@ package: @echo Building npm tgz... @ \ cd .. && \ - make build && \ + make install build && \ npm pack && \ mv cdk-athena-*.tgz cdk-athena-test.tgz diff --git a/test/lib/index.ts b/test/lib/index.ts index 355340f..666fb4a 100644 --- a/test/lib/index.ts +++ b/test/lib/index.ts @@ -8,8 +8,7 @@ import { Tags, } from 'aws-cdk-lib'; import { Construct } from 'constructs'; - -import { EncryptionOption, LogLevel, NamedQuery, WorkGroup } from '../../lib'; +import { EncryptionOption, LogLevel, NamedQuery, WorkGroup } from 'cdk-athena'; export class TestStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) {