Skip to content

Commit

Permalink
ci: Run BATS test in pipeline (#403)
Browse files Browse the repository at this point in the history
secureli-128

Running BATS to validate e2e tests on every PR push. They seem to run
pretty quickly so it shouldn't add much latency to the pipeline.


## Changes
* BATS tests now run in the pipeline and print out verbose results (This
work was done by @joe-stafford )
* Enabling `ci:` as a valid PR prefix, as it's supported by
[conventional
commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).

## Testing
* Fixed existing BATS tests & enabled them in the pipeline

## Clean Code Checklist
<!-- This is here to support you. Some/most checkboxes may not apply to
your change -->
- [x] Meets acceptance criteria for issue
- [ ] New logic is covered with automated tests
- [ ] Appropriate exception handling added
- [ ] Thoughtful logging included
- [ ] Documentation is updated
- [ ] Follow-up work is documented in TODOs
- [ ] TODOs have a ticket associated with them
- [x] No commented-out code included


<!--
Github-flavored markdown reference:
https://docs.github.com/en/get-started/writing-on-github
-->

---------

Co-authored-by: Joey Stafford <[email protected]>
  • Loading branch information
tdurk93 and joe-stafford authored Jan 25, 2024
1 parent 69d7346 commit 05deb62
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,17 @@ jobs:
pip install poetry
poetry install
- name: Install BATS for e2e tests
uses: bats-core/[email protected]

- name: Run Tests
env:
BATS_LIBS_ROOT: /usr/lib
run: |
poetry run poe precommit
poetry run poe coverage
poetry run secureli build
poetry run poe e2e
secureli-release-noop:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ jobs:
- uses: morrisoncole/[email protected]
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
title-regex: "(chore|style|test|feat|fix|docs): .+"
title-regex: "(chore|style|test|feat|fix|docs|ci): .+"
on-failed-regex-fail-action: true
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install = "poetry install"
lint = "black --check ."
precommit = "pre-commit run -a"
test = ["init", "lint", "coverage_run", "coverage_report"]
e2e = "bats tests/end-to-end/test.bats"
e2e = "bats --verbose-run tests/end-to-end/test.bats"

[tool.poetry.dependencies]
# Until `python-dependency-injector` supports python 3.12, restrict to python 3.11 and lower
Expand Down
8 changes: 4 additions & 4 deletions tests/end-to-end/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ setup() {

@test "can run secureli init" {
run python secureli/main.py init -ry
assert_output --partial 'seCureLI has not been setup yet.'
assert_output --partial 'seCureLI has been installed successfully (language = Python)'
assert_output --partial 'Hooks successfully updated to latest version'
assert_output --partial 'seCureLI has been installed successfully'
}

@test "can run secureli scan" {
run python secureli/main.py scan -y
assert_output --partial 'Scan executed successfully and detected no issues!'
run python secureli/main.py scan -y -m all-files
assert_output --partial 'Detected the following language(s):'
}

0 comments on commit 05deb62

Please sign in to comment.