From ac5026dedc9a1b527353ce35281ee1a890ef7f34 Mon Sep 17 00:00:00 2001 From: jnsbck <65561470+jnsbck@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:39:17 +0100 Subject: [PATCH] Skip Changelog test on push to main (#558) * enh: add chores workflow as example * fix: rename tests to chores * fix: fix license header test * fix: refactor workflows * fix: rebase regression_tests to main * fix: skip changelog on pushes * fix: better license check * chore: update changelog --- .github/workflows/tests.yml | 40 +++++++++++++++++++++++++++---------- CHANGELOG.md | 2 +- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9a228cd5..ef1d7004 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,14 +56,14 @@ jobs: # Compare the first line if [ "$file_header_1" != "$expected_header_1" ]; then - echo "❌ Incorrect first line in $file" - exit_code=1 + echo "❌ Missing or incorrect license header in $file" + exit 1 fi # Compare the second line if [ "$file_header_2" != "$expected_header_2" ]; then - echo "❌ Incorrect second line in $file" - exit_code=1 + echo "❌ Missing or incorrect license header in $file" + exit 1 fi done < <(find jaxley tests -name "*.py" -type f) @@ -73,7 +73,7 @@ jobs: - name: Ensure that the changelog was updated id: changelog - if: always() # Run this step even if the previous one fails + if: github.event_name == 'pull_request' # Only run on pull requests run: | # Ensure the main branch is up-to-date git fetch origin main @@ -88,14 +88,32 @@ jobs: fi - name: Final check + if: always() # Run this step even if the previous one fails run: | - if [[ "${{ steps.black.outcome }}" != "success" || - "${{ steps.isort.outcome }}" != "success" || - "${{ steps.license.outcome }}" != "success" || - "${{ steps.changelog.outcome }}" != "success" ]]; then - echo "❌ Some checks failed!" + 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: @@ -120,4 +138,4 @@ jobs: - name: Test with pytest run: | pip install pytest pytest-cov - pytest tests/ -m "not regression" --cov=jaxley --cov-report=xml \ No newline at end of file + pytest tests/ -m "not regression" --cov=jaxley --cov-report=xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 4756040b..1b4fa8ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ net.vis() - Allow parameter sharing for groups of different sizes, i.e. due to inhomogenous numbers of compartments or for synapses with the same (pre-)synaptic parameters but different numbers of post-synaptic partners. (#514, @jnsbck) -- changelog added to CI +- changelog added to CI (#537, #558, @jnsbck) # 0.5.0