From 0b2cdae37c0bf3c099d2b4cdb913e2e891f06f04 Mon Sep 17 00:00:00 2001 From: Viacheslav Lyzohub Date: Tue, 2 Jul 2024 14:03:23 +0300 Subject: [PATCH] SCALRCORE-31241: Fix CI --- .github/workflows/opa.yml | 53 ++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/.github/workflows/opa.yml b/.github/workflows/opa.yml index 2ebe0a4..40c5487 100644 --- a/.github/workflows/opa.yml +++ b/.github/workflows/opa.yml @@ -4,36 +4,25 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2.0.0 - - name: OPA Test - uses: petroprotsakh/opa-test-action@v2.1 + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Setup OPA + uses: open-policy-agent/setup-opa@v2 with: - options: -v - tests: | - cost - external_data - aws/enforce_aws_resource.rego;aws/enforce_aws_resource_test.rego;aws/enforce_aws_resource_mock.json - aws/enforce_aws_iam_and_workspace.rego;aws/enforce_aws_iam_and_workspace_test.rego;aws/enforce_aws_iam_and_workspace_mock.json - aws/enforce_s3_buckets_encryption.rego;aws/enforce_s3_buckets_encryption_test.rego;aws/enforce_s3_buckets_encryption_mock.json - aws/enforce_kms_key_names.rego;aws/enforce_kms_key_names.test.rego;aws/enforce_kms_key_names.mock.json - aws/enforce_iam_instance_profiles.rego;aws/enforce_iam_instance_profiles.test.rego;aws/enforce_iam_instance_profiles.mock.json - aws/enforce_ebs_del_on_term.rego;aws/enforce_ebs_del_on_term.test.rego;aws/enforce_ebs_del_on_term.mock.json - aws/enforce_instance_subnet.rego;aws/enforce_instance_subnet.test.rego;aws/enforce_instance_subnet.mock.json - aws/enforce_lb_subnets.rego;aws/enforce_lb_subnets.test.rego;aws/enforce_lb_subnets.mock.json - aws/enforce_rds_subnets.rego;aws/enforce_rds_subnets.test.rego;aws/enforce_rds_subnets.mock.json - management/denied_provisioners.rego;management/denied_provisioners_test.rego;management/denied_provisioners_mock.json - management/enforce_ami_owners.rego;management/enforce_ami_owners_test.rego;management/enforce_ami_owners_mock.json - management/instance_types.rego;management/instance_types_test.rego;management/instance_types_mock.json - management/resource_tags.rego;management/resource_tags_test.rego;management/resource_tags_mock.json - management/whitelist_ami.rego;management/whitelist_ami_test.rego;management/whitelist_ami_mock.json - management/workspace_name.rego;management/workspace_name_test.rego;management/workspace_name_mock.json - management/workspace_destroy.rego;management/workspace_destroy_test.rego;management/workspace_destroy_mock.json - management/pull_requests.rego;management/pull_requests_test.rego;management/pull_requests_mock.json - management/workspace_tags.rego;management/workspace_tags_test.rego;management/workspace_tags_mock.json - management/workspace_environment_type.rego;management/workspace_environment_type_еуіе.rego;management/workspace_environment_type_mock.json - modules/pin_module_version.rego;modules/pin_module_version_test.rego;modules/pin_module_version_mock.json; - modules/required_modules.rego;modules/required_modules_test.rego;modules/required_modules_mock.json; - placement - providers - user + version: latest + + - name: Run OPA Tests + run: | + dirs=$(find . -type f -name '*.rego' -exec dirname {} \; | sort -u) + echo "Directories to be tested:" + for dir in $dirs; do + echo "$dir" + done + for dir in $dirs; do + echo "Running tests in $dir" + if ! opa test $dir/ -v --format pretty; then + echo "Tests failed in $dir" + exit 1 + fi + done