Skip to content

Commit

Permalink
feat: add JSON lint job (#252)
Browse files Browse the repository at this point in the history
Add a GitHub workflow that lints JSON changes on PRs and pushes
to main.

Also moves the Step Function definitions into the AWS module to
remove duplication and hardcodes the `retry_interval_seconds`
template parameter so the JSON validates.
  • Loading branch information
patheard authored Aug 30, 2022
1 parent c9d8375 commit 653079a
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 370 deletions.
10 changes: 3 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/python-3
{
"name": "Scan files",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
// Set *default* container specific settings.json values on container create.

"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
Expand Down Expand Up @@ -64,7 +62,7 @@
"version": "2.7.12"
}
},
// Add the IDs of extensions you want installed when the container is created.

"extensions": [
"esbenp.prettier-vscode",
"ms-python.python",
Expand All @@ -76,9 +74,7 @@
"hashicorp.terraform",
"GitHub.copilot"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.

"postCreateCommand": "make install && make install-dev",
"remoteUser": "vscode"
}
24 changes: 24 additions & 0 deletions .github/workflows/json_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: JSON lint
on:
workflow_dispatch:
pull_request:
paths:
- "**/*.json"
- ".github/workflows/json_lint.yml"
push:
branches:
- main
paths:
- "**/*.json"
- ".github/workflows/json_lint.yml"

jobs:
json-lint:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2

- name: Lint JSON
run: find . -name "*.json" -exec cat {} \; | jq .
5 changes: 0 additions & 5 deletions terragrunt/aws/scan_queue/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ variable "concurrent_scan_limit" {
type = number
}

variable "retry_interval_seconds" {
description = "The number of seconds to wait before polling for results"
type = number
}

variable "api_function_arn" {
default = "ARN of the API function"
type = string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
},
"Wait to Get Lock": {
"Type": "Wait",
"Seconds": ${retry_interval_seconds},
"Seconds": 120,
"Next": "Acquire Lock"
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@
},
"Wait to Get Results": {
"Type": "Wait",
"Seconds": ${retry_interval_seconds},
"Seconds": 120,
"Next": "Get AssemblyLine Result"
},
"Release Lock": {
Expand Down
5 changes: 2 additions & 3 deletions terragrunt/aws/scan_queue/state_machine.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ resource "aws_sfn_state_machine" "scan_queue" {
}
}
data "template_file" "scan_queue" {
template = file("state-machines/scan-queue.json")
template = file("${path.module}/state-machines/scan-queue.json")
vars = {
worker_lambda = var.api_function_name
table_semaphore = aws_dynamodb_table.scan-locktable.name
lock_name = "ScanSemaphore"
concurrent_scan_limit = var.concurrent_scan_limit
retry_interval_seconds = var.retry_interval_seconds
}
}

Expand All @@ -32,7 +31,7 @@ resource "aws_sfn_state_machine" "scan_queue_lock_cleanup" {
}
}
data "template_file" "scan_queue_lock_cleanup" {
template = file("state-machines/scan-queue-lock-cleanup.json")
template = file("${path.module}/state-machines/scan-queue-lock-cleanup.json")
vars = {
table_semaphore = aws_dynamodb_table.scan-locktable.name
lock_name = "ScanSemaphore"
Expand Down
1 change: 0 additions & 1 deletion terragrunt/env/production/scan_queue/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ dependency "api" {

inputs = {
concurrent_scan_limit = 5
retry_interval_seconds = 120
api_function_arn = dependency.api.outputs.function_arn
api_function_name = dependency.api.outputs.function_name
}
Expand Down

This file was deleted.

Loading

0 comments on commit 653079a

Please sign in to comment.