Skip to content

Commit 18a30de

Browse files
committed
update workflow
1 parent 59372ae commit 18a30de

File tree

4 files changed

+90
-176
lines changed

4 files changed

+90
-176
lines changed

.github/workflows/style.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Style
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
PYTHON_VERSION: "3.10"
18+
19+
jobs:
20+
linter-check:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
- name: Set up Python ${{ env.PYTHON_VERSION }}
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: ${{ env.PYTHON_VERSION }}
29+
cache: pip
30+
31+
- name: Install Python deps
32+
shell: bash
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install black ruff
36+
python -m pip install -e .
37+
38+
- name: Black Check
39+
shell: bash
40+
run: black . --diff --color --check
41+
42+
# - name: ruff Check
43+
# shell: bash
44+
# run: ruff check src

.github/workflows/test-ci.yml

Lines changed: 36 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,54 @@
1-
name: CI
1+
name: CI-CD
22

33
on:
44
push:
55
branches: [ "main" ]
66
pull_request:
77
branches: [ "main" ]
88

9-
workflow_dispatch:
10-
119
jobs:
12-
linter-check:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v3
17-
- name: Set up Python "3.10"
18-
uses: actions/setup-python@v4
19-
with:
20-
python-version: "3.10"
21-
- name: Black setup
22-
shell: bash
23-
run: pip install black ruff mypy
24-
- name: Black Check
25-
shell: bash
26-
run: black . --diff --color --check
27-
28-
test-cpu:
10+
test:
2911
runs-on: ubuntu-latest
30-
needs: linter-check
12+
3113
strategy:
32-
fail-fast: true
3314
matrix:
34-
python-version: ["3.12", "3.10"]
15+
python-version: [3.11, 3.12] # Specify the desired Python versions
3516

3617
steps:
37-
- uses: actions/checkout@v3
38-
- name: Set up Python ${{ matrix.python-version }}
39-
uses: actions/setup-python@v4
40-
with:
41-
python-version: ${{ matrix.python-version }}
42-
- name: Install Dependencies
43-
shell: bash
44-
run: |
45-
python --version
46-
python -m pip install --upgrade pip
47-
python -m pip install .[test]
48-
- name: Run Tests
49-
shell: bash
50-
run: |
51-
export COVERAGE_FILE=coverage_${{ matrix.python-version }}
52-
pytest -n auto --cov --disable-pytest-warnings --cov-branch --cov-report=term
53-
- name: Upload coverage
54-
if: success()
55-
uses: actions/upload-artifact@v4
56-
with:
57-
name: coverage_${{ matrix.python-version }}
58-
path: coverage_${{ matrix.python-version }}
59-
60-
get-commit-message:
61-
runs-on: ubuntu-latest
62-
outputs:
63-
message: ${{ steps.get_commit_message.outputs.message }}
64-
steps:
65-
- uses: actions/checkout@v3
66-
with:
67-
ref: ${{ github.event.pull_request.head.sha }}
68-
- name: Get commit message
69-
id: get_commit_message
70-
run: |
71-
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
72-
echo "Commit message $COMMIT_MESSAGE"
73-
echo "::set-output name=message::$COMMIT_MESSAGE"
74-
75-
coverage:
76-
runs-on: ubuntu-latest
77-
needs: [test-cpu, get-commit-message]
78-
if: ${{ always() }}
79-
steps:
80-
- name: Checkout
81-
uses: actions/checkout@v3
82-
83-
- name: Collect Coverages
84-
uses: actions/download-artifact@v4
85-
with:
86-
path: coverage_data
87-
pattern: coverage_*
88-
merge-multiple: true
89-
90-
- name: Set up Python 3.10
91-
uses: actions/setup-python@v4
92-
with:
93-
python-version: ${{ env.PYTHON_VERSION }}
94-
95-
- name: add the coverage tool
96-
shell: bash
97-
run: |
98-
python -m pip install --upgrade pip
99-
python -m pip install coverage[toml]
100-
python -m pip install -e .
101-
102-
- name: Combine coverage
103-
run: |
104-
export COVERAGE_FILE=coverage_combined
105-
coverage combine -a coverage_data/*
18+
- name: Checkout code
19+
uses: actions/checkout@v4
10620

107-
- name: Upload Combined coverage
108-
uses: actions/upload-artifact@v4
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
10923
with:
110-
name: coverage_combined
111-
path: coverage_combined
112-
113-
- name: Reports
114-
run: |
115-
export COVERAGE_FILE=coverage_combined
116-
coverage xml
117-
coverage report
118-
echo COVERAGE_PERC=$(coverage report | tail -n 1 | grep -oE [0-9\.]*?% | cut -d '%' -f1) >> $GITHUB_ENV
24+
python-version: ${{ matrix.python-version }}
11925

120-
- name: Create a Coverage Badge
121-
if: ${{github.event_name == 'push'}}
26+
- name: Install dependencies
12227
run: |
123-
wget https://img.shields.io/badge/coverage-${{env.COVERAGE_PERC}}%25-green -O coverage_badge.svg
28+
pip install .[test]
12429
125-
- name: Upload badge as artifact
126-
if: ${{github.event_name == 'push'}}
127-
uses: actions/upload-artifact@v4
30+
- name: Run tests
31+
run: pytest --cov --cov-report=xml tests
32+
33+
- name: Upload coverage reports to Codecov
34+
uses: codecov/codecov-action@v4.0.1
12835
with:
129-
name: coverage_badge
130-
path: coverage_badge.svg
36+
token: ${{ secrets.CODECOV_TOKEN }}
37+
slug: INFN-MRI/torchsim
13138

132-
BuildDocs:
133-
name: Build API Documentation
134-
runs-on: ubuntu-latest
135-
needs: get-commit-message
136-
if: ${{ contains(needs.get-commit-message.outputs.message, '!docs_build') || github.ref == 'refs/heads/main' }}
39+
docs:
40+
runs-on: ubuntu-20.04
41+
needs: test
13742
steps:
13843
- name: Checkout
139-
uses: actions/checkout@v3
44+
uses: actions/checkout@v4
14045

141-
- name: Get history and tags for SCM versioning to work
142-
run: |
143-
git fetch --prune --unshallow
144-
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
145-
14646
- name: Set up Python
147-
uses: actions/setup-python@v4
47+
uses: actions/setup-python@v5
14848
with:
14949
python-version: "3.10"
15050

151-
- name: Restore cached ixi directory
51+
- name: Restore cached IXI directory
15252
uses: actions/cache/restore@v4
15353
id: cache-restore
15454
with:
@@ -166,49 +66,22 @@ jobs:
16666
run: |
16767
python -m sphinx docs docs_build
16868
169-
- name: Display data
170-
run: ls -R
171-
working-directory: docs_build/_static
69+
- name: Display structure of docs
70+
run: ls -R docs_build/
17271

173-
- name: Cache ixi directory
72+
- name: Cache IXI directory
17473
uses: actions/cache/save@v4
17574
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
17675
with:
17776
path: ~/.ixi
178-
key: ${{ runner.os }}-ixi
179-
180-
- name: Upload artifact
181-
id: artifact-upload-step
182-
uses: actions/upload-artifact@v4
183-
with:
184-
# Upload the docs
185-
name: docs
186-
path: 'docs_build'
187-
retention-days: 5
188-
189-
CompileDocs:
190-
name: Compile the coverage badge in docs
191-
runs-on: ubuntu-latest
192-
if: ${{ github.ref == 'refs/heads/main' }}
193-
needs: [BuildDocs, coverage]
194-
steps:
195-
- name: Get the docs_build artifact
196-
uses: actions/download-artifact@v4
197-
with:
198-
name: docs
199-
path: docs_build
200-
overwrite: true
201-
202-
- name: Get the badge from CI
203-
uses: actions/download-artifact@v4
204-
with:
205-
name: coverage_badge
206-
path: docs_build/_static
207-
github-token: ${{ secrets.GITHUB_TOKEN }}
77+
key: ${{ runner.os }}-ixi
20878

209-
- name: ReUpload artifacts
210-
uses: actions/upload-artifact@v4
79+
- name: Deploy to GitHub Pages
80+
uses: peaceiris/actions-gh-pages@v4
21181
with:
212-
name: docs_final
213-
retention-days: 20
214-
path: docs_build
82+
github_token: ${{ secrets.GITHUB_TOKEN }}
83+
publish_dir: ./docs_build
84+
destination_dir: . # Ensure you deploy to the root of the gh-pages branch
85+
publish_branch: gh-pages
86+
keep_files: false
87+

README.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ TorchSim is a pure Pytorch-based MR simulator, including analytical and EPG mode
55

66
|Coverage| |CI| |CD| |License| |Codefactor| |Sphinx| |PyPi| |Black| |PythonVersion|
77

8-
.. |Coverage| image:: https://infn-mri.github.io/torchsim/_static/coverage_badge.svg
9-
:target: https://infn-mri.github.io/torchsim
10-
11-
.. |CI| image:: https://github.com/INFN-MRI/torchsim/workflows/CI/badge.svg
12-
:target: https://github.com/INFN-MRI/torchsim
8+
.. |Coverage| image:: https://codecov.io/gh/INFN-MRI/torchsim/graph/badge.svg?token=qtB53xANwI
9+
:target: https://codecov.io/gh/INFN-MRI/torchsim
1310

14-
.. |CD| image:: https://github.com/INFN-MRI/torchsim/workflows/CD/badge.svg
11+
.. |CI/CD| image:: https://github.com/INFN-MRI/torchsim/workflows/CI-CD/badge.svg
1512
:target: https://github.com/INFN-MRI/torchsim
1613

1714
.. |License| image:: https://img.shields.io/github/license/INFN-MRI/torchsim

docs/sg_execution_times.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Computation times
88
=================
9-
**01:31.589** total execution time for 4 files **from all galleries**:
9+
**01:07.135** total execution time for 4 files **from all galleries**:
1010

1111
.. container::
1212

@@ -33,14 +33,14 @@ Computation times
3333
- Time
3434
- Mem (MB)
3535
* - :ref:`sphx_glr_generated_autoexamples_02-synth-data.py` (``../examples/02-synth-data.py``)
36-
- 00:41.073
36+
- 00:42.438
3737
- 0.0
3838
* - :ref:`sphx_glr_generated_autoexamples_03-fitting.py` (``../examples/03-fitting.py``)
39-
- 00:24.580
40-
- 0.0
41-
* - :ref:`sphx_glr_generated_autoexamples_04-derivatives.py` (``../examples/04-derivatives.py``)
42-
- 00:14.056
39+
- 00:24.697
4340
- 0.0
4441
* - :ref:`sphx_glr_generated_autoexamples_01-simple-simulator.py` (``../examples/01-simple-simulator.py``)
45-
- 00:11.881
42+
- 00:00.000
43+
- 0.0
44+
* - :ref:`sphx_glr_generated_autoexamples_04-derivatives.py` (``../examples/04-derivatives.py``)
45+
- 00:00.000
4646
- 0.0

0 commit comments

Comments
 (0)