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

Refactor Workflow Linter #231

Merged
merged 60 commits into from
Mar 7, 2024
Merged

Refactor Workflow Linter #231

merged 60 commits into from
Mar 7, 2024

Conversation

joseph-flinn
Copy link
Contributor

@joseph-flinn joseph-flinn commented Dec 29, 2023

🎟️ Tracking

🚧 Type of change

  • 🧹 Tech debt (refactoring, code cleanup, dependency upgrades, etc.)

📔 Objective

Make the Workflow Linter more easily maintainable through abstracting Rules and creating Workflow, Job, and Step level objects to test against

📋 Code changes

This is almost a full rewrite. All of the files are new

📸 Screenshots

Output of no changes needed:
image

Output of failed jobs:
image

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@joseph-flinn joseph-flinn marked this pull request as ready for review January 9, 2024 19:03
@joseph-flinn joseph-flinn requested a review from a team as a code owner January 9, 2024 19:03
@mimartin12
Copy link
Contributor

While in review, I saw some unused imports for some files such as cli.py and settings.py. Figured I would just drop a comment instead of try to point them all out with GitHub suggestions 😄

lint-workflow/actions.json Outdated Show resolved Hide resolved
lint-workflow/settings.py Outdated Show resolved Hide resolved
lint-workflow/cli.py Outdated Show resolved Hide resolved
lint-workflow/lint.py Outdated Show resolved Hide resolved
@joseph-flinn
Copy link
Contributor Author

I think this is finally ready for review 😅. I'd like to push out packaging for PyPi to a followup task.

@joseph-flinn joseph-flinn marked this pull request as ready for review February 28, 2024 22:52
lint-workflow-v2/README.md Outdated Show resolved Hide resolved
lint-workflow-v2/README.md Outdated Show resolved Hide resolved
lint-workflow-v2/pyproject.toml Outdated Show resolved Hide resolved
lint-workflow-v2/pyproject.toml Show resolved Hide resolved
lint-workflow-v2/pyproject.toml.tpl Outdated Show resolved Hide resolved
lint-workflow-v2/tests/test_load.py Outdated Show resolved Hide resolved
lint-workflow-v2/tests/test_rule.py Outdated Show resolved Hide resolved
lint-workflow-v2/tests/test_step.py Outdated Show resolved Hide resolved
lint-workflow-v2/tests/test_utils.py Outdated Show resolved Hide resolved
lint-workflow-v2/tests/test_workflow.py Outdated Show resolved Hide resolved
mimartin12
mimartin12 previously approved these changes Feb 29, 2024
Copy link
Contributor

@mimartin12 mimartin12 left a comment

Choose a reason for hiding this comment

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

Nothing crazy from me on the changes. They look good.
I am curious how the reliability of the various usage of loading data from keys, with the assumption that the data will just be there.

For example, this assumes that there will be a value for tag_name, correct me if I am wrong, but I think we personally have run into situations where there wasn't a tag available. This would raise a KeyError that isn't handled by the application itself.

tag_name = json.loads(response.data)["tag_name"]

This isn't necessarily something that must change today, but something in the future that would improve the reliability of the linting application.

@joseph-flinn
Copy link
Contributor Author

Yikes...we need to figure out that rate limiting issue...

@joseph-flinn
Copy link
Contributor Author

I am curious how the reliability of the various usage of loading data from keys, with the assumption that the data will just be there.

@mimartin12 I definitely think that that resiliency should be built-in. This is a great callout. We shouldn't be assuming that there is data. I'll go back through and update these in all of the places that I can find.

@joseph-flinn
Copy link
Contributor Author

joseph-flinn commented Feb 29, 2024

After a quick scan, it seems like the major offender (and I believe the only offender) is src.bitwarden_workflow_linter.actions:get_latest_version which is interacting with the GitHub API

I think we are implicitly safe since all GitHub Release will have a tag and an associated tag_name. Similarly, there is a high chance that we are implicitly safe with the response from asking for the data associated with the tag. But to be on the safe side for now, I've wrapped the logic in a specific GitHubResponseSchemaError to alert us to a change in the GitHub Repsonse that would break the current logic. It doesn't fix the resiliency issue, but brings a bit more visibility if this happens

mimartin12
mimartin12 previously approved these changes Feb 29, 2024
lint-workflow-v2/README.md Outdated Show resolved Hide resolved
lint-workflow-v2/README.md Outdated Show resolved Hide resolved
@joseph-flinn joseph-flinn enabled auto-merge (squash) March 7, 2024 15:53
@joseph-flinn joseph-flinn merged commit 4a07a79 into main Mar 7, 2024
4 checks passed
@joseph-flinn joseph-flinn deleted the feature/refactor-linter branch March 7, 2024 15:54
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

Successfully merging this pull request may close these issues.

4 participants