Skip to content

Commit

Permalink
Update ci.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-shcherbak authored Jun 7, 2024
1 parent 1337222 commit 2c5039c
Showing 1 changed file with 1 addition and 86 deletions.
87 changes: 1 addition & 86 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,94 +5,9 @@ on:
types:
- submitted
jobs:
test_policy_red_flights:
if: github.event_name == 'push' || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
runs-on: ubuntu-22.04
container: python:3.8
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/composite-action
- name: test_policy_red_flights
shell: bash
run: |
cd cloud-custodian
python3.8 -m venv .venv && source .venv/bin/activate
pip install poetry
make install
mkdir out
RULE_NAMES=$(find ./aws-custodian-policies/tests/ -maxdepth 1 -type d | tail -n +2 | awk -F '/' '{ print $NF }')
RED_WHITELISTED_RULE_NAMES=$(cat ./aws-custodian-policies/tests/.whitelisted_red)
touch .red_passed .red_failed .whitelisted_red_failed
echo "$RULE_NAMES" |
while IFS= read -r policy ; do
echo "red test $policy executing..."
mkdir out/$policy
cp aws-custodian-policies/tests/$policy/placebo-red/* out/$policy
ls out/$policy
red_policy_test_file_name="aws-custodian-policies.tests.$policy.red_policy_test"
python3 policy_as_test.py test aws-custodian-policies/policies/$policy.yml $red_policy_test_file_name out \
&& echo $policy >> .red_passed || if [[ $RED_WHITELISTED_RULE_NAMES =~ $policy ]]; \
then echo $policy >> .whitelisted_red_failed; else echo $policy >> .red_failed; fi
rm -r out/$policy
done
echo "red tests executed"
echo "red_passed:"
cat .red_passed
echo "whitelisted_red_failed:"
cat .whitelisted_red_failed
echo "red_failed:"
cat .red_failed
test -s .red_failed && exit 1
exit 0
test_policy_green_flights:
if: github.event_name == 'push' || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
runs-on: ubuntu-22.04
container: python:3.8
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/composite-action
- name: test_policy_green_flights
shell: bash
run: |
cd cloud-custodian
python3.8 -m venv .venv && source .venv/bin/activate
pip install poetry
make install
mkdir out
RULE_NAMES=$(find ./aws-custodian-policies/tests/ -maxdepth 1 -type d | tail -n +2 | awk -F '/' '{ print $NF }')
GREEN_WHITELISTED_RULE_NAMES=$(cat ./aws-custodian-policies/tests/.whitelisted_green)
touch .green_passed .green_failed .whitelisted_green_failed
echo "$RULE_NAMES" |
while IFS= read -r policy ; do
echo "green test $policy executing..."
mkdir out/$policy
cp aws-custodian-policies/tests/$policy/placebo-green/* out/$policy
ls out/$policy
green_policy_test_file_name=$(test -f aws-custodian-policies/tests/$policy/green_policy_test.py && echo "aws-custodian-policies.tests.$policy.green_policy_test" || echo "green_policy_test")
python3 policy_as_test.py test aws-custodian-policies/policies/$policy.yml $green_policy_test_file_name out \
&& echo $policy >> .green_passed || if [[ $GREEN_WHITELISTED_RULE_NAMES =~ $policy ]]; \
then echo $policy >> .whitelisted_green_failed; else echo $policy >> .green_failed; fi
rm -r out/$policy
done
echo "green tests executed"
echo "green_passed:"
cat .green_passed
echo "whitelisted_green_failed:"
cat .whitelisted_green_failed
echo "green_failed:"
cat .green_failed
test -s .green_failed && exit 1
exit 0
build:
name: Create Release
runs-on: ubuntu-latest
needs: [test_policy_red_flights, test_policy_green_flights]
if: startsWith(github.ref, 'refs/tags/v')
steps:

Expand All @@ -119,4 +34,4 @@ jobs:
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.changes }}
body: ${{ steps.changelog.outputs.changes }}

0 comments on commit 2c5039c

Please sign in to comment.