From f24f31cb2d7772c6cd4e522d00fa335954ab8498 Mon Sep 17 00:00:00 2001 From: George Dang <53052793+gtdang@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:03:47 -0400 Subject: [PATCH] Revert "ci: removed other workflows to test only linkcheck." This reverts commit 1503b84c3426025bd5b7e877bbac02943579fdc4. --- .github/workflows/codespell.yml | 22 ++++++++ .github/workflows/issue-metrics.yml | 45 ++++++++++++++++ .github/workflows/unix_unit_tests.yml | 68 ++++++++++++++++++++++++ .github/workflows/windows_unit_tests.yml | 45 ++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100644 .github/workflows/codespell.yml create mode 100644 .github/workflows/issue-metrics.yml create mode 100644 .github/workflows/unix_unit_tests.yml create mode 100644 .github/workflows/windows_unit_tests.yml diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 000000000..c5e16043e --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,22 @@ +--- +name: Codespell + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Codespell + uses: codespell-project/actions-codespell@v2 diff --git a/.github/workflows/issue-metrics.yml b/.github/workflows/issue-metrics.yml new file mode 100644 index 000000000..ce7d1ba70 --- /dev/null +++ b/.github/workflows/issue-metrics.yml @@ -0,0 +1,45 @@ +name: Monthly issue metrics + +on: + workflow_dispatch: + schedule: + - cron: '3 2 1 * *' + +permissions: + contents: write + +jobs: + build: + name: issue metrics + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: read + + steps: + + - name: Get dates for last month + shell: bash + run: | + # Calculate the first day of the previous month + first_day=$(date -d "last month" +%Y-%m-01) + + # Calculate the last day of the previous month + last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d) + + #Set an environment variable with the date range + echo "$first_day..$last_day" + echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" + + - name: Run issue-metrics tool + uses: github/issue-metrics@v3 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SEARCH_QUERY: 'repo:jonescompneurolab/hnn-core is:issue created:${{ env.last_month }}' + + - name: Create issue + uses: peter-evans/create-issue-from-file@v4 + with: + title: Monthly issue metrics report + token: ${{ secrets.GITHUB_TOKEN }} + content-filepath: ./issue_metrics.md \ No newline at end of file diff --git a/.github/workflows/unix_unit_tests.yml b/.github/workflows/unix_unit_tests.yml new file mode 100644 index 000000000..1e6ff5330 --- /dev/null +++ b/.github/workflows/unix_unit_tests.yml @@ -0,0 +1,68 @@ + name: Unit tests + + on: + push: + branches: ['**'] + pull_request: + branches: ['**'] + + jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest,macos-latest] + python-version: [3.8, 3.11, 3.12] + + steps: + - uses: actions/checkout@v4 + + - name: Install Ubuntu System dependencies + if: matrix.os == 'ubuntu-latest' + shell: bash -el {0} + run: | + sudo add-apt-repository ppa:ubuntu-toolchain-r/test + sudo apt-get update + sudo apt-get install libopenmpi-dev openmpi-bin + + - name: Activate conda environment for macOS + if: matrix.os == 'macos-latest' + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: test + python-version: ${{ matrix.python-version }} + fetch-depth: 2 + + - name: Activate Python environment for Ubuntu + if: matrix.os == 'ubuntu-latest' + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Python dependencies + shell: bash -el {0} + run: | + if [ ${{ matrix.os }} == 'macos-latest' ]; then + python -m pip install --upgrade pip + conda install --yes -c conda-forge mpi4py openmpi + elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then + python -m pip install --upgrade pip + python -m pip install mpi4py + fi + - name: Install HNN-core + shell: bash -el {0} + run: | + pip install --verbose '.[opt, parallel, test, gui]' + - name: Lint with flake8 + shell: bash -el {0} + run: | + flake8 --count hnn_core + - name: Test with pytest + shell: bash -el {0} + run: | + python -m pytest ./hnn_core/tests/ --cov=hnn_core --cov-report=xml + - name: Upload coverage to Codecov + shell: bash -el {0} + run: | + bash <(curl -s https://codecov.io/bash) -f ./coverage.xml \ No newline at end of file diff --git a/.github/workflows/windows_unit_tests.yml b/.github/workflows/windows_unit_tests.yml new file mode 100644 index 000000000..e836599fd --- /dev/null +++ b/.github/workflows/windows_unit_tests.yml @@ -0,0 +1,45 @@ +name: Unit test + +on: + push: + branches: ['**'] + pull_request: + branches: ['**'] + +env: + PYTHONPATH: C:\nrn_test\lib\python + NEURONHOME: C:\nrn_test + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest] + python-version: [3.8, 3.11, 3.12] + + steps: + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: test + python-version: ${{ matrix.python-version }} + - name: Install Neuron on Windows separately + shell: cmd + run: | + powershell -command "gh release download --repo https://github.com/neuronsimulator/nrn --pattern '*.exe' --output nrn-setup.exe" + start /b /wait .\nrn-setup.exe /S /D=C:\nrn_test + powershell -command "'C:\nrn_test\bin' >> $env:GITHUB_PATH" + python -c "import neuron" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Install dependencies and HNN + shell: cmd + run: | + python -m pip install --upgrade pip + pip install --verbose .[opt,parallel,test,gui] + - name: Test with pytest + shell: cmd + run: | + python -m pytest ./hnn_core/tests/