Skip to content

Commit

Permalink
Issue #81: Add pytest to CI pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark2000 committed Sep 30, 2024
1 parent ed50428 commit cfa970e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 23 deletions.
18 changes: 5 additions & 13 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Description
Closes #XXX

Please include a summary, motivation, and context of the changes and the related issue.
*Please include a summary, motivation, and context of the changes and the related issue.*

### Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
Expand All @@ -14,25 +14,17 @@ Please include a summary, motivation, and context of the changes and the related

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes.
*Please describe how tests have been updated to verify your changes.*

### Passes Tests
- [ ] __Unit tests__ `pytest --cov bsk_rl --cov-report term-missing tests/unittest`
- [ ] __Integrated tests__ `pytest --cov bsk_rl --cov-report term-missing tests/integration`
- [ ] __Documentation builds__ `cd docs; make html`
## Future Work

### Test Configuration
- Python:
- Basilisk:
- Platform:
*What future tasks are needed, if any?*

# Checklist:
## Checklist

- [ ] My code follows the style guidelines of this project (passes Black, ruff, and isort)
- [ ] I have performed a self-review of my code
- [ ] I have commented my code in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation and release notes
- [ ] Commit messages are atomic, are in the form `Issue #XXX: Message` and have a useful message
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] If I changed an example ipynb, I have locally rebuilt the documentation
54 changes: 44 additions & 10 deletions .github/workflows/commit_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@ name: Commit Checks
on: [pull_request]

jobs:
Black:
formatting:
name: Linting and Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: psf/black@stable
Ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: isort/isort-action@v1

check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
Expand All @@ -40,6 +34,46 @@ jobs:
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.GITHUB_TOKEN }}

run-pytest:
name: Run Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Find artifact run
run: |
sudo apt-get install jq
export RUN_ID=$(
curl -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/AVSLab/basilisk/actions/runs?status=completed&per_page=100" |
jq -r '.workflow_runs[] | select(.name == "Pull Request Closed") | .id' |
head -n 1
)
echo "RUN_ID=$RUN_ID" >> $GITHUB_ENV
- name: Pull artifacts
uses: actions/download-artifact@v4
with:
name: basilisk-wheels_ubuntu-latest_python${{ matrix.python-version }}
repository: AVSLab/basilisk
run-id: ${{ env.RUN_ID }}
github-token: ${{ github.token }}
- name: Install Basilisk from wheels
run: pip install Basilisk*.whl
- name: Install BSK-RL
run: pip install -e '.[all]' && finish_install
- name: Run pytest
run: pytest -v

check-doc-build:
name: Test Documentation Build
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/sats/test_int_satellites.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import gymnasium as gym
import numpy as np
import pytest
from pytest import approx

from bsk_rl import act, data, obs, sats
Expand Down Expand Up @@ -35,6 +36,7 @@ class ImageSat(sats.ImagingSatellite):
disable_env_checker=True,
)

@pytest.mark.skip(reason="Causes tests to hang sometimes")
def test_generate_more_windows(self):
self.env.reset()
dts = []
Expand Down

0 comments on commit cfa970e

Please sign in to comment.