Skip to content

Commit

Permalink
Merge remote-tracking branch 'amplify/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nfsaavedra committed May 9, 2024
2 parents 4d4ccdf + b5b73e0 commit e6b47c8
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -47,4 +47,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/pr_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## \[4.3.3\] - 2024-03-27

### Added

- Support for Python 3.12 ([#153](https://github.com/amplify-education/python-hcl2/pull/153))

## \[4.3.2\] - 2023-05-24

### Added

- Support for the conditional inside the nested locals without parentheses ([#138](https://github.com/amplify-education/python-hcl2/pull/129))

## \[4.3.1\] - 2023-05-02

### Added

- Support for the braces in the next line. Thanks @rout39574 ([#129](https://github.com/amplify-education/python-hcl2/pull/129))
- Support for the ternary multi-line expression. Thanks @seksham ([#128](https://github.com/amplify-education/python-hcl2/pull/128))

## \[4.3.0\] - 2022-01-16

### Added
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/2e2015f9297346cbaa788c46ab957827)](https://app.codacy.com/gh/amplify-education/python-hcl2/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![Build Status](https://travis-ci.org/amplify-education/python-hcl2.svg?branch=master)](https://travis-ci.org/amplify-education/python-hcl2)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/amplify-education/python-hcl2/master/LICENSE)

# Notice
Expand Down
4 changes: 2 additions & 2 deletions hcl2/hcl2.lark
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
start : body
body : (new_line_or_comment? (attribute | block))* new_line_or_comment?
attribute : identifier "=" expression
block : identifier (identifier | STRING_LIT)* "{" body "}"
block : identifier (identifier | STRING_LIT)* new_line_or_comment? "{" body "}"
new_line_and_or_comma: new_line_or_comment | "," | "," new_line_or_comment
new_line_or_comment: ( /\n/ | /#.*\n/ | /\/\/.*\n/ | /\/\*(.|\n)*?(\*\/)/ )+

Expand All @@ -13,7 +13,7 @@ conditional : expression "?" new_line_or_comment? expression new_line_or_comment

?operation : unary_op | binary_op
!unary_op : ("-" | "!") expr_term
binary_op : expression binary_term
binary_op : expression binary_term new_line_or_comment?
!binary_operator : "==" | "!=" | "<" | ">" | "<=" | ">=" | "-" | "*" | "/" | "%" | "&&" | "||" | "+"
binary_term : binary_operator new_line_or_comment? expression

Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-r requirements.txt
# Linting tools
pylint
pycodestyle
Expand Down
10 changes: 10 additions & 0 deletions test/helpers/terraform-config-json/locals_embedded_condition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"locals": [
{
"terraform": {
"channels": "${local.running_in_ci ? local.ci_channels : local.local_channels}",
"authentication": []
}
}
]
}
5 changes: 3 additions & 2 deletions test/helpers/terraform-config/backend.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// a comment
provider "aws" {
// test new line braces style
provider "aws"
{
region = var.region
}

Expand Down
6 changes: 6 additions & 0 deletions test/helpers/terraform-config/locals_embedded_condition.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
locals {
terraform = {
channels = local.running_in_ci ? local.ci_channels : local.local_channels
authentication = []
}
}
3 changes: 2 additions & 1 deletion test/helpers/terraform-config/route_table.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ resource "aws_route" "tgw" {
}

resource "aws_route" "tgw-dot-index" {
count = var.tgw_name == "" ? 0 : var.number_of_az
count = (var.tgw_name == ""
? 0 : var.number_of_az)
route_table_id = aws_route_table.rt[count.index].id
destination_cidr_block = "10.0.0.0/8"
transit_gateway_id = data.aws_ec2_transit_gateway.tgw.0.id
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/terraform-config/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ locals {
}
}
has_valid_forwarding_rules_template_inputs = (
length(keys(var.forwarding_rules_template.copy_resolver_rules)) > 0 &&
length(var.forwarding_rules_template.replace_with_target_ips) > 0 &&
length(keys(var.forwarding_rules_template.copy_resolver_rules)) > 0
&& length(var.forwarding_rules_template.replace_with_target_ips) > 0 &&
length(var.forwarding_rules_template.exclude_cidrs) > 0
)

Expand Down
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist={py37}-unit,{py38}-unit,{py39}-unit,{py310}-unit,{py311}-unit
envlist={py37}-unit,{py38}-unit,{py39}-unit,{py310}-unit,{py311}-unit,{py312}-unit
skipsdist=true

[gh-actions]
Expand All @@ -9,10 +9,11 @@ python =
3.9: py39-unit
3.10: py310-unit
3.11: py311-unit
3.12: py312-unit

[testenv]
commands =
pip install --upgrade -r requirements.txt -r test-requirements.txt .
pip install --upgrade -r test-requirements.txt .
nose2 --config tox.ini --verbose
coverage xml -o reports/coverage.xml --omit=hcl2/lark_parser.py

Expand All @@ -22,7 +23,7 @@ whitelist_externals=rm
passenv = TERRAFORM_CONFIG
basepython=python3.7
commands =
pip install --upgrade -r requirements.txt -r test-requirements.txt -e .
pip install --upgrade -r test-requirements.txt -e .
rm -f hcl2/lark_parser.py
python bin/terraform_test {posargs}

Expand Down

0 comments on commit e6b47c8

Please sign in to comment.