Skip to content

Commit

Permalink
add tests to pipelines, make arm64, python3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
sakibstark11 committed Jan 7, 2024
1 parent 4dbbf75 commit 91a66ed
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 6 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/Check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Quality Check'

on:
push

permissions:
contents: read

defaults:
run:
shell: bash

concurrency:
group: ${{ github.ref }}

env:
RUNNER_IMAGE_NAME: github-runner-image

jobs:

Check-Code:
name: Deploy Terraform
runs-on: ubuntu-22.04
environment: production

steps:
- name: Checkout Branch
uses: actions/checkout@v3

- name: Build Runner Image
run: make build-runner-image

- name: Run Terraform Lint
run: make run-command-in-container-lint-terraform

- name: Run Tests
run: make run-command-in-container-run-tests
5 changes: 4 additions & 1 deletion .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: 'Deploy Infrastructure'

on:
push:
workflow_run:
workflows: ["Quality Check"]
branches: [master]
types:
- completed

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
terraform 1.4.2
python 3.8.16
python 3.12.1
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ RUN wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform
RUN unzip /tmp/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/bin

COPY requirements.txt /tmp
RUN pip install -r /tmp/requirements.txt
RUN pip install -r /tmp/requirements-dev.txt
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ validate-terraform:
terraform -chdir=terraform validate
.PHONY: validate-terraform

lint-terraform:
terraform -chdir=terraform lint
.PHONY: lint-terraform

run-tests:
pytest -s
.PHONY: run-tests

deploy:
terraform -chdir=terraform init -input=false $(TF_BACKEND_CONFIG)
terraform -chdir=terraform plan -input=false -out=tfplan-apply $(TF_VARS)
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
pythonpath = . src
2 changes: 1 addition & 1 deletion terraform/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ resource "aws_lambda_function" "lambda_functions" {
layers = [aws_lambda_layer_version.lambda_layer.arn]
publish = lookup(each.value, "publish_lambda", false)
reserved_concurrent_executions = lookup(each.value, "reserved_concurrency", -1)
architectures = ["x86_64"]
architectures = ["arm64"]
environment {
variables = lookup(each.value, "env_variables", {})
}
Expand Down
4 changes: 2 additions & 2 deletions terraform/lambda_layer.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
lambda_python_version = "python3.8"
lambda_python_version = "python3.12"
requirements_filepath = "${path.module}/../requirements.txt"
lambda_layer_zipfile_name = "craftsmen-bot-layer"

Expand All @@ -24,4 +24,4 @@ resource "aws_lambda_layer_version" "lambda_layer" {
compatible_runtimes = [local.lambda_python_version]
depends_on = [null_resource.build_lambda_layer]
description = filemd5(local.requirements_filepath)
}
}

0 comments on commit 91a66ed

Please sign in to comment.