super-linter / super-linter

Combination of multiple linters to run as a GitHub Action or standalone
https://github.com/super-linter/super-linter
MIT License
9.48k stars 969 forks source link

Improve SHA mismatch error message #5315

Closed TrentSteenholdt-Insight closed 8 months ago

TrentSteenholdt-Insight commented 8 months ago

Is there an existing issue for this?

Current Behavior

Super Linter v6 on Pull Request pipeline run fails with

2024-02-22 01:35:33 [FATAL] The GITHUB_SHA reference (xxxx) doesn't exist in this Git repository

---
name: PR

on:
  pull_request:
    branches:
      - main

env:
  PSRULE_DIRECTORY: ./

jobs:
  linting:
    name: Linting
    runs-on: ubuntu-latest

    permissions:
      contents: read
      packages: read
      statuses: write

    steps:
      - name: Check-Out Repository
        uses: actions/checkout@v4

        # Linting
      - name: Run GitHub Super-Linter
        uses: super-linter/super-linter@v6
        env:
          DEFAULT_BRANCH: 'main'
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          VALIDATE_JSON: true
          VALIDATE_MARKDOWN: true
          VALIDATE_POWERSHELL: true
          VALIDATE_YAML: true
          FILTER_REGEX_EXCLUDE: ^.*/src/modules/[^/]+/.*\.md$

Expected Behavior

In version v5, the same YAML works fine

---
name: PR

on:
  pull_request:
    branches:
      - main

env:
  PSRULE_DIRECTORY: ./

jobs:
  linting:
    name: Linting
    runs-on: ubuntu-latest

    permissions:
      contents: read
      packages: read
      statuses: write

    steps:
      - name: Check-Out Repository
        uses: actions/checkout@v4

        # Linting
      - name: Run GitHub Super-Linter
        uses: super-linter/super-linter@v5
        env:
          DEFAULT_BRANCH: 'main'
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          VALIDATE_JSON: true
          VALIDATE_MARKDOWN: true
          VALIDATE_POWERSHELL: true
          VALIDATE_YAML: true
          FILTER_REGEX_EXCLUDE: ^.*/src/modules/[^/]+/.*\.md$

Super-Linter version

v6 latest (v6.2.0)

Relevant log output

/usr/bin/docker run --name ghcriosuperlintersuperlinterv620_2fa901 --label 72f98f --workdir /github/workspace --rm -e "PSRULE_DIRECTORY" -e "INFRA_WORKING_DIRECTORY" -e "github_user_name" -e "github_email" -e "github_commit_message" -e "github_pr_number" -e "github_pr_repo" -e "DEFAULT_BRANCH" -e "GITHUB_TOKEN" -e "VALIDATE_JSON" -e "VALIDATE_MARKDOWN" -e "VALIDATE_POWERSHELL" -e "VALIDATE_YAML" -e "FILTER_REGEX_EXCLUDE" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_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_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -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 "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_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/azure-landing-zones-vending-machine/azure-landing-zones-vending-machine":"/github/workspace" ghcr.io/super-linter/super-linter:v6.2.0
Super-Linter initialization
  --------------------------------------------------------------------------------

                                /@@#///////@@/(@//@%/(@.@(       @@
                            @@//////////////////////////////#*  @@@
                          @////@//(///////////@@@@@///@//@/@**//@@(
                        @///////@///////////////@@@@    (           @,
                       @/(&/@////////////////////                     @
                      @////////////////////////@@                      @
                    @%////////(//////////%/////&@            @@       *,@           ______________
               @@@@@/@/#/////(&//////////////////                       .@         /              \
          *@@@@@.    .%///(//@//////////////////&.   .@@,                 @%      / Don't mind me  \
        @@%           .&@&&/@.@//&/////(//////////    @@@@@@@@@         .. &@    / I'm just looking \
      @@%               @@@@@   @&/////////////////#   @/       V  @@/ ,@@@ @   <  for some trash... |
  @@@%                   @@@@        .%@@@@//////#@ @   @@         @     .,.     \__________________/
                                            @@@/@(  (@@@@% @/\      %
                                             @@@@(    .     .@@/\   #
                                               @                  %@%

  --------------------------------------------------------------------------------
  2024-02-22 01:35:32 [INFO]   ---------------------------------------------
  2024-02-22 01:35:32 [INFO]   --- GitHub Actions Multi Language Linter ----
  2024-02-22 01:35:32 [INFO]    - Image Creation Date: 2024-02-20T21:39:00Z
  2024-02-22 01:35:32 [INFO]    - Image Revision: 25003d0370b45d97187597838ecb9fdadfc08aea
  2024-02-22 01:35:32 [INFO]    - Image Version: 25003d0370b45d97187597838ecb9fdadfc08aea
  2024-02-22 01:35:32 [INFO]   ---------------------------------------------
  2024-02-22 01:35:32 [INFO]   ---------------------------------------------
  2024-02-22 01:35:32 [INFO]   The Super-Linter source code can be found at:
  2024-02-22 01:35:32 [INFO]    - https://github.com/super-linter/super-linter
  2024-02-22 01:35:32 [INFO]   ---------------------------------------------
  2024-02-22 01:35:32 [INFO]   - Validating all files in code base...
  chktex: chktex: WARNING -- Could not find global resource file.
  ChkTeX v1.7.8 - Copyright 1995-96 Jens T. Berger Thielemann.
  Compiled with POSIX extended regex support.
  rubocop: 1.60.2
  perl: 
  This is perl 5, version 38, subversion 2 (v5.38.2) built for x86_64-linux-thread-multi

  Copyright 1987-2023, Larry Wall

  Perl may be copied only under the terms of either the Artistic License or the
  GNU General Public License, which may be found in the Perl 5 source kit.

  Complete documentation for Perl, including FAQ lists, should be found on
  this system using "man perl" or "perldoc perl".  If you have access to the
  Internet, point your browser at https://www.perl.org/, the Perl Home Page.
  xmllint: xmllint: using libxml version 21106
     compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 HTTP DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Schemas Schematron Modules Debug Zlib Lzma 
  ansible-lint: ansible-lint 24.2.0 using ansible-core:2.16.3 ansible-compat:4.1.11 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
  eslint: v8.56.0
  markdownlint: 0.39.0
  snakefmt: snakefmt, version 0.10.0
  cpplint: Cpplint fork (https://github.com/cpplint/cpplint)
  cpplint 1.6.1
  Python 3.12.2 (main, Feb  7 2024, 22:13:24) [GCC 13.2.1 20231014]
  editorconfig-checker: 2.7.2
  gitleaks: v8.18.2
  phpstan: PHPStan - PHP Static Analysis Tool 1.10.48
  dotenv-linter: dotenv-linter 3.3.0
  asl-validator: 3.8.2
  actionlint: 1.6.26
  installed by building from source
  built with go1.21.1 compiler for linux/amd64
  tekton-lint: 1.0.0-beta.9
  terrascan: version: v1.18.11
  terraform: Terraform v1.7.3
  on linux_amd64
  2024/02/20 18:33:30 traces export: Post "http:///dev/otel-grpc.sock": http: no Host in request URL
  2024/02/20 18:33:30 traces export: Post "http:///dev/otel-grpc.sock": http: no Host in request URL
  clippy: clippy 0.1.72
  R: R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
  Copyright (C) 2023 The R Foundation for Statistical Computing
  Platform: x86_64-pc-linux-musl (64-bit)

  R is free software and comes with ABSOLUTELY NO WARRANTY.
  You are welcome to redistribute it under the terms of the
  GNU General Public License versions 2 or 3.
  For more information about these matters see
  https://www.gnu.org/licenses/.
  rustfmt: rustfmt 1.6.0-stable ( )
  shellcheck: ShellCheck - shell script analysis tool
  version: 0.9.0
  license: GNU General Public License, version 3
  website: https://www.shellcheck.net
  jscpd: 3.5.10
  black: black, 24.2.0 (compiled: no)
  Python (CPython) 3.12.2
  prettier: 3.2.5
  php: PHP 8.2.15 (cli) (built: Jan 18 2024 16:40:05) (NTS)
  Copyright (c) The PHP Group
  Zend Engine v4.2.15, Copyright (c) Zend Technologies
  textlint: v14.0.3
  npm-groovy-lint: GroovyLint: Successfully processed CodeNarc: 
  CodeNarc version 3.3.0
  npm-groovy-lint version 14.2.2

  Embeds:
  CodeNarc version 3.3.0
  - Groovy version 3.0.9 (superlite)
  renovate-config-validator: (node:239) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
  (Use `node --trace-deprecation ...` to show where the warning was created)
  37.202.2
  golangci-lint: golangci-lint has version 1.56.2 built with go1.22.0 from 58a724a0 on 2024-02-15T20:35:23Z
  kubeconform: v0.6.4
  golangci-lint: golangci-lint has version 1.56.2 built with go1.22.0 from 58a724a0 on 2024-02-15T20:35:23Z
  gherkin-lint: Version command not supported
  eslint: v8.56.0
  scalafmt: scalafmt 3.7.17
  stylelint: 15.11.0
  sqlfluff: sqlfluff, version 2.3.5
  bash-exec: Version command not supported
  google-java-format: google-java-format: Version 1.19.2
  phpcs: PHP_CodeSniffer version 3.8.0 (stable) by Squiz and PHPCSStandards
  terragrunt: terragrunt version v0.55.2
  psalm: Psalm 5.22.1@e9dad66e11274315dac27e08349c628c7d6a1a43
  pylint: pylint 3.0.3
  astroid 3.0.3
  Python 3.12.2 (main, Feb  7 2024, 22:13:24) [GCC 13.2.1 20231014]
  shfmt: v3.8.0
  snakemake: 8.4.9
  arm-ttk: ModuleVersion = 0.24
  pwsh: PowerShell 7.4.1
  mypy: mypy 1.8.0 (compiled: yes)
  eslint: v8.56.0
  coffeelint: 5.2.11
  tflint: TFLint version 0.50.3
  + ruleset.terraform (0.5.0-bundled)
  cfn-lint: cfn-lint 0.85.2
  flake8: 7.0.0 (mccabe: 0.7.0, pycodestyle: 2.11.1, pyflakes: 3.2.0) CPython 3.12.2 on
  Linux
  spectral: 6.11.0
  clj-kondo: clj-kondo v2024.02.12
  eslint: v8.56.0
  ts-standard: 12.0.2
  eslint: v8.56.0
  protolint: protolint version 0.47.5(80ba08f)
  raku: Welcome to Rakudo™ v2023.11.
  Implementing the Raku® Programming Language v6.d.
  Built on MoarVM version 2023.11.
  prettier: 3.2.5
  hadolint: Haskell Dockerfile Linter 2.12.0
  checkstyle: Checkstyle version: 10.13.0
  clang-format: clang-format version 17.0.5 (https://github.com/llvm/llvm-project.git 98bfdac5ce82d1679f8af9a57501471812ab68d7)
  ktlint: 1.1.1
  yamllint: yamllint 1.35.1
  dart: Dart SDK version: 3.3.0 (stable) (Tue Feb 13 10:25:19 2024 +0000) on "linux_x64"
  isort: 
                   _                 _
                  (_) ___  ___  _ __| |_
                  | |/ _/ / _ \/ '__  _/
                  | |\__ \/\_\/| |  | |_
                  |_|\___/\___/\_/   \_/

        isort your imports, so you don't have to.

                      VERSION 5.13.2
  dotnet: 8.0.101
  eslint: v8.56.0
  rustfmt: rustfmt 1.6.0-stable ( )
  htmlhint: 1.1.4
  rustfmt: rustfmt 1.6.0-stable ( )
  sql-lint: 1.0.0
  checkov: 3.2.22
  lua: Lua 5.3.5  Copyright (C) 1994-2018 Lua.org, PUC-Rio
  standard: 17.1.0
  2024-02-22 01:35:32 [INFO]   --------------------------------------------
  2024-02-22 01:35:32 [INFO]   Gathering GitHub information...
  2024-02-22 01:35:32 [INFO]   Successfully validated GITHUB_WORKSPACE: /github/workspace
  2024-02-22 01:35:32 [INFO]   Successfully found GITHUB_EVENT_PATH: /github/workflow/event.json]
  2024-02-22 01:35:32 [INFO]   Successfully found GITHUB_SHA: f949888b8ab4e8f7b1eb5394da82dde922e00a02
  2024-02-22 01:35:32 [INFO]   Successfully found GITHUB_ORG: Insight-Services-APAC
  2024-02-22 01:35:32 [INFO]   Successfully found GITHUB_REPO: azure-landing-zones-vending-machine
  2024-02-22 01:35:32 [INFO]   The default branch for this repository is set to: main
  2024-02-22 01:35:32 [INFO]   Successfully found GITHUB_TOKEN.
  2024-02-22 01:35:32 [INFO]   Successfully found GITHUB_REPOSITORY: Insight-Services-APAC/azure-landing-zones-vending-machine
  2024-02-22 01:35:32 [INFO]   Successfully found GITHUB_RUN_ID 7998125238
  2024-02-22 01:35:32 [INFO]   --------------------------------------------
  2024-02-22 01:35:32 [INFO]   Validating the configuration
  .git
  2024-02-22 01:35:33 [FATAL]   The GITHUB_SHA reference (05bce21b8e4551cc59985802154e3184fe1bad4f) doesn't exist in this Git repository

Steps To Reproduce

  1. Run above YAML in pipeline on GitHub Actions
  2. SHA mismatch on PR when running v6
  3. SHA matches on PR when running v5

Anything else?

No response

echoix commented 8 months ago

I got the same thing when upgrading a repo to v6 the other week. The error message isn't clear at all for this, but the SHA reference is your commit's SHA, the one that the workflow is running for.

So, see the resolution of another issue today, https://github.com/super-linter/super-linter/issues/5313, it's the same problem.

A similar report here: https://github.com/super-linter/super-linter/issues/5239

ferrarimarco commented 8 months ago

Hi! Given the recurrence of this kind of report, we should probably enhance the error message. Thanks for reporting this!

ferrarimarco commented 8 months ago

5316 should take care of this.

damies13 commented 3 months ago

I am getting this error with superlinter 6.8.0, not on my own check-ins or when I merge branches, only when running superlinter against pull-requests.

It's not clear to me what the root cause was or how to resolve this issue? According to this issue it should have been resolved in 6.3.0?

https://github.com/damies13/rfswarm/actions/runs/10193188112/job/28204156573?pr=270

ferrarimarco commented 3 months ago

@damies13 it appears that you didn't set the proper fetch depth in the checkout step of your workflow. I suggest having a look at the readme as the error message suggests. If the issue persists, please open a new issue so we can investigate.

damies13 commented 3 months ago

Ah ok, I fixed that issue on the main branch the the requestor of the PR might be on the old branch, thatnks, I'll remind him to pull from upstream - Thanks :+1:

Also explains why I didn't get this error when I merged the PR.