Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ntse committed Nov 4, 2024
1 parent 882abe3 commit 844e07a
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 9 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/_skip_test-container-image-build copy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Test Build Container Image"

on:
pull_request:
branches:
- main
paths-ignore:
- .github/workflows/_test-container-image-build.yml
- .github/workflows/container-image-build.yml
- .github/workflows/container-image-release.yml

jobs:
container_image_build_regression_test:
name: Test using devops-terraform-ci@main
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required" '
2 changes: 1 addition & 1 deletion .github/workflows/_skip_test-terraform-destroy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[Test] Skip Destroy Terraform stacks"
name: "Test Destroy Terraform stacks"

on:
pull_request:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_skip_test-terraform-plan-apply.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[Test] Skip Deploy Terraform stacks"
name: "Test Deploy Terraform stacks"

on:
pull_request:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/_test-container-image-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Test Build Container Image"
# Regression testing to try and catch and breaking changes

on:
pull_request:
branches:
- main
paths:
- .github/workflows/_test-container-image-build.yml
- .github/workflows/container-image-build.yml
- .github/workflows/container-image-release.yml

jobs:
container_image_build_regression_test:
name: Test using devops-terraform-ci@main
uses: ./.github/workflows/container-image-build.yml
with:
repo: UKHSA-Internal/devops-terraform-ci
ref: "main"
release_after_build: false
permissions:
id-token: write
contents: write
actions: read
2 changes: 1 addition & 1 deletion .github/workflows/_test-terraform-destroy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[Test] Destroy Terraform stacks"
name: "Test Destroy Terraform stacks"
# Regression testing to try and catch and breaking changes. Will only run a destroy plan.

on:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_test-terraform-plan-apply.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[Test] Deploy Terraform stacks"
name: "Test Deploy Terraform stacks"
# Regression testing to try and catch and breaking changes

on:
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/container-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,29 @@ on:
unit_tests_command:
description: "The command to run unit tests of the application"
type: string
default: echo docker run "$APP_NAME":latest pytest || exit 1
default: echo docker run container:latest pytest || exit 1
release_after_build:
description: "Whether or not to generate a tag and release after building the image"
type: boolean
default: false
dockerfile_path:
description: "Path of the Dockerfile"
type: string
default: "${{ inputs.docker_build_context}}/Dockerfile"
docker_build_context:
description: "The context of the Docker build command"
type: string
default: "."
repo:
required: false
type: string
default: ${{ github.repository }}
description: "Specify the org/repo of the repo containing Terraform code. Normally left blank to clone calling repo."
ref:
required: false
type: string
default: ${{ github.ref }}
description: "Specify the branch of the Terraform code. Normally left blank to use calling ref."
outputs:
artifact_url:
value: ${{ jobs.build.outputs.artifact_url }}
Expand All @@ -36,10 +54,11 @@ jobs:
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
context: ${{ inputs.docker_build_context }}
push: false
tags: "container:latest"
load: true
file: ${{ inputs.dockerfile_path }}
outputs: type=docker,dest=/tmp/container-image.tar

- name: Unit tests
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/container-image-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ on:
ecr_aws_account_id:
description: "The AWS account ID to push the ECR images to"
type: string
default: "636728427214"
image_name:
description: "The name of the container image"
type: string
role_to_assume:
description: "IAM role to assume for pushing to ECR"
type: string
default: "active10-github-actions-role"

repo:
required: false
type: string
default: ${{ github.repository }}
description: "Specify the org/repo of the repo containing Terraform code. Normally left blank to clone calling repo."
ref:
required: false
type: string
default: ${{ github.ref }}
description: "Specify the branch of the Terraform code. Normally left blank to use calling ref."


permissions:
id-token: write
Expand Down

0 comments on commit 844e07a

Please sign in to comment.