-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
43 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Tests | ||
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" |
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
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