From dd5092b62c7a00138eb4f34ab1300411976c4d4c Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:10:16 +0100 Subject: [PATCH 1/8] Test on self-hosted mac --- .github/workflows/mac.yml | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/mac.yml diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml new file mode 100644 index 00000000..e526cd9d --- /dev/null +++ b/.github/workflows/mac.yml @@ -0,0 +1,58 @@ +name: mac-ci + +on: [push, pull_request] + +jobs: + + tests: + runs-on: [self-hosted, macOS] + if: github.repository == 'stfc/janus-core' + timeout-minutes: 30 + strategy: + matrix: + python-version: ['3.9','3.10','3.11','3.12'] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Set path + run: | + echo "/github/home/.local/bin" >> $GITHUB_PATH + rm -rf /github/home/.local + rm -rf /github/home/.cache + + - name: Install python dependencies + run: | + python3 -m pip install pipx + pipx install poetry + poetry env use ${{ matrix.python-version }} + poetry install --with dev + + - name: Run test suite + env: + # show timings of tests + PYTEST_ADDOPTS: "--durations=0" + run: | + poetry run pytest --cov janus_core --cov-append . + + - name: Report coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + parallel: true + flag-name: run-${{ matrix.python-version }} + file: coverage.xml + base-path: janus_core + + coverage: + needs: tests + runs-on: self-hosted + steps: + - name: Close parallel build + uses: coverallsapp/github-action@v2 + with: + parallel-finished: true From 72db7f6d77ddf99d35ab59db96c28a0c9a6d5ed8 Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Fri, 11 Oct 2024 12:32:21 +0100 Subject: [PATCH 2/8] Automatically add pipx apps to PATH --- .github/workflows/mac.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index e526cd9d..e16e27d1 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -20,16 +20,12 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Set path - run: | - echo "/github/home/.local/bin" >> $GITHUB_PATH - rm -rf /github/home/.local - rm -rf /github/home/.cache - - name: Install python dependencies run: | python3 -m pip install pipx pipx install poetry + pipx ensurepath + source ~/.zshrc poetry env use ${{ matrix.python-version }} poetry install --with dev From 1d622d5d2b9080c384b5320a3e9ba3c933f5bee1 Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:38:59 +0100 Subject: [PATCH 3/8] Test all MLIPs on mac --- .github/workflows/mac.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index e16e27d1..08054435 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -27,14 +27,14 @@ jobs: pipx ensurepath source ~/.zshrc poetry env use ${{ matrix.python-version }} - poetry install --with dev + poetry install --with dev --extras all - name: Run test suite env: # show timings of tests PYTEST_ADDOPTS: "--durations=0" run: | - poetry run pytest --cov janus_core --cov-append . + poetry run pytest --run-extra-mlips --cov janus_core --cov-append . - name: Report coverage to Coveralls uses: coverallsapp/github-action@v2 From 382073809320104eed1cd07c20ccda7b90c664a6 Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:39:01 +0100 Subject: [PATCH 4/8] Remove pipx and poetry installation --- .github/workflows/mac.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 08054435..be25497d 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -22,9 +22,6 @@ jobs: - name: Install python dependencies run: | - python3 -m pip install pipx - pipx install poetry - pipx ensurepath source ~/.zshrc poetry env use ${{ matrix.python-version }} poetry install --with dev --extras all From f9fb8d9b0e5d5983441a26ecb5d05091d06c15f8 Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:52:20 +0100 Subject: [PATCH 5/8] Fix poetry path --- .github/workflows/mac.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index be25497d..20cfa452 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -31,6 +31,7 @@ jobs: # show timings of tests PYTEST_ADDOPTS: "--durations=0" run: | + source ~/.zshrc poetry run pytest --run-extra-mlips --cov janus_core --cov-append . - name: Report coverage to Coveralls From 1189b1eee8c544789063cab7b7d428a70e94f3ae Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:45:24 +0000 Subject: [PATCH 6/8] Update MacOS ci for uv --- .github/workflows/mac.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 20cfa452..5f924c52 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -15,16 +15,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + - name: Install uv + uses: astral-sh/setup-uv@v4 with: + version: "0.5.7" python-version: ${{ matrix.python-version }} - - name: Install python dependencies - run: | - source ~/.zshrc - poetry env use ${{ matrix.python-version }} - poetry install --with dev --extras all + - name: Install dependencies + run: uv sync --all-extras - name: Run test suite env: @@ -32,7 +30,7 @@ jobs: PYTEST_ADDOPTS: "--durations=0" run: | source ~/.zshrc - poetry run pytest --run-extra-mlips --cov janus_core --cov-append . + uv run pytest --run-extra-mlips --cov janus_core --cov-append . - name: Report coverage to Coveralls uses: coverallsapp/github-action@v2 From d746d730f3ebf1f3abf586e1425e81ca4060ca18 Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:42:53 +0000 Subject: [PATCH 7/8] Fix coveralls --- .github/workflows/mac.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 5f924c52..f296f151 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -28,9 +28,12 @@ jobs: env: # show timings of tests PYTEST_ADDOPTS: "--durations=0" + run: uv run pytest --run-extra-mlips --cov janus_core --cov-append . + + - name: Set Path run: | source ~/.zshrc - uv run pytest --run-extra-mlips --cov janus_core --cov-append . + echo "PATH=$PATH" >> $GITHUB_ENV - name: Report coverage to Coveralls uses: coverallsapp/github-action@v2 From a08d7e12b5ec286243663abc9701335fab64f6b6 Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:43:10 +0000 Subject: [PATCH 8/8] Update docs for self-hosted runners --- docs/source/developer_guide/ci.rst | 29 +++++++++++++++++++++++++++ docs/source/developer_guide/index.rst | 1 + 2 files changed, 30 insertions(+) create mode 100644 docs/source/developer_guide/ci.rst diff --git a/docs/source/developer_guide/ci.rst b/docs/source/developer_guide/ci.rst new file mode 100644 index 00000000..2b553275 --- /dev/null +++ b/docs/source/developer_guide/ci.rst @@ -0,0 +1,29 @@ +====================== +Continuous Integration +====================== + +General instructions for setting up self-hosted GitHub runners can be found `here `_. + +This process typically involves: + +1. Add a new self-hosted runner on GitHub +2. Run instructions from GitHub on your runner to download and configure +3. Ensure tags added to the runner are unique, and match those in ``runs-on`` within the CI workflow + + +MacOS self-hosted runner +======================== + +Currently, ``janus-core`` uses a self-hosted runner to run all unit tests on MacOS. + +To ensure the self-hosted runner remains active, we currently recommend using + +.. code-block:: bash + + nohup ./run.sh &! + +This runs the script in the background, and disowns the process, allowing the ssh connection to be ended without killing the process. + +It would be preferable to `configure the runner application as a service `_, +but currently this appears to lead to difficulties if the GUI is not active +and/or ``sudo`` permissions are not used in running the service. diff --git a/docs/source/developer_guide/index.rst b/docs/source/developer_guide/index.rst index 5de224d0..28f342c9 100644 --- a/docs/source/developer_guide/index.rst +++ b/docs/source/developer_guide/index.rst @@ -7,3 +7,4 @@ Developer guide get_started tutorial + ci