Skip to content
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

chore: added test-lambda-code job to Github workflow #658

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading