From d8866e62405608433e6014e7ee888f6a71ff24e3 Mon Sep 17 00:00:00 2001 From: Olivier ORAND Date: Wed, 20 Mar 2024 10:53:43 +0000 Subject: [PATCH] tasks(repackage_boshreleases_fallback): fix UT after merge Follow up of #443. UT were failing due to missing '`initialize': uninitialized constant RepackageReleasesFallback::Tasks (NameError)' --- ci/fail-github-commit-status.sh | 33 ++++++++++++++++--- .../repackage_releases_fallback.rb | 1 + spec/spec_helper.rb | 6 +++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ci/fail-github-commit-status.sh b/ci/fail-github-commit-status.sh index b0a12bcc..92c88c10 100755 --- a/ci/fail-github-commit-status.sh +++ b/ci/fail-github-commit-status.sh @@ -2,20 +2,43 @@ OWNER=${OWNER:-orange-cloudfoundry} REPO=${REPO:-cf-ops-automation} +PR_STATUS="error" usage(){ - echo "$0 " - commit_sha1 + echo "$0 -c [-s ]" + echo " -c|--commit: commit_sha1" + echo " -s|--status: status to set. Default: $PR_STATUS" exit 1 } -if [ $# -ne 1 ];then + +while [ "$#" -gt 0 ] ; do + case "$1" in + "-c"|"--commit") + REF="$2" + shift ; shift ;; + "-s"|"--status") + PR_STATUS="$2" + shift ; shift ;; + *) usage ;; + esac +done + +if [ "${REF}" = "" ] ; then usage fi +case $PR_STATUS in +error|pending|failure|success) + echo "Status ($PR_STATUS) is valid" + ;; +*) + echo "ERROR: invalid status: $PR_STATUS. Valid status are: error|pending|failure|success" + exit 1 +esac gh api --method POST \ -H "Accept: application/vnd.github+json" \ -H "X-GitHub-Api-Version: 2022-11-28" \ /repos/$OWNER/$REPO/statuses/$REF \ - -f state='error' \ - -f description='Manual update! Set to failure' \ + -f state="$PR_STATUS" \ + -f description="Manual update! Set to $PR_STATUS" \ -f context='concourse-ci/status' diff --git a/concourse/tasks/repackage_boshreleases_fallback/repackage_releases_fallback.rb b/concourse/tasks/repackage_boshreleases_fallback/repackage_releases_fallback.rb index 2abe0c12..897530e7 100644 --- a/concourse/tasks/repackage_boshreleases_fallback/repackage_releases_fallback.rb +++ b/concourse/tasks/repackage_boshreleases_fallback/repackage_releases_fallback.rb @@ -15,6 +15,7 @@ require 'fileutils' require 'open3' require 'open-uri' +require_relative '../../../lib/tasks/bosh' # This class process boshrelease repackaging errors and try to get releases from bosh.io or github class RepackageReleasesFallback diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9ace5df9..009ae11e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -142,10 +142,14 @@ def initialize(msg, stdout_snapshot, stderr_snapshot, status) end end + def fly_bin + "fly" + end + def fly_run(arg, env = {}) target = 'cf-ops-automation' env_var = env.collect { |k, v| "#{k}=#{v}" }.join(' ') - out, err, status = Open3.capture3("bash -o pipefail -c \"env #{env_var} fly --target #{target} #{arg}| tee /tmp/fly.log\"") + out, err, status = Open3.capture3("bash -o pipefail -c \"env #{env_var} #{fly_bin} --target #{target} #{arg}| tee /tmp/fly.log\"") raise FlyExecuteError.new("Failed: env #{env_var} fly --target #{target} #{arg} | tee /tmp/fly.log\n #{err unless err.empty? }", out, err, status) if !status.success? || !err.empty? #err =~ /error: websocket: bad handshake/ out