Skip to content

Commit

Permalink
Fixed GH filtering & restored accidentally changed/deleted files
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWilkie committed Oct 12, 2023
1 parent 7475f08 commit 809800f
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 79 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/EVENT_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
with:
files: ${{ needs.get_changed_files.outputs.python_changed_files }}

typecheck:
name: Analyse types in python
needs: get_changed_files
uses: ./.github/workflows/JOB_typecheck.yml
with:
files: ${{ needs.get_changed_files.outputs.python_changed_files }}
# typecheck:
# name: Analyse types in python
# needs: get_changed_files
# uses: ./.github/workflows/JOB_typecheck.yml
# with:
# files: ${{ needs.get_changed_files.outputs.python_changed_files }}

run_tests:
needs: [format, lint, typecheck]
needs: [format, lint]
name: Run tests
uses: ./.github/workflows/JOB_tests.yml

114 changes: 56 additions & 58 deletions .github/workflows/EVENT_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ jobs:
needs: validate_tag
uses: ./.github/workflows/JOB_tests.yml

build:
needs: validate_tag
release:
needs: [run_tests]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -65,80 +66,77 @@ jobs:
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.3.1"

- name: Install dependencies
run: |
poetry install --no-interaction --no-root --all-extras -vvv
poetry build
- name: Add build to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dist/*
asset_name: ${{ env.release_id }}.tar.gz
asset_content_type: application/gzip

release:
needs: [run_tests, build]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Publish on pypi.org
env:
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
# poetry publish
echo "Publishing to pypi.org - Emulated"
poetry publish --build
test_release:
needs: [run_tests, build]
needs: [run_tests]
if: startsWith(github.ref, 'refs/tags/test-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- run: pip install pip --upgrade
- name: Setup Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.3.1"
- name: Check secrets are set
run: |
if [[ -z "${{ secrets.TEST_PYPI_USERNAME }}" || -z "${{ secrets.TEST_PYPI_PASSWORD }}" ]]; then
echo "TEST_PYPI_USERNAME and TEST_PYPI_PASSWORD must be set"
exit 1
fi
- name: Publish on test.pypi.org
env:
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
run: |
poetry publish
echo "Publishing to test.pypi.org - Emulated"
python ./deploy/nightly_package_setup.py
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config http-basic.test-pypi ${{ secrets.TEST_PYPI_USERNAME }} ${{ secrets.TEST_PYPI_PASSWORD }}
poetry publish --build --repository test-pypi
python ./deploy/revert_nightly_setup.py
# Linear tickets update

notify_release:
needs: [release, test_release]
if: always() && contains(needs.*.result, 'success')
runs-on: ubuntu-latest
steps:
- name: Notify Slack
uses: ./.github/workflows/JOB_slack_message.yml
with:
icon: ":rocket:"
at_team: ${{ env.is_scheduled || !env.is_draft }}
secrets: inherit
message: |
:tada: *${{ env.release_tag }}* has been released!
:link:
- https://pypi.org/project/darwin-py
- ${{ github.event.release.html_url }}
needs: [release]
if: success()
uses: ./.github/workflows/JOB_slack_message.yml
secrets: inherit
with:
icon: ":rocket:"
at_team: true
message: |
:tada: *${{ inputs.release_tag || github.event.release.tag_name }}* has been released!
:link:
- https://pypi.org/project/darwin-py
- ${{ github.event.release.html_url }}
notify_failed_release:
needs: [release, test_release]
if: always() && contains(needs.*.result, 'failure')
runs-on: ubuntu-latest
steps:
- name: Notify Slack
uses: ./.github/workflows/JOB_slack_message.yml
with:
secrets: inherit
icon: ":warning:"
at_team: true
message: |
:warning: *${{ env.release_tag }}* has failed to be released!
*An error occurred performing release, and you may need to release manually.*
:link:
- ${{ github.event.release.html_url }}
needs: [release]
if: failure()
uses: ./.github/workflows/JOB_slack_message.yml
secrets: inherit
with:
icon: ":warning:"
at_team: true
message: |
:warning: *${{ inputs.release_tag || github.event.release.tag_name }}* Release has failed to be released!
*An error occurred performing release, and you may need to release manually.*
:link:
- ${{ github.event.release.html_url }}
14 changes: 1 addition & 13 deletions .github/workflows/JOB_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,5 @@ jobs:
:link:
- https://github.com/v7labs/darwin-py/actions/runs/${{ github.run_id }}
:warning: ${{ github.workflow }} failed
:warning: ${{ github.workflow }} failed.
- name: Send Slack Notification
run: |
PAYLOAD=$(cat <<EOF
{
"channel": "#${{ vars.SLACK_CHANNEL }}",
"username": "${{ vars.SLACK_USERNAME }}",
"text": "",
"icon_emoji": "${{ vars.SLACK_ICON }}"
}
EOF
)
curl -X POST --data-urlencode "payload=$PAYLOAD" ${{ secrets.SLACK_WEBHOOK }}
2 changes: 1 addition & 1 deletion deploy/_filter_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def main(argv: List[str]) -> None:
if file_extension.startswith("."):
file_extension = file_extension[1:]

files_out = [file for file in files_in if file.endswith(f".{file_extension}") if "darwin/future" in file]
files_out = [file for file in files_in if file.endswith(f".{file_extension}") and "darwin/future" in file]

print(" ".join(files_out))

Expand Down
44 changes: 44 additions & 0 deletions deploy/nightly_package_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Require a single string argument, the new package name
# Example: python change_package_name.py com.example.newname

from datetime import datetime
from os import linesep
from pathlib import Path


def main() -> None:
epoch_timestring = datetime.now().strftime("%s")

this_file_path = Path(__file__).parent.resolve()
path_to_pyproject = this_file_path / ".." / "pyproject.toml"
path_to_version = this_file_path / ".." / "version.txt"

try:
assert path_to_pyproject.exists()
except AssertionError:
print("No pyproject.toml found.")
exit(1)

lines = path_to_pyproject.read_text().splitlines()
lines_to_write = []

for line in lines:
if line.startswith("name ="):
lines_to_write.append('name = "darwin-nightly"\n')
elif line.startswith("version ="):
version = line.split("=")[1].strip()
path_to_version.write_text(version)
lines_to_write.append(f'version = "{epoch_timestring}"\n')
else:
lines_to_write.append(line)

path_to_pyproject.write_text(linesep.join(lines_to_write))

print(f"Set build to a nightly in pyproject.toml - darwin-nightly@{epoch_timestring}")


if __name__ == "__main__":
main()
41 changes: 41 additions & 0 deletions deploy/revert_nightly_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from datetime import datetime
from os import path
from pathlib import Path


def main() -> None:
new_package_name = "darwin-py"

this_file_path = Path(__file__).parent.resolve()
path_to_pyproject = this_file_path / ".." / "pyproject.toml"
path_to_version = this_file_path / ".." / "version.txt"

try:
assert path_to_pyproject.exists()
assert path_to_version.exists()
except AssertionError:
print("No nightly build in place to revert")
exit(1)

lines = path_to_pyproject.read_text().splitlines()
new_version = path_to_version.read_text().strip()

lines_to_write = []

for line in lines:
if line.startswith("name ="):
line = f'name = "{new_package_name}"\n'
if line.startswith("version ="):
line = f'version = {new_version}\n'
lines_to_write.append(line)

path_to_pyproject.write_text("\n".join(lines_to_write))

print(f"Changed package name to {new_package_name}@{new_version} in pyproject.toml")


if __name__ == "__main__":
main()

0 comments on commit 809800f

Please sign in to comment.