Simpler edge indexing #1563
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
chores: | |
name: Chores | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
architecture: 'x64' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e ".[dev]" | |
- name: Check formatting with black | |
id: black | |
if: always() # Run this step even if the previous one fails | |
run: | | |
black --check jaxley tests | |
- name: Check imports with isort | |
id: isort | |
if: always() # Run this step even if the previous one fails | |
run: | | |
isort -c jaxley tests | |
- name: Check license headers | |
id: license | |
if: always() # Run this step even if the previous one fails | |
run: | | |
expected_header_1="# This file is part of Jaxley, a differentiable neuroscience simulator. Jaxley is" | |
expected_header_2="# licensed under the Apache License Version 2.0, see <https://www.apache.org/licenses/>" | |
exit_code=0 | |
while IFS= read -r file; do | |
# Extract the first two lines of the file | |
file_header_1=$(head -n 1 "$file") | |
file_header_2=$(head -n 2 "$file" | tail -n 1) | |
# Compare the first line | |
if [ "$file_header_1" != "$expected_header_1" ]; then | |
echo "❌ Missing or incorrect license header in $file" | |
exit 1 | |
fi | |
# Compare the second line | |
if [ "$file_header_2" != "$expected_header_2" ]; then | |
echo "❌ Missing or incorrect license header in $file" | |
exit 1 | |
fi | |
done < <(find jaxley tests -name "*.py" -type f) | |
if [ $exit_code -ne 0 ]; then | |
exit 1 | |
fi | |
- name: Ensure that the changelog was updated | |
id: changelog | |
if: github.event_name == 'pull_request' # Only run on pull requests | |
run: | | |
# Ensure the main branch is up-to-date | |
git fetch origin main | |
# Check if CHANGELOG.md was updated | |
changed_files=$(git diff --name-only origin/main) | |
if echo "$changed_files" | grep -q 'CHANGELOG.md'; then | |
echo "CHANGELOG.md was updated" | |
else | |
echo "CHANGELOG.md was not updated. Please add your changes if significant. Otherwise, this check can be safely ignored." | |
exit 1 | |
fi | |
- name: Final check | |
if: always() # Run this step even if the previous one fails | |
run: | | |
failed_checks=() | |
if [[ "${{ steps.black.outcome }}" != "success" ]]; then | |
failed_checks+=("black formatting") | |
fi | |
if [[ "${{ steps.isort.outcome }}" != "success" ]]; then | |
failed_checks+=("isort imports") | |
fi | |
if [[ "${{ steps.license.outcome }}" != "success" ]]; then | |
failed_checks+=("license headers") | |
fi | |
if [[ "${{ steps.changelog.outcome }}" != "success" && "${{ github.event_name }}" == "pull_request" ]]; then | |
failed_checks+=("changelog update") | |
fi | |
if (( ${#failed_checks[@]} > 0 )); then | |
echo "❌ The following checks failed:" | |
printf '%s\n' "${failed_checks[@]}" | |
exit 1 | |
fi | |
echo "✅ All checks passed" | |
pytest: | |
name: Pytest | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
architecture: 'x64' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e ".[dev]" | |
- name: Test with pytest | |
run: | | |
pip install pytest pytest-cov | |
pytest tests/ -m "not regression" --cov=jaxley --cov-report=xml |