Skip to content

Commit

Permalink
Add DEBUG var to control debug printing
Browse files Browse the repository at this point in the history
It's not always necessary to have debug prints, most of the time it's
useful when developing Shipyard/script features or when running the CI.

The `DEBUG` env var can be use to request debug printing.
Currently the default is `true` to maintain the current behavior, but
after adoption this can be set to `false` (or unset).

Signed-off-by: Mike Kolesnik <mkolesni@redhat.com>
  • Loading branch information
mkolesnik authored and tpantelis committed Aug 8, 2022
1 parent 7cef2ee commit 14f86e1
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/clean-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ name: Clean Target Verification
on:
pull_request:

env:
DEBUG: true
jobs:
clean-clusters:
name: Cluster Clean-up
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/multiarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ name: Multi-arch Builds
on:
pull_request:

env:
DEBUG: true
jobs:
check-multiarch:
name: Check the multi-arch builds
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ name: Shared Scripts
on:
pull_request:

env:
DEBUG: true
jobs:
clusters:
name: Clusters
Expand Down
6 changes: 5 additions & 1 deletion Makefile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ RUN_IN_DAPPER = ./.dapper $(DAPPER_ARGS) $(SELINUX_CONTEXT) --

endif

ifeq (true,$(DEBUG))
MAKE_DEBUG_FLAG = --debug=b
endif

# Only run command line goals in dapper (except things that have to run outside of dapper).
# Otherwise, make applies this rule to various files and tries to build them in dapper (which doesn't work, obviously).
$(filter-out .dapper prune-images shell targets $(NON_DAPPER_GOALS),$(MAKECMDGOALS)): .dapper $(BASE_DAPPER)
-docker network create -d bridge kind
+$(RUN_IN_DAPPER) make --debug=b $@
+$(RUN_IN_DAPPER) make $(MAKE_DEBUG_FLAG) $@

# The original dockerfiles will live in Shipyard and be downloaded by consuming projects.
$(BASE_DAPPER) $(LINTING_DAPPER):
Expand Down
3 changes: 2 additions & 1 deletion Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ PRELOAD_IMAGES ?= submariner-gateway submariner-operator submariner-route-agent

### Tunable variables for affecting make commands ###
# Affecting multiple commands
DEBUG ?= true
TIMEOUT ?= 5m
export GLOBALNET PLUGIN SETTINGS TIMEOUT
export DEBUG GLOBALNET PLUGIN SETTINGS TIMEOUT

# Specific to `clusters`
K8S_VERSION ?= 1.23
Expand Down
2 changes: 2 additions & 0 deletions gh-actions/e2e/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ inputs:
runs:
using: "composite"
steps:
- shell: bash
run: echo "DEBUG=true" >> $GITHUB_ENV
- shell: bash
run: |
echo "::group::Reclaiming free space"
Expand Down
2 changes: 2 additions & 0 deletions gh-actions/release-images/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ inputs:
runs:
using: "composite"
steps:
- shell: bash
run: echo "DEBUG=true" >> $GITHUB_ENV
- name: Set up QEMU (to support building on non-native architectures)
uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480
- name: Set up buildx
Expand Down
2 changes: 2 additions & 0 deletions gh-actions/upgrade-e2e/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ description: 'Runs an upgrade procedure, followed by end to end tests with multi
runs:
using: "composite"
steps:
- shell: bash
run: echo "DEBUG=true" >> $GITHUB_ENV
- shell: bash
run: |
echo "::group::Reclaiming free space"
Expand Down
1 change: 1 addition & 0 deletions scripts/shared/lib/debug_functions
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ function trap_commands() {

### Main ###

[[ "${DEBUG}" == 'true' ]] || return 0
set -T
trap_commands

0 comments on commit 14f86e1

Please sign in to comment.