Skip to content

Commit

Permalink
chore: added test-lambda-code job to Github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
craigzour committed May 8, 2024
1 parent 72fc8cb commit 0e0af86
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 131 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/terragrunt-plan-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ jobs:
with:
filters: .github/lambda-filter.yml

test-lambda-code:
needs: detect-lambda-changes
if: needs.detect-lambda-changes.outputs.lambda-to-rebuild != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image: ${{ fromJSON(needs.detect-lambda-changes.outputs.lambda-to-rebuild) }}
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Test Lambda code
uses: ./.github/workflows/test-lambda-code
with:
lambda-directory: lambda-code/${{ matrix.image }}
lambda-name: ${{ matrix.image }}

build-lambda-images:
needs: detect-lambda-changes
if: needs.detect-lambda-changes.outputs.lambda-to-rebuild != '[]'
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/terragrunt-plan-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ jobs:
with:
filters: .github/lambda-filter.yml

test-lambda-code:
needs: detect-lambda-changes
if: needs.detect-lambda-changes.outputs.lambda-to-rebuild != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image: ${{ fromJSON(needs.detect-lambda-changes.outputs.lambda-to-rebuild) }}
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Test Lambda code
uses: ./.github/workflows/test-lambda-code
with:
lambda-directory: lambda-code/${{ matrix.image }}
lambda-name: ${{ matrix.image }}

build-lambda-images:
needs: detect-lambda-changes
if: needs.detect-lambda-changes.outputs.lambda-to-rebuild != '[]'
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/test-lambda-code/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test Lambda code

inputs:
lambda-directory:
required: true
lambda-name:
required: true

runs:
using: "composite"
steps:
- run: |
if [ -d tests ]; then
yarn install
yarn test
else
echo "No tests folder detected"
fi
working-directory: ${{ inputs.lambda-directory }}
shell: bash
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ tf.plan
.env

# Ignore coverage reports
**/coverage/*
**/coverage/
9 changes: 3 additions & 6 deletions lambda-code/notify-slack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
"main": "main.js",
"type": "module",
"scripts": {
"prebuild": "rm -rf dist",
"build": "tsc --project tsconfig.json",
"build:dev": "tsc --project tsconfig.json --watch",
"test": "vitest --coverage",
"postbuild": "cp package.json dist/package.json && cp yarn.lock dist/yarn.lock && cd ./dist && yarn install --production"
"test": "vitest --coverage"
},
"license": "MIT",
"devDependencies": {
"@types/aws-lambda": "^8.10.128",
"@types/node": "^20.9.4",
"@vitest/coverage-v8": "^1.3.1",
"typescript": "^5.3.2",
"vitest": "^1.3.1"
"vitest": "^1.6.0",
"@vitest/coverage-v8": "^1.6.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as notify_slack from "./main.js";
import * as utils from "./utils.js";
import * as notify_slack from "../main.js";
import * as utils from "../utils.js";
import { afterEach, describe, expect, it, vi } from "vitest";
import * as zlib from "zlib";

Expand Down
Loading

0 comments on commit 0e0af86

Please sign in to comment.