diff --git a/.github/workflows/chores.yml b/.github/workflows/chores.yml deleted file mode 100644 index f799e6b8..00000000 --- a/.github/workflows/chores.yml +++ /dev/null @@ -1,99 +0,0 @@ -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_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 " - - 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 "❌ Incorrect first line in $file" - exit_code=1 - fi - - # Compare the second line - if [ "$file_header_2" != "$expected_header_2" ]; then - echo "❌ Incorrect second line in $file" - exit_code=1 - fi - done < <(find jaxley tests -name "*.py" -type f) - - if [ $exit_code -ne 0 ]; then - 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" diff --git a/.github/workflows/regression_tests.yml b/.github/workflows/regression_tests.yml index 3509be48..e69de29b 100644 --- a/.github/workflows/regression_tests.yml +++ b/.github/workflows/regression_tests.yml @@ -1,39 +0,0 @@ -# .github/workflows/regression_tests.yml -name: Regression Tests - -on: - pull_request: - branches: - - main - -jobs: - regression_tests: - name: regression_tests - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v3 - with: - lfs: true - fetch-depth: 0 # This ensures we can checkout main branch too - - - 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: Run benchmarks and compare to baseline - if: github.event.pull_request.base.ref == 'main' - run: | - # Check if regression test results exist in main branch - if [ -f 'git cat-file -e main:tests/regression_test_baselines.json' ]; then - git checkout main tests/regression_test_baselines.json - else - echo "No regression test results found in main branch" - fi - pytest -m regression \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 20b7f950..d77c0ede 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,13 +3,103 @@ name: Tests on: push: branches: - - main + - main pull_request: branches: - main jobs: - build: + 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 " + + 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 "❌ Incorrect first line in $file" + exit_code=1 + fi + + # Compare the second line + if [ "$file_header_2" != "$expected_header_2" ]; then + echo "❌ Incorrect second line in $file" + exit_code=1 + fi + done < <(find jaxley tests -name "*.py" -type f) + + if [ $exit_code -ne 0 ]; then + 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" + + # Regular Tests Job + pytest: name: Tests runs-on: ubuntu-20.04 @@ -32,3 +122,36 @@ jobs: run: | pip install pytest pytest-cov pytest tests/ -m "not regression" --cov=jaxley --cov-report=xml + + # Regression Tests Job + regression_tests: + name: Regression Tests + runs-on: ubuntu-20.04 + needs: pytest # This ensures that regression tests only run if the pytest job is successful + + steps: + - uses: actions/checkout@v3 + with: + lfs: true + fetch-depth: 0 # This ensures we can checkout the main branch too + + - 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: Run benchmarks and compare to baseline + if: github.event.pull_request.base.ref == 'main' # Run only for PRs targeting the 'main' branch + run: | + # Check if regression test results exist in main branch + if git cat-file -e main:tests/regression_test_baselines.json; then + git checkout main tests/regression_test_baselines.json + else + echo "No regression test results found in main branch" + fi + pytest -m regression \ No newline at end of file