Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 50 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.11'
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
Expand All @@ -27,6 +27,12 @@ jobs:
- "3.11"
steps:
- uses: actions/checkout@v3
- name: Install conda
run: |
wget -q -O /tmp/miniforge.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash /tmp/miniforge.sh -b -p "${HOME}/miniforge"
echo "${HOME}/miniforge/bin" >> "$GITHUB_PATH"
echo "CONDA=${HOME}/miniforge" >> "$GITHUB_ENV"
- name: Prepare environment
run: .github/workflows/prepare_environment.sh ${{ matrix.python_version }}
- name: Run pytest
Expand All @@ -42,12 +48,22 @@ jobs:
. "${CONDA}/bin/activate" test-env
pylint -E src/diraccfg/ tests/

publish-pypi:
build-pypi:
runs-on: ubuntu-latest
name: Publish package to PyPI
name: Build package
needs: [pytest, pre-commit]
outputs:
is-tag: ${{ steps.check-tag.outputs.is-tag }}
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Install conda
run: |
wget -q -O /tmp/miniforge.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash /tmp/miniforge.sh -b -p "${HOME}/miniforge"
echo "${HOME}/miniforge/bin" >> "$GITHUB_PATH"
echo "CONDA=${HOME}/miniforge" >> "$GITHUB_ENV"
- run: |
git fetch --prune --unshallow
- name: Prepare environment
Expand All @@ -56,9 +72,35 @@ jobs:
run: |
. "${CONDA}/bin/activate" test-env
python setup.py sdist bdist_wheel --universal
- name: Publish package
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
- name: Check if this is a tag push
id: check-tag
env:
IS_TAG: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }}
run: echo "is-tag=$IS_TAG" >> "$GITHUB_OUTPUT"
- name: Upload the distribution packages
if: steps.check-tag.outputs.is-tag == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: diraccfg-dist
path: dist/
retention-days: 5

# Only this job talks to PyPI; the build above runs without any PyPI credential.
publish-pypi:
runs-on: ubuntu-latest
name: Publish package to PyPI
needs: build-pypi
if: needs.build-pypi.outputs.is-tag == 'true' && needs.build-pypi.result == 'success'
environment: pypi
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing on pypi
steps:
- name: Download the distribution packages
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
user: __token__
password: ${{ secrets.pypi_password }}
name: diraccfg-dist
path: dist/
# Use trusted publisher for pypi
# https://docs.pypi.org/trusted-publishers/
- name: Publish package
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
5 changes: 2 additions & 3 deletions src/diraccfg/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,7 @@ def renameKey(self, oldName: str, newName: str) -> bool:
else:
return False

# def __getitem__(self, key: str) -> CFG | str | Literal[False]:
def __getitem__(self, key: str) -> CFG | str:
def __getitem__(self, key: str) -> CFG | str | Literal[False]:
"""
Get the contents of a section/option

Expand All @@ -653,7 +652,7 @@ def __getitem__(self, key: str) -> CFG | str:
if key.find("/") > -1:
subDict = self.getRecursive(key)
if not subDict:
return False # type: ignore
return False
# raise KeyError(key)
return subDict["value"]
return self.__dataDict[key]
Expand Down
Loading