From f3887cfca42dc48ee33325cb2446aa186550674d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej?= <46246339+BartekCK@users.noreply.github.com> Date: Sat, 21 Jan 2023 20:25:04 +0100 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=92=82=20add=20image=20building?= =?UTF-8?q?=20and=20checking=20for=20AWS=20lambda=20=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 60 ++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6b0f76c..7b6a1db 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,8 +7,8 @@ on: branches: [ "develop", "master" ] jobs: - test: + test: services: postgres: image: postgres @@ -31,21 +31,51 @@ jobs: node-version: [16.x] steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install all dependencies + run: npm ci + + - name: Check typescript types + run: npm run check-types + + - name: Check lint + run: npm run lint + + - name: Run test + run: npm test + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install aws-lambda-runtime-interface-emulator + run: | + mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && chmod +x ~/.aws-lambda-rie/aws-lambda-rie + + - name: Set COMMIT_HASH environment variable + run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + - - name: Install all dependencies - run: npm ci + - name: Build Docker image + run: | + echo "Building image with tag: $COMMIT_HASH" + docker build -t cgm-handler:$COMMIT_HASH . - - name: Check typescript types - run: npm run check-types + - name: Run cgm-handler-container + run: | + docker run --rm -d -p 9000:8080 --name cgm-handler-container cgm-handler:$COMMIT_HASH - - name: Check lint - run: npm run lint + - name: Check if image is appropriate for Lambda Container + run: | + curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}' - - name: Run test - run: npm test + - name: Clear after pipeline + run: | + docker container stop cgm-handler-container