Skip to content

Commit

Permalink
UPDATE: use hashset
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeebru committed Dec 19, 2023
1 parent cc0b05f commit 3061e7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 5 additions & 4 deletions lint-workflow/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,16 @@ def get_action_update(action_id):

def lint(filename):

supported_actions = {"act10ns/slack", "actions/cache", "actions/checkout", "actions/delete-package-versions", "actions/download-artifact", "actions/github-script", "actions/labeler", "actions/setup-dotnet", "actions/setup-java", "actions/setup-node", "actions/setup-python", "actions/stale", "actions/upload-artifact", "android-actions/setup-android", "Asana/create-app-attachment-github-action", "Azure/functions-action", "Azure/get-keyvault-secrets", "Azure/login", "azure/webapps-deploy", "bitwarden/sm-action", "checkmarx/ast-github-action", "chrnorm/deployment-action", "chrnorm/deployment-status", "chromaui/action", "cloudflare/pages-action", "convictional/trigger-workflow-and-wait", "crazy-max/ghaction-import-gpg", "crowdin/github-action", "dawidd6/action-download-artifact", "dawidd6/action-homebrew-bump-formula", "digitalocean/action-doctl", "docker/build-push-action", "docker/setup-buildx-action", "docker/setup-qemu-action", "dorny/test-reporter", "dtolnay/rust-toolchain", "futureware-tech/simulator-action", "hashicorp/setup-packer", "macauley/action-homebrew-bump-cask", "microsoft/setup-msbuild", "ncipollo/release-action", "peter-evans/close-issue", "ruby/setup-ruby", "samuelmeuli/action-snapcraft", "snapcore/action-build", "sonarsource/sonarcloud-github-action", "stackrox/kube-linter-action", "Swatinem/rust-cache", "SwiftDocOrg/github-wiki-publish-action", "SwiftDocOrg/swift-doc", "tj-actions/changed-files", "yogevbd/enforce-label-action"}



findings = []
max_error_level = 0

with open(filename) as file:
workflow = yaml.load(file, Loader=yaml.FullLoader)

with open("supported-actions.json") as file:
supported_actions = json.load(file)

# Check for 'name' key for the workflow.
if "name" not in workflow:
findings.append(LintFinding("Name key missing for workflow.", "warning"))
Expand Down Expand Up @@ -299,7 +300,7 @@ def lint(filename):
if "bitwarden/gh-actions" not in path:
try:
# Check if actions are in supported actions list.
if path != supported_actions[path]:
if path not in supported_actions:
findings.append(
LintFinding(
f"Step {str(i)} of job key '{job_key}' uses an unsupported action: {path}.",
Expand Down
2 changes: 0 additions & 2 deletions lint-workflow/supported-actions.json
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
{ "act10ns/slack": "act10ns/slack", "actions/cache": "actions/cache", "actions/checkout": "actions/checkout", "actions/delete-package-versions": "actions/delete-package-versions", "actions/download-artifact": "actions/download-artifact", "actions/github-script": "actions/github-script", "actions/labeler": "actions/labeler", "actions/setup-dotnet": "actions/setup-dotnet", "actions/setup-java": "actions/setup-java", "actions/setup-node": "actions/setup-node", "actions/setup-python": "actions/setup-python", "actions/stale": "actions/stale", "actions/upload-artifact": "actions/upload-artifact", "android-actions/setup-android": "android-actions/setup-android", "Asana/create-app-attachment-github-action": "Asana/create-app-attachment-github-action", "Azure/functions-action": "Azure/functions-action", "Azure/get-keyvault-secrets": "Azure/get-keyvault-secrets", "Azure/login": "Azure/login", "azure/webapps-deploy": "azure/webapps-deploy", "bitwarden/sm-action": "bitwarden/sm-action", "checkmarx/ast-github-action": "checkmarx/ast-github-action", "chrnorm/deployment-action": "chrnorm/deployment-action", "chrnorm/deployment-status": "chrnorm/deployment-status", "chromaui/action": "chromaui/action", "cloudflare/pages-action": "cloudflare/pages-action", "convictional/trigger-workflow-and-wait": "convictional/trigger-workflow-and-wait", "crazy-max/ghaction-import-gpg": "crazy-max/ghaction-import-gpg", "crowdin/github-action": "crowdin/github-action", "dawidd6/action-download-artifact": "dawidd6/action-download-artifact", "dawidd6/action-homebrew-bump-formula": "dawidd6/action-homebrew-bump-formula", "digitalocean/action-doctl": "digitalocean/action-doctl", "docker/build-push-action": "docker/build-push-action", "docker/setup-buildx-action": "docker/setup-buildx-action", "docker/setup-qemu-action": "docker/setup-qemu-action", "dorny/test-reporter": "dorny/test-reporter", "dtolnay/rust-toolchain": "dtolnay/rust-toolchain", "futureware-tech/simulator-action": "futureware-tech/simulator-action", "hashicorp/setup-packer": "hashicorp/setup-packer", "macauley/action-homebrew-bump-cask": "macauley/action-homebrew-bump-cask", "microsoft/setup-msbuild": "microsoft/setup-msbuild", "ncipollo/release-action": "ncipollo/release-action", "peter-evans/close-issue": "peter-evans/close-issue", "ruby/setup-ruby": "ruby/setup-ruby", "samuelmeuli/action-snapcraft": "samuelmeuli/action-snapcraft", "snapcore/action-build": "snapcore/action-build", "sonarsource/sonarcloud-github-action": "sonarsource/sonarcloud-github-action", "stackrox/kube-linter-action": "stackrox/kube-linter-action", "Swatinem/rust-cache": "Swatinem/rust-cache", "SwiftDocOrg/github-wiki-publish-action": "SwiftDocOrg/github-wiki-publish-action", "SwiftDocOrg/swift-doc": "SwiftDocOrg/swift-doc", "tj-actions/changed-files": "tj-actions/changed-files", "yogevbd/enforce-label-action": "yogevbd/enforce-label-action"}

0 comments on commit 3061e7e

Please sign in to comment.