Skip to content

Commit

Permalink
tasks(repackage_boshreleases_fallback): fix UT after merge
Browse files Browse the repository at this point in the history
Follow up of #443. UT were failing due to missing '`initialize': uninitialized constant RepackageReleasesFallback::Tasks (NameError)'
  • Loading branch information
o-orand committed Mar 20, 2024
1 parent 18ee75a commit d8866e6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
33 changes: 28 additions & 5 deletions ci/fail-github-commit-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,43 @@
OWNER=${OWNER:-orange-cloudfoundry}
REPO=${REPO:-cf-ops-automation}

PR_STATUS="error"
usage(){
echo "$0 <commit_sha1>"
commit_sha1
echo "$0 -c <commit_sha1> [-s <PR-Status>]"
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'
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d8866e6

Please sign in to comment.