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
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

252 changes: 240 additions & 12 deletions .github/workflows/deploy-dev-release.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,257 @@
---
name: Deploy Pre-Release Artifacts
name: Deploy Release Artifacts

on:
push:
branches:
- develop
- develop
workflow_dispatch:

inputs:
release-version:
description: "Version number to use. If provided bump-rule will be ignored"
required: false
default: ""
type: string

defaults:
run:
shell: bash

env:
LANG: en_US.utf-8
LC_ALL: en_US.utf-8
PYTHON_VERSION: '3.10'
PYTHON_VERSION: "3.10"

jobs:
call-deploy-release:
deploy-dev-release:
runs-on: ubuntu-22.04
permissions:
contents: write # To push a branch
pull-requests: write # To create a PR from that branch
contents: write # To push a branch
pull-requests: write # To create a PR from that branch
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."

#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
# ref: develop
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python ${{ env.PYTHON_VERSION }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1.3.3
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

# #----------------------------------------------
# # load cached venv if cache exists
# #----------------------------------------------
# - name: Load cached venv
# id: cached-poetry-dependencies
# uses: actions/cache@v3
# with:
# path: .venv
# key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

# #----------------------------------------------
# # install dependencies if cache does not exist
# #----------------------------------------------
# - name: Install dependencies
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# run: poetry install --no-interaction --no-root

#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: |
./scripts/poetry_install.sh

# git checkout develop
# poetry lock --no-update
# poetry install --no-interaction

# - name: Use given release-version number
# if: inputs.release-version != ''
# run: |
# echo "Using given release version is ${{ inputs.release-version }}"
# poetry version ${{ inputs.release-version }}

# NEW_TAG=v$(poetry version --short)

# # we want to be able to use the variable in later
# # steps we set a NEW_TAG environmental variable
# echo "NEW_TAG=$(echo ${NEW_TAG})" >> $GITHUB_ENV
# # we don't want to update pyproject.toml yet. don't want this change to create merge conflict.
# # we don't really persist right version in pyproject.toml to figure out the next version. we use git tags.
# git restore pyproject.toml

#----------------------------------------------
# bump version number for patch
#----------------------------------------------
- name: Bump Version
run: |
# current_tag is the last tagged release in the repository. From there
# we need to remove the v from the beginning of the tag.
# echo "Bump rule is ${{ inputs.bump-rule }}"
# echo "Given release version is ${{ inputs.release-version }}"
dt=$(date +%Y.%-m.0)
if ! $(git tag -l "v*" = ''); then
# uses -V which is version sort to keep it monotonically increasing.
current_tag=$(git tag -l "v*" | grep --invert-match '-' | sort --reverse -V | sed -n 1p)
echo "current git tag is ${current_tag}"
current_tag=${current_tag#?}
if [[ "$current_tag" < "$dt" ]]; then
current_tag=$dt
fi
# current_tag is now the version we want to set our poetry version so
# that we can bump the version
./scripts/run_on_each.sh poetry version ${current_tag}
./scripts/run_on_each.sh poetry version prerelease

# poetry version ${current_tag}
# poetry version prerelease --no-interaction

else
# very first release. start with inputs.release-version

echo "First release. Setting tag as 0.1.0rc0"
current_tag=$(date +%Y.%-m.1)
./scripts/run_on_each.sh poetry version ${current_tag}

# poetry version ${current_tag}
fi

NEW_TAG=v$(poetry version --short)

# Finally because we want to be able to use the variable in later
# steps we set a NEW_TAG environmental variable
echo "NEW_TAG=$(echo ${NEW_TAG})" >> $GITHUB_ENV
# we don't want to update pyproject.toml yet. don't want this change to create merge conflict.
# we don't really persist right version in pyproject.toml to figure out the next version. we use git tags.
#git restore pyproject.toml

# #--------------------------------------------------------------
# # Create a new releases/new_tag
# #--------------------------------------------------------------
# - name: Create a new releases branch
# run: |
# git checkout -b releases/${NEW_TAG}
# git push --set-upstream origin releases/${NEW_TAG}

# #--------------------------------------------------------------
# # merge changes back to main
# #--------------------------------------------------------------
# - name: Merge changes back to main
# run: |
# git checkout main
# git merge ${{ inputs.merge-strategy }} releases/${NEW_TAG}
# git push

# - name: Run tests on main branch
# id: run-tests-on-main
# run: |
# poetry run pytest --timeout=${{ inputs.run-tests-wait }} tests
# continue-on-error: true

# - name: Do something with a failing build
# if: steps.run-tests-on-main.outcome != 'success'
# run: |
# echo "tests on main did not succeed. Outcome is ${{ steps.run-tests-on-main.outcome }}"
# git reset --hard HEAD~1
# git push origin HEAD --force
# git branch -d releases/${NEW_TAG}
# git push origin --delete releases/${NEW_TAG}
# echo "reverted changes to main and removed release branch"
# exit 1

- name: Create build artifacts
run: |
set -x
set -u
set -e

# set the right version in pyproject.toml before build and publish
./scripts/poetry_build.sh
#./scripts/replace_path_deps.sh

# # all python packages, in topological order
# . scripts/projects.sh
# _projects=". ${PROJECTS}"
# echo "Running on following projects: ${_projects}"
# for p in $_projects
# do
# cd "${p}" || exit
# echo "==running in ${p}=="
# ../scripts/replace_path_deps.sh
# done

# poetry version ${NEW_TAG#?}
# poetry build -vvv

- name: Push artifacts to github
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*.gz,dist/*.whl"
artifactErrorsFailBuild: true
generateReleaseNotes: true
commit: ${{ github.ref }}
# check bump-rule and set accordingly
prerelease: true
tag: ${{ env.NEW_TAG }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to pypi
id: publish-to-pypi
if: github.repository_owner == 'GRIDAPPSD' || github.repository_owner == 'PNNL-CIM-Tools'
run: |
echo "POETRY_PUBLISH_OPTIONS=''" >> $GITHUB_ENV
./scripts/run_on_each.sh poetry config pypi-token.pypi ${{ secrets.pypi-token }}
./scripts/run_on_each.sh poetry publish

# - name: Publish to test-pypi
# id: publish-to-test-pypi
# if: ${{ inputs.publish-to-test-pypi }}
# run: |
# poetry config repositories.test-pypi https://test.pypi.org/legacy/
# poetry config pypi-token.test-pypi ${{ secrets.pypi-token }}
# poetry publish -r test-pypi
# continue-on-error: true

# - name: if publish to pypi/test-pypi failed revert main and delete release branch
# if: ${{ steps.publish-to-pypi.outcome != 'success' && steps.publish-to-test-pypi.outcome != 'success' }}
# run: |
# echo "publish to pypi/test-pypi did not succeed. Outcome for pypi = ${{ steps.publish-to-pypi.outcome }} outcome for test-pypi= ${{ steps.publish-to-test-pypi.outcome }}"
# git reset --hard HEAD~1
# git push origin HEAD --force
# git branch -d releases/${NEW_TAG}
# git push origin --delete releases/${NEW_TAG}
# echo "reverted changes to main and removed release branch"

uses: GRIDAPPSD/.github/.github/workflows/deploy-dev-release.yml@main
secrets:
git-token: ${{ secrets.GITHUB_TOKEN }}
pypi-token: ${{ secrets.PYPI_TOKEN }}
# - name: if publish to pypi/test-pypi failed delete release and tag on github
# if: ${{ ! (steps.publish-to-pypi.outcome == 'success' || steps.publish-to-test-pypi.outcome == 'success') }}
# uses: dev-drprasad/delete-tag-and-release@v0.2.1
# env:
# GITHUB_TOKEN: ${{ secrets.git-token }}
# with:
# tag_name: ${{ env.NEW_TAG }}

# - name: if publish to pypi/test-pypi failed exit with exit code 1
# if: ${{ steps.publish-to-pypi.outcome != 'success' && steps.publish-to-test-pypi.outcome != 'success' }}
# run: |
# exit 1
15 changes: 8 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on: [push, pull_request]

jobs:
push:
if: github.repository_owner == 'GRIDAPPSD' || github.repository_owner == 'PNNL-CIM-Tools'
runs-on: ubuntu-latest
name: Build and push the docker container
steps:
Expand All @@ -19,7 +20,7 @@ jobs:
- name: Log in to docker
run: |
if [ -n "${{ secrets.DOCKER_USERNAME }}" -a -n "${{ secrets.DOCKER_TOKEN }}" ]; then

echo " "
echo "Connecting to docker"
echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
Expand All @@ -29,7 +30,7 @@ jobs:
exit 1
fi
fi

- name: Build the image
env:
DOCKER_IMAGE_NAME: ${{ secrets.DOCKER_IMAGE_NAME }}
Expand Down Expand Up @@ -67,27 +68,27 @@ jobs:
ORG="${ORG:+${ORG}/}"
IMAGE="${ORG}${{ env.DOCKER_IMAGE_NAME }}"
if [ -n "${{ secrets.DOCKER_USERNAME }}" -a -n "${{ secrets.DOCKER_TOKEN }}" ]; then

if [ -n "$TAG" -a -n "$ORG" ]; then
# Get the built container name
CONTAINER=`docker images --format "{{.Repository}}:{{.Tag}}" ${IMAGE}`

echo "docker push ${CONTAINER}"
docker push "${CONTAINER}"
status=$?
if [ $status -ne 0 ]; then
echo "Error: status $status"
exit 1
fi

echo "docker tag ${CONTAINER} ${IMAGE}:$TAG"
docker tag ${CONTAINER} ${IMAGE}:$TAG
status=$?
if [ $status -ne 0 ]; then
echo "Error: status $status"
exit 1
fi

echo "docker push ${IMAGE}:$TAG"
docker push ${IMAGE}:$TAG
status=$?
Expand All @@ -96,5 +97,5 @@ jobs:
exit 1
fi
fi

fi
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ ENV/

# visual studio code
.vscode/

# pytest cache
.pytest_cache

30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-yaml
- id: check-json
- id: check-toml
- id: check-xml
- id: forbid-new-submodules
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-merge-conflict
- id: no-commit-to-branch # blocks main commits. To bypass do git commit --allow-empty
- id: pretty-format-json


#- repo: https://github.com/pre-commit/mirrors-autopep8
# rev: v1.6.0
# hooks:
# - id: autopep8

- repo: https://github.com/craig8/mirrors-yapf
rev: b84f670025671a341d0afd2b06b877b195d65c0f # Use the sha / tag you want to point at
hooks:
- id: yapf
name: yapf
description: "A formatter for Python files."
entry: yapf
language: python
types: [ python ]
Empty file added CHANGELOG.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there an empty changelog file added to the repo?

Empty file.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023.5.1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another Empty changelog file.

Empty file.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An empty readme file.

Empty file.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what this empty file is supposed to be and why it is present.

Empty file.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another empty changelog file. why are these present?

Empty file.
1 change: 1 addition & 0 deletions gridappsd-field-bus-lib/info/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023.5.1
Loading