Skip to content

fix(examples): update example policies and test script#2378

Merged
Piskoo merged 1 commit intochainloop-dev:mainfrom
Piskoo:fix-policy-examples
Aug 22, 2025
Merged

fix(examples): update example policies and test script#2378
Piskoo merged 1 commit intochainloop-dev:mainfrom
Piskoo:fix-policy-examples

Conversation

@Piskoo
Copy link
Collaborator

@Piskoo Piskoo commented Aug 21, 2025

This PR fixes issue with _testutils.sh functions returning exit codes in lint and eval functions. Older example policies got linted with policy devel lint --format to make them consistent with other examples. One of the tests in freshness policy was fixed since it was time depended. Regex is used to find result fields in the output so no additional changes were needed to adjust the script to the new eval output.

Closes #2376

…shness test

Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
@Piskoo Piskoo marked this pull request as ready for review August 21, 2025 09:24
@Piskoo Piskoo requested review from javirln and migmartri August 21, 2025 09:24
if output=$($CHAINLOOP_BIN policy develop lint --policy "$policy_file" 2>&1); then
echo -e "${GREEN}✓ PASSED${NC}"
((TESTS_PASSED++))
((TESTS_PASSED++)) || true
Copy link
Member

@migmartri migmartri Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! could you give some color on why we need this?

thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently ((TESTS_PASSED++)) uses post increment so here it returns 0 which causes the script to exit (bash expr). ((++TESTS_PASSED)) would fix that as well but as defensive measure I've used || true
since from what I understood from other tests that use this utils, it is meant to return exit code with test_summary .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but is this issue related to your change? Why wasn't it failing before? Out of curiosity what's the root cause

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it was failing before, I'm not sure which released version caused it to not work, unless it wasn't working since the beginning

if output=$($CHAINLOOP_BIN policy develop lint --policy "$policy_file" 2>&1); then
echo -e "${GREEN}✓ PASSED${NC}"
((TESTS_PASSED++))
((TESTS_PASSED++)) || true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but is this issue related to your change? Why wasn't it failing before? Out of curiosity what's the root cause

@Piskoo Piskoo merged commit eed41ef into chainloop-dev:main Aug 22, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update example policy test script to align with new eval output format

2 participants