Skip to content

Commit

Permalink
Update gh-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nimish committed May 4, 2024
1 parent dbb7b86 commit 4d1e780
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 62 deletions.
48 changes: 28 additions & 20 deletions .github/workflows/build.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Deploy Main
on:
release:
types: [published]

env:
PYTHON_VERSION: "3.12"

jobs:
deploy-pypi:
runs-on: ubuntu-latest
Expand All @@ -11,20 +15,22 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: true

- name: Install Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Twine and Build
run: sudo pip install twine build

- name: Create the distribution
- name: Setup and build
run: |
git fetch --prune --unshallow --tags
sudo python3 -m build
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system --break-system-packages -r requirements.txt
uv pip install --system --break-system-packages twine build
python3 -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand All @@ -35,18 +41,20 @@ jobs:
defaults:
run:
shell: bash -l {0}
environment: deployment
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: true

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: ${{ env.PYTHON_VERSION }}

# Much better than manual installation, original version Miniconda2-4.7.10-Linux-x86_64.sh is broken
- name: Install Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: true
activate-environment: ""
Expand All @@ -57,9 +65,8 @@ jobs:
conda config --set always_yes yes --set auto_update_conda false
conda update conda
conda install -n base conda-libmamba-solver
conda install python=3.10 conda-build colorama pip ruamel ruamel.yaml rich jsonschema -c conda-forge
git fetch --prune --unshallow --tags
pip install -e .
conda install python=${{ env.PYTHON_VERSION }} conda-build colorama pip ruamel ruamel.yaml rich jsonschema uv -c conda-forge
uv pip install -e .
# echo yes before login to prevent anaconda bug breaking automation
# git tags MUST be fetched otherwise output will be blank
Expand All @@ -71,10 +78,11 @@ jobs:
conda install anaconda-client
conda config --set anaconda_upload no --set solver libmamba
echo yes | anaconda login --username ${{ secrets.ANACONDA_CLOUD_USERNAME }} --password ${{ secrets.ANACONDA_CLOUD_PASSWORD }}
VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c mosek -c anaconda -c pvlib -c slacgismo -c conda-forge -c stanfordcvxgrp
echo "gitversion=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)" >> $GITHUB_OUTPUT
tag_ver=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)
echo "gitversion=${tag_ver}" >> $GITHUB_OUTPUT
VERSION_FROM_GIT_TAG="${tag_ver}" conda build . -c mosek -c anaconda -c pvlib -c slacgismo -c conda-forge -c stanfordcvxgrp
- name: Upload the Anaconda Package
id: condaload
run: |
anaconda upload -u slacgismo /usr/share/miniconda3/conda-bld/noarch/solar-data-tools-${{ steps.condabuild.outputs.gitversion }}-*.tar.bz2
anaconda upload -u slacgismo /usr/share/miniconda3/conda-bld/noarch/solar-data-tools-${{ steps.condabuild.outputs.gitversion }}-*.tar.bz2
48 changes: 29 additions & 19 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,50 @@ on:
jobs:
build-pypi:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- uses: actions/setup-python@v4
uses: actions/checkout@v4
with:
python-version: "3.10"
fetch-depth: 1
fetch-tags: true

- name: Install Twine and Build
run: sudo pip install twine build
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Create the distribution
- name: Setup and build
run: |
git fetch --prune --unshallow --tags
sudo python3 -m build
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system --break-system-packages -r requirements.txt
uv pip install --system --break-system-packages twine build
python3 -m build
build-conda:
runs-on: ubuntu-latest
# sets default shell to remove need for source to run the conda shell
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
defaults:
run:
shell: bash -l {0}
environment: test-deployment
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: true

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: ${{ matrix.python-version }}

# Much better than manual installation, original version Miniconda2-4.7.10-Linux-x86_64.sh is broken
- name: Install Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: true
activate-environment: ""
Expand All @@ -50,9 +60,8 @@ jobs:
conda config --set always_yes yes --set auto_update_conda false
conda update conda
conda install -n base conda-libmamba-solver
conda install python=3.10 conda-build colorama pip ruamel ruamel.yaml rich jsonschema -c conda-forge
git fetch --prune --unshallow --tags
pip install -e .
conda install python=${{matrix.python-version}} conda-build colorama pip ruamel ruamel.yaml rich jsonschema uv -c conda-forge
uv pip install -e .
# echo yes before login to prevent anaconda bug breaking automation
# git tags MUST be fetched otherwise output will be blank
Expand All @@ -63,5 +72,6 @@ jobs:
run: |
conda install anaconda-client
conda config --set anaconda_upload no --set solver libmamba
VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)test conda build . -c mosek -c anaconda -c pvlib -c slacgismo -c conda-forge -c stanfordcvxgrp
echo "gitversion=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)" >> $GITHUB_OUTPUT
tag_ver=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)
echo "gitversion=${tag_ver}" >> $GITHUB_OUTPUT
VERSION_FROM_GIT_TAG="${tag_ver}test" conda build . -c mosek -c anaconda -c pvlib -c slacgismo -c conda-forge -c stanfordcvxgrp
36 changes: 14 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.3.0
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.2
hooks:
- id: black
#- repo: https://github.com/pycqa/flake8
# rev: '' # pick a git hash / tag to point to
# hooks:
# - id: flake8
# args: # arguments to configure flake8
# # making isort line length compatible with black
# - "--max-line-length=88"
# - "--max-complexity=18"
# - "--select=B,C,E,F,W,T4,B9"
#
# # these are errors that will be ignored by flake8
# # check out their meaning here
# # https://flake8.pycqa.org/en/latest/user/error-codes.html
# - "--ignore=E203,E266,E501,W503,F403,F401,E402,C901,E741,F811,F841,E722"
- id: ruff
types_or: [python, pyi, jupyter]
verbose: true
args: [--exit-zero]
- id: ruff-format
types_or: [python, pyi, jupyter]
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.analysis.typeCheckingMode": "basic"
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ mosek = [
Homepage = "https://github.com/slacgismo/solar-data-tools"
Documentation = "https://solar-data-tools.readthedocs.io/"
"Bug Tracker" = "https://github.com/slacgismo/solar-data-tools/issues"
Discussions = "https://github.com/slacgismo/solar-data-tools/discussions"
Discussions = "https://github.com/slacgismo/solar-data-tools/discussions"

0 comments on commit 4d1e780

Please sign in to comment.