Skip to content

Ensure Changelog is updated with every PR. #2

Ensure Changelog is updated with every PR.

Ensure Changelog is updated with every PR. #2

Workflow file for this run

name: Chores
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
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="# This file is part of Jaxley, a differentiable neuroscience simulator. Jaxley is\n# licensed under the Apache License Version 2.0, see <https://www.apache.org/licenses/>"
exit_code=0
while IFS= read -r file; do
header=$(head -n 2 "$file")
if [ "$header" != "$expected_header" ]; then
echo "❌ Missing or incorrect license header in $file"
exit_code=1
fi
done < <(find jaxley tests -name "*.py" -type f)
if [ $exit_code -ne 0 ]; then
echo "License header check failed"
exit 1
fi
- name: Ensure that the changelog reflects the changes
id: changelog
if: always() # Run this step even if the previous one fails
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"
exit 1
fi
- name: Final check
run: |
if [[ "${{ steps.black.outcome }}" != "success" ||
"${{ steps.isort.outcome }}" != "success" ||
"${{ steps.license.outcome }}" != "success" ||
"${{ steps.changelog.outcome }}" != "success" ]]; then
echo "❌ Some checks failed!"
exit 1
fi
echo "✅ All checks passed"