diff --git a/.devcontainer/devcontainer.env b/.devcontainer/devcontainer.env index 0be22df4..dc9a5cba 100644 --- a/.devcontainer/devcontainer.env +++ b/.devcontainer/devcontainer.env @@ -1,5 +1,5 @@ -ACTIONS_RUNNER_DEBUG=true DEFAULT_BRANCH=main DEFAULT_WORKSPACE=/workspaces/super-linter ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true +LOG_LEVEL=DEBUG RUN_LOCAL=true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 115c8a4b..adab18f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -105,7 +105,7 @@ jobs: - name: Test Local Action (debug log) uses: ./ env: - ACTIONS_RUNNER_DEBUG: true + LOG_LEVEL: DEBUG CREATE_LOG_FILE: true VALIDATE_ALL_CODEBASE: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index d345e010..554fedb4 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ all: info docker test ## Run all targets. .PHONY: test -test: info validate-container-image-labels test-lib inspec lint-codebase test-default-config-files test-find lint-subset-files test-custom-ssl-cert test-non-default-workdir test-git-flags test-non-default-home-directory test-log-level test-linters-expect-failure-log-level-notice test-linters ## Run the test suite +test: info validate-container-image-labels test-lib inspec lint-codebase test-default-config-files test-actions-runner-debug test-actions-steps-debug test-runner-debug test-find lint-subset-files test-custom-ssl-cert test-non-default-workdir test-git-flags test-non-default-home-directory test-log-level test-linters-expect-failure-log-level-notice test-linters ## Run the test suite # if this session isn't interactive, then we don't want to allocate a # TTY, which would fail, but if it is interactive, we do want to attach @@ -134,11 +134,44 @@ validate-container-image-labels: ## Validate container image labels # For some cases, mount a directory that doesn't have too many files to keep tests short +.PHONY: test-actions-runner-debug +test-actions-runner-debug: ## Run super-linter with ACTIONS_RUNNER_DEBUG=true + docker run \ + -e ACTIONS_RUNNER_DEBUG=true \ + -e RUN_LOCAL=true \ + -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ + -e DEFAULT_BRANCH=main \ + -e USE_FIND_ALGORITHM=true \ + -v "$(CURDIR)/.github":/tmp/lint/.github \ + $(SUPER_LINTER_TEST_CONTAINER_URL) + +.PHONY: test-actions-steps-debug +test-actions-steps-debug: ## Run super-linter with ACTIONS_STEPS_DEBUG=true + docker run \ + -e ACTIONS_STEPS_DEBUG=true \ + -e RUN_LOCAL=true \ + -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ + -e DEFAULT_BRANCH=main \ + -e USE_FIND_ALGORITHM=true \ + -v "$(CURDIR)/.github":/tmp/lint/.github \ + $(SUPER_LINTER_TEST_CONTAINER_URL) + +.PHONY: test-runner-debug +test-runner-debug: ## Run super-linter with RUNNER_DEBUG=1 + docker run \ + -e RUNNER_DEBUG=1 \ + -e RUN_LOCAL=true \ + -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ + -e DEFAULT_BRANCH=main \ + -e USE_FIND_ALGORITHM=true \ + -v "$(CURDIR)/.github":/tmp/lint/.github \ + $(SUPER_LINTER_TEST_CONTAINER_URL) + .phony: test-find test-find: ## Run super-linter on a subdirectory with USE_FIND_ALGORITHM=true docker run \ -e RUN_LOCAL=true \ - -e ACTIONS_RUNNER_DEBUG=true \ + -e LOG_LEVEL=DEBUG \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ -e DEFAULT_BRANCH=main \ -e USE_FIND_ALGORITHM=true \ @@ -151,8 +184,7 @@ test-find: ## Run super-linter on a subdirectory with USE_FIND_ALGORITHM=true test-non-default-workdir: ## Run super-linter with DEFAULT_WORKSPACE set docker run \ -e RUN_LOCAL=true \ - -e ACTIONS_RUNNER_DEBUG=true \ - -e ERROR_ON_MISSING_EXEC_BIT=true \ + -e LOG_LEVEL=DEBUG \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ -e DEFAULT_BRANCH=main \ -e DEFAULT_WORKSPACE=/tmp/not-default-workspace \ @@ -165,8 +197,7 @@ test-non-default-workdir: ## Run super-linter with DEFAULT_WORKSPACE set test-git-flags: ## Run super-linter with different git-related flags docker run \ -e RUN_LOCAL=true \ - -e ACTIONS_RUNNER_DEBUG=true \ - -e ERROR_ON_MISSING_EXEC_BIT=true \ + -e LOG_LEVEL=DEBUG \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ -e FILTER_REGEX_EXCLUDE=".*(/test/linters/|CHANGELOG.md).*" \ -e DEFAULT_BRANCH=main \ @@ -180,7 +211,7 @@ test-git-flags: ## Run super-linter with different git-related flags lint-codebase: ## Lint the entire codebase docker run \ -e RUN_LOCAL=true \ - -e ACTIONS_RUNNER_DEBUG=true \ + -e LOG_LEVEL=DEBUG \ -e DEFAULT_BRANCH=main \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ -e FILTER_REGEX_EXCLUDE=".*(/test/linters/|CHANGELOG.md).*" \ @@ -199,7 +230,7 @@ lint-subset-files: lint-subset-files-enable-only-one-type lint-subset-files-enab lint-subset-files-enable-only-one-type: ## Lint a small subset of files in the codebase by enabling only one linter time docker run \ -e RUN_LOCAL=true \ - -e ACTIONS_RUNNER_DEBUG=true \ + -e LOG_LEVEL=DEBUG \ -e DEFAULT_BRANCH=main \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ -e FILTER_REGEX_EXCLUDE=".*(/test/linters/|CHANGELOG.md).*" \ @@ -212,7 +243,7 @@ lint-subset-files-enable-only-one-type: ## Lint a small subset of files in the c lint-subset-files-enable-expensive-io-checks: ## Lint a small subset of files in the codebase and keep expensive I/O operations to check file types enabled time docker run \ -e RUN_LOCAL=true \ - -e ACTIONS_RUNNER_DEBUG=true \ + -e LOG_LEVEL=DEBUG \ -e DEFAULT_BRANCH=main \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ -e FILTER_REGEX_EXCLUDE=".*(/test/linters/|CHANGELOG.md).*" \ @@ -270,7 +301,7 @@ test-validation: ## Test validation test-default-config-files: ## Test default configuration files loading docker run \ -e RUN_LOCAL=true \ - -e ACTIONS_RUNNER_DEBUG=true \ + -e LOG_LEVEL=DEBUG \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ -e DEFAULT_BRANCH=main \ -e USE_FIND_ALGORITHM=true \ @@ -281,7 +312,7 @@ test-default-config-files: ## Test default configuration files loading test-custom-ssl-cert: ## Test the configuration of a custom SSL/TLS certificate docker run \ -e RUN_LOCAL=true \ - -e ACTIONS_RUNNER_DEBUG=true \ + -e LOG_LEVEL=DEBUG \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ -e DEFAULT_BRANCH=main \ -e USE_FIND_ALGORITHM=true \ diff --git a/README.md b/README.md index 0d005280..5e9bbb0e 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,6 @@ You can configure super-linter using the following environment variables: | **Environment variable** | **Default Value** | **Description** | |-------------------------------------------------|---------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | | **ANSIBLE_CONFIG_FILE** | `.ansible-lint.yml` | Filename for [Ansible-lint configuration](https://ansible.readthedocs.io/projects/lint/configuring/) (ex: `.ansible-lint`, `.ansible-lint.yml`) | | **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s), relative to `DEFAULT_WORKSPACE`. Set to `.` to use the top-level of the `DEFAULT_WORKSPACE`. | | **BASH_SEVERITY** | `style` | Specify the minimum severity of errors to consider in shellcheck. Valid values in order of severity are error, warning, info and style. | @@ -407,7 +406,7 @@ super-linter from a shell: ```bash docker run \ - -e ACTIONS_RUNNER_DEBUG=true \ + -e LOG_LEVEL=DEBUG \ -e RUN_LOCAL=true \ -v /path/to/local/codebase:/tmp/lint \ ghcr.io/super-linter/super-linter:latest diff --git a/docs/run-linter-locally.md b/docs/run-linter-locally.md index fafed3a9..a4c9e9bc 100644 --- a/docs/run-linter-locally.md +++ b/docs/run-linter-locally.md @@ -9,7 +9,7 @@ You can run the container locally with the following configuration options to ru ```bash docker run \ - -e ACTIONS_RUNNER_DEBUG=true \ + -e LOG_LEVEL=DEBUG \ -e RUN_LOCAL=true \ -v /path/to/local/codebase:/tmp/lint \ --rm \ diff --git a/lib/linter.sh b/lib/linter.sh index df0aab0f..a93920db 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -4,9 +4,18 @@ # Debug Vars # # Define these early, so we can use debug logging ASAP if needed # ################################################################## +# GitHub Actions variables to enable workflow debug logging +# Ref: https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging +# Ref: https://github.com/actions/runner/pull/253 declare -l ACTIONS_RUNNER_DEBUG -ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG:-"false"}" # Boolean to see even more info (debug) -IMAGE="${IMAGE:-standard}" # Version of the Super-linter (standard,slim,etc) +ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG:-"false"}" +declare -l ACTIONS_STEPS_DEBUG +ACTIONS_STEPS_DEBUG="${ACTIONS_STEPS_DEBUG:-"false"}" +declare -i RUNNER_DEBUG +RUNNER_DEBUG="${RUNNER_DEBUG:-0}" + +# Version of the Super-linter (standard,slim,etc) +IMAGE="${IMAGE:-standard}" ################################################################## # Log Vars # @@ -17,7 +26,12 @@ LOG_LEVEL="${LOG_LEVEL:-"INFO"}" declare -l CREATE_LOG_FILE CREATE_LOG_FILE="${CREATE_LOG_FILE:-"false"}" -if [[ ${ACTIONS_RUNNER_DEBUG} == true ]]; then LOG_LEVEL="DEBUG"; fi +if [[ ${ACTIONS_RUNNER_DEBUG} == true ]] || + [[ ${ACTIONS_STEPS_DEBUG} == true ]] || + [[ ${RUNNER_DEBUG} -eq 1 ]]; then + LOG_LEVEL="DEBUG" + echo "ACTIONS_RUNNER_DEBUG: ${ACTIONS_RUNNER_DEBUG}. ACTIONS_STEPS_DEBUG: ${ACTIONS_STEPS_DEBUG}. RUNNER_DEBUG: ${RUNNER_DEBUG}. Setting LOG_LEVEL to: ${LOG_LEVEL}" +fi # Boolean to see debug logs LOG_DEBUG=$(if [[ ${LOG_LEVEL} == "DEBUG" || ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi) export LOG_DEBUG