Super-linter: Support non-master default branches

Created on 18 Jun 2020  路  23Comments  路  Source: github/super-linter

Is your feature request related to a problem? Please describe.
When setting up the linter to run as a github action, it is looking for the master branch but ours is named main. Fails with error:

Failed to switch to master branch to get files changed!
ERROR:[error: pathspec 'master' did not match any file(s) known to git]

Describe the solution you'd like
An environment variable could be used to input the name of the default branch if it is not named master.

enhancement

Most helpful comment

@zkoppert just pushed v2.1.1 with the fix

this has to do with the release and how we test. I will spend some time on this next week to update... my bad for the miss on this

All 23 comments

@admiralAwkbar I'd like to work on this one, seems like a no brainer idea (And like 10 lines of code)

@Hanse00 make it so...

152 was merged so seems like this could be closed.

Let me take a look. I tried earlier today and it was still failing even w/ the env var set:

  env:
    VALIDATE_ALL_CODEBASE: false
    VALIDATE_PYTHON: true
    DEFAULT_BRANCH: main

/usr/bin/docker run --name githubsuperlinterv200_ef3398 --label 3888d3 --workdir /github/workspace --rm -e VALIDATE_ALL_CODEBASE -e VALIDATE_PYTHON -e DEFAULT_BRANCH

Looks like #160 is what merged this code into master

I just failed again - is anyone able to get this working? Here is my linter.yml

###########################
###########################
## Linter GitHub Actions ##
###########################
###########################
name: Lint Code Base

#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#

#############################
# Start the job on all push #
#############################
on:
  push:
    branches-ignore:
      - 'main'

###############
# Set the Job #
###############
jobs:
  build:
    # Name the Job
    name: Lint Code Base
    # Set the agent to run on
    runs-on: ubuntu-latest

    ##################
    # Load all steps #
    ##################
    steps:
      ##########################
      # Checkout the code base #
      ##########################
      - name: Checkout Code
        uses: actions/checkout@v2

      ################################
      # Run Linter against code base #
      ################################
      - name: Lint Code Base
        uses: docker://github/super-linter:v2.0.0
        env:
          DEFAULT_BRANCH: 'main'
          VALIDATE_ALL_CODEBASE: false
          VALIDATE_PYTHON: true 

I have a yml basically identical to what @jdyke has and am getting the same pathspec error.

I assumed the new docker image wasn't published yet and was going to give it a couple hours before commenting but I didn't want this to get closed.

Using docker inspect to see the environment variables exposed by the various versions, I can tell that github/super-linter:latest contains the changes above, github/super-linter:v2.0.0 does not.

I'm going to defer to @zkoppert and @admiralAwkbar on what their process is here. You could probably update your yaml file to use latest, or they might have a specific versioning strategy in mind.

Switching to latest gives an error:

Gathering user validation information...
- Only validating [new], or [edited] files in code base...
awk: cmd. line:1: Unexpected end of string

----------------------------------------------

We need to put some automation behind versioning. I will try to cut a new release version later today.

@zkoppert Do you think the error by @jdyke above has to do with how we release this? Or is it a code bug?

It's a little hard since I cannot test the changes that require the container to run in the context of a GitHub Action. Don't know if we have a solution to that :)

@Hanse00 We just cut a new release so we could have @jdyke try that out first and see if the issue persists. Then we can debug from there if needed.

@zkoppert what would you like me to point to?

################################
      # Run Linter against code base #
      ################################
      - name: Lint Code Base
        uses: docker://github/super-linter:latest

Yeah that will work as well as calling out v2.1.0

Here is what I see:

Gathering user validation information...
- Only validating [new], or [edited] files in code base...
awk: cmd. line:1: Unexpected end of string
awk: cmd. line:1: Unexpected end of string

You can see the results here:
https://github.com/ScaleSec/gcp_api_key_inventory/pull/3/checks?check_run_id=789267373

@jdyke Could you add ACTIONS_RUNNER_DEBUG=true to your configuration?

Okay so far I've found:

  • The error is present in v2.1.0, but not v2.0.0.
  • The error messages from awk are presented no matter if the default branch is switched, in fact none of the environment variables need to be present for the errors to be presented (I've tried with VALIDATE_ALL_CODEBASE on and off, and with a few different combinations of other variables.

At this point I'm not confident if it's actually my change that is causes the problem, or something else that was merged in as well. But I'll keep digging for a bit.

Finally figured out the issue, the new additions of ENV and CSS listing were missing some closing curly brackets :) That should be fixed once #206 is merged in.

Merged #206 but will have to wait for @admiralAwkbar to cut a new release.

@zkoppert I can make a 2.1.1 right now, should we back Port this into 2.0.0 and 2.1.0?

@zkoppert just pushed v2.1.1 with the fix

this has to do with the release and how we test. I will spend some time on this next week to update... my bad for the miss on this

I can confirm that 2.1.1 fixes the problem. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

krtschmr picture krtschmr  路  4Comments

IlanCosman picture IlanCosman  路  4Comments

brunomartinspro picture brunomartinspro  路  4Comments

ymd-h picture ymd-h  路  3Comments

bazzadp picture bazzadp  路  3Comments