stoplightio / spectral-action

GitHub Action wrapper for Spectral - a JSON/YAML/OpenAPI/AsyncAPI/etc linter with custom rule support.
https://stoplight.io/open-source/spectral
Apache License 2.0
89 stars 46 forks source link

Run spectral action for a pull_request fails but shows pass #624

Open wirthual opened 2 years ago

wirthual commented 2 years ago

Describe the bug

We use spectral to lint documents in our repo, however if someone opens a pull request the process fails with the following message: Error: Resource not accessible by integration

Example see here: image

However, the action passes and does not fail

https://github.com/bundesAPI/autobahn-api/runs/4684070400?check_suite_focus=true

To Reproduce

  1. Create a pull request for a repo which uses the spectral action (v0.8.1)
  2. Execute linting on the merge request
  3. See error

Expected behavior

Linting runs on merge request branch and outputs linting errors and only passes if test is sucessful.

Additional context

Some research pointed towards the direction of missing permissions. I am wondering which permissions are required to perform the linting?

Screenshots If applicable, add screenshots to help explain your problem.

Environment (remove any that are not applicable):

image

jamietanna commented 2 years ago

Also seeing this with the action failing due to an ENOENT

Run stoplightio/spectral-action@v0.8.1
/usr/bin/docker run --name a682566c64977fe8747b39e0aa25d3519c4de_79ab50 --label 6a6825 --workdir /github/workspace --rm -e INPUT_FILE_GLOB -e INPUT_SPECTRAL_RULESET -e INPUT_REPO_TOKEN -e INPUT_EVENT_NAME -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/federated-api-model/federated-api-model":"/github/workspace" 6a6825:66c64977fe8747b39e0aa25d3519c4de
Using glob 'v1alpha/openapi.yml' under '/github/workspace', found files to lint
Running @stoplight/spectral-core v1.4.0
Loading ruleset '/github/workspace/schemas/.spectral.yml'...
Error: Failed to load ruleset '/github/workspace/schemas/.spectral.yml'... Error: ENOENT: no such file or directory, open '/github/workspace/schemas/@govuk-data-standards/spectral-ruleset-govuk-public@0.1.0'
Error: ENOENT: no such file or directory, open '/github/workspace/schemas/@govuk-data-standards/spectral-ruleset-govuk-public@0.1.0'

But showing as having passed

jamietanna commented 2 years ago

My error above is related to #625, but the check failing is still an issue

shavo007 commented 2 years ago

I get the same error Error: Resource not accessible by integration

https://github.com/shavo007/docker-kong/runs/5379810619?check_suite_focus=true#step:4:8

ikenna commented 2 years ago

"Some research pointed towards the direction of missing permissions. I am wondering which permissions are required to perform the linting?"

The error went away when I allowed all permissions (by removing my permissions entry), but as per above not clear to me which permission is required

ikenna commented 2 years ago

I am wondering which permissions are required to perform the linting?

This worked for me:

permissions:
  checks: write