Skip to content

Commit

Permalink
Add instances to rules integration tests (#351)
Browse files Browse the repository at this point in the history
* Added 2 runners to integration tests for rules registry

* Fixed indent

* Added explicit shell name

* Moved shell to job parameters

* Added powershell commands for windows

* Removed test branch

* Updated README.md (#352)

* Updated README for Guard 3.0

* Update README.md

Co-authored-by: Ben Bridts <ben.bridts@gmail.com>

---------

Co-authored-by: Ben Bridts <ben.bridts@gmail.com>

---------

Co-authored-by: Akshay Rane <raneaks@amazon.com>
Co-authored-by: razcloud <34892703+razcloud@users.noreply.github.com>
Co-authored-by: Ben Bridts <ben.bridts@gmail.com>
  • Loading branch information
4 people committed Mar 28, 2023
1 parent 597452a commit e427ed5
Showing 1 changed file with 73 additions and 5 deletions.
78 changes: 73 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Rust

on:
push:
branches: [ main, development, rogue_one]
branches: [ main, development, rogue_one ]
pull_request:
branches: [ main, development, rogue_one]
branches: [ main, development, rogue_one ]

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -39,9 +39,12 @@ jobs:
- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1

aws-guard-rules-registry-ubuntu-integration-tests:
name: Integration tests against aws-guard-rules-registry on Ubuntu
runs-on: ubuntu-latest
aws-guard-rules-registry-integration-tests-linux:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
name: Integration tests against aws-guard-rules-registry
steps:
- uses: actions/checkout@v3
name: Checkout cfn-guard
Expand Down Expand Up @@ -106,3 +109,68 @@ jobs:
else
echo "All the rules have succeeded the parse-tree integration tests."
fi
aws-guard-rules-registry-integration-tests-windows:
runs-on: windows-latest
name: Integration tests against aws-guard-rules-registry for Windows
steps:
- uses: actions/checkout@v3
name: Checkout cfn-guard
with:
path: cloudformation-guard
- name: Build binary
run: |
cd cloudformation-guard/guard/
cargo build --release
- uses: actions/checkout@v3
name: Checkout aws-guard-rules-registry
with:
repository: aws-cloudformation/aws-guard-rules-registry
path: aws-guard-rules-registry
ref: main
- name: Run integration tests using test command
run: |
if (cloudformation-guard/target/release/cfn-guard test -d aws-guard-rules-registry/rules) {
echo "The integration tests for test command have passed."
}
else {
echo "The integration tests for test command have failed."
exit 1
}
- name: Run integration tests using parse-tree command
run: |
cd aws-guard-rules-registry/rules
$FAILED_RULES = @()
$SKIPPED_RULES = @()
$rules = @(Get-ChildItem -Path .\ -Filter *.guard -Recurse -File)
Foreach ($rule in $rules) {
$rule_files_without_comments = (Get-Content $rule.FullName) -replace '^[ \s]*#.*$', ''
if ([String]::IsNullOrWhiteSpace($rule_files_without_comments)){
$SKIPPED_RULES += "$rule"
}
elseif (../../cloudformation-guard/target/release/cfn-guard parse-tree --rules $rule.FullName) {
continue
} else {
$FAILED_RULES += "$rule"
}
}
$SKIPPED_RULE_COUNT = $SKIPPED_RULES.Length
if ($SKIPPED_RULE_COUNT -gt 0) {
echo "The following `$SKIPPED_RULE_COUNT.Length` rule(s) were skipped because they contained only comments:"
echo $SKIPPED_RULES
}
$FAILED_RULE_COUNT = $FAILED_RULES.Length
if ($FAILED_RULE_COUNT -gt 0) {
echo "The following $FAILED_RULE_COUNT rule(s) have failed the parse-tree integration tests with a non-zero error code:"
echo $FAILED_RULES
exit 1
} else {
echo "All the rules have succeeded the parse-tree integration tests."
}

0 comments on commit e427ed5

Please sign in to comment.