-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Style | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
|
||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
PYTHON_VERSION: "3.10" | ||
|
||
jobs: | ||
linter-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: pip | ||
|
||
- name: Install Python deps | ||
shell: bash | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install black ruff | ||
python -m pip install -e . | ||
- name: Black Check | ||
shell: bash | ||
run: black . --diff --color --check | ||
|
||
# - name: ruff Check | ||
# shell: bash | ||
# run: ruff check src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,154 +1,54 @@ | ||
name: CI | ||
name: CI-CD | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
linter-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Python "3.10" | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Black setup | ||
shell: bash | ||
run: pip install black ruff mypy | ||
- name: Black Check | ||
shell: bash | ||
run: black . --diff --color --check | ||
|
||
test-cpu: | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: linter-check | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
python-version: ["3.12", "3.10"] | ||
python-version: [3.11, 3.12] # Specify the desired Python versions | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Dependencies | ||
shell: bash | ||
run: | | ||
python --version | ||
python -m pip install --upgrade pip | ||
python -m pip install .[test] | ||
- name: Run Tests | ||
shell: bash | ||
run: | | ||
export COVERAGE_FILE=coverage_${{ matrix.python-version }} | ||
pytest -n auto --cov --disable-pytest-warnings --cov-branch --cov-report=term | ||
- name: Upload coverage | ||
if: success() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage_${{ matrix.python-version }} | ||
path: coverage_${{ matrix.python-version }} | ||
|
||
get-commit-message: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
message: ${{ steps.get_commit_message.outputs.message }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Get commit message | ||
id: get_commit_message | ||
run: | | ||
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | ||
echo "Commit message $COMMIT_MESSAGE" | ||
echo "::set-output name=message::$COMMIT_MESSAGE" | ||
coverage: | ||
runs-on: ubuntu-latest | ||
needs: [test-cpu, get-commit-message] | ||
if: ${{ always() }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Collect Coverages | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: coverage_data | ||
pattern: coverage_* | ||
merge-multiple: true | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: add the coverage tool | ||
shell: bash | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install coverage[toml] | ||
python -m pip install -e . | ||
- name: Combine coverage | ||
run: | | ||
export COVERAGE_FILE=coverage_combined | ||
coverage combine -a coverage_data/* | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Upload Combined coverage | ||
uses: actions/upload-artifact@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
name: coverage_combined | ||
path: coverage_combined | ||
|
||
- name: Reports | ||
run: | | ||
export COVERAGE_FILE=coverage_combined | ||
coverage xml | ||
coverage report | ||
echo COVERAGE_PERC=$(coverage report | tail -n 1 | grep -oE [0-9\.]*?% | cut -d '%' -f1) >> $GITHUB_ENV | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Create a Coverage Badge | ||
if: ${{github.event_name == 'push'}} | ||
- name: Install dependencies | ||
run: | | ||
wget https://img.shields.io/badge/coverage-${{env.COVERAGE_PERC}}%25-green -O coverage_badge.svg | ||
pip install .[test] | ||
- name: Upload badge as artifact | ||
if: ${{github.event_name == 'push'}} | ||
uses: actions/upload-artifact@v4 | ||
- name: Run tests | ||
run: pytest --cov --cov-report=xml tests | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
name: coverage_badge | ||
path: coverage_badge.svg | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
slug: INFN-MRI/torchsim | ||
|
||
BuildDocs: | ||
name: Build API Documentation | ||
runs-on: ubuntu-latest | ||
needs: get-commit-message | ||
if: ${{ contains(needs.get-commit-message.outputs.message, '!docs_build') || github.ref == 'refs/heads/main' }} | ||
docs: | ||
runs-on: ubuntu-20.04 | ||
needs: test | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get history and tags for SCM versioning to work | ||
run: | | ||
git fetch --prune --unshallow | ||
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Restore cached ixi directory | ||
- name: Restore cached IXI directory | ||
uses: actions/cache/restore@v4 | ||
id: cache-restore | ||
with: | ||
|
@@ -166,49 +66,22 @@ jobs: | |
run: | | ||
python -m sphinx docs docs_build | ||
- name: Display data | ||
run: ls -R | ||
working-directory: docs_build/_static | ||
- name: Display structure of docs | ||
run: ls -R docs_build/ | ||
|
||
- name: Cache ixi directory | ||
- name: Cache IXI directory | ||
uses: actions/cache/save@v4 | ||
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }} | ||
with: | ||
path: ~/.ixi | ||
key: ${{ runner.os }}-ixi | ||
|
||
- name: Upload artifact | ||
id: artifact-upload-step | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
# Upload the docs | ||
name: docs | ||
path: 'docs_build' | ||
retention-days: 5 | ||
|
||
CompileDocs: | ||
name: Compile the coverage badge in docs | ||
runs-on: ubuntu-latest | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
needs: [BuildDocs, coverage] | ||
steps: | ||
- name: Get the docs_build artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: docs | ||
path: docs_build | ||
overwrite: true | ||
|
||
- name: Get the badge from CI | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: coverage_badge | ||
path: docs_build/_static | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
key: ${{ runner.os }}-ixi | ||
|
||
- name: ReUpload artifacts | ||
uses: actions/upload-artifact@v4 | ||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v4 | ||
with: | ||
name: docs_final | ||
retention-days: 20 | ||
path: docs_build | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs_build | ||
destination_dir: . # Ensure you deploy to the root of the gh-pages branch | ||
publish_branch: gh-pages | ||
keep_files: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters