Skip to content

Commit

Permalink
testing/ temp removed cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
okankoAMZ committed Sep 21, 2023
1 parent 4f552a4 commit 2095744
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
run: |
cd packaging/uniformBuild
go build .
./uniformBuild -r "${{github.repositoryUrl}}" -b "main" -c "${{github.sha}} -a ${{secrets.AWS_TEST_ACCOUNT_ID}}"
./uniformBuild -r "${{github.repositoryUrl}}" -b "main" -c "${{github.sha}}" -a "${{secrets.AWS_TEST_ACCOUNT_ID}}"
# - name: Cache go ^^^ make it not main
# # Only skip for integration builds not release builds.
Expand Down
23 changes: 15 additions & 8 deletions packaging/uniformBuild/aws_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func (imng *InstanceManager) GetAllAMIVersions(accountID string) []types.Image {
Filters: filters,
})
if err != nil {
panic(err)
fmt.Println(err)
return nil
}
// Sort the images based on the CreationDate field in descending order
sort.Slice(resp.Images, func(i, j int) bool {
Expand All @@ -86,7 +87,8 @@ func (imng *InstanceManager) GetLatestAMIVersion(accountID string) *types.Image
func parseTime(value string) *time.Time {
t, err := time.Parse("2006-01-02T15:04:05.999999999Z", value)
if err != nil {
panic(err)
fmt.Println(err)
return nil
}
return &t
}
Expand Down Expand Up @@ -130,6 +132,7 @@ func (imng *InstanceManager) CreateEC2InstancesBlocking() error {
fmt.Println(err)
return
}
time.Sleep(30 * time.Second)
}(instance)
}
wg.Wait()
Expand Down Expand Up @@ -283,8 +286,8 @@ func RunCmdRemotely(ssmClient *ssm.Client, instance *types.Instance, command str
"workingDirectory": {"~"},
"executionTimeout": {strconv.Itoa(int(timeout))},
},
OutputS3BucketName: aws.String("buildenvtesting"),
OutputS3KeyPrefix: aws.String("buildenvtesting/logs/"),
OutputS3BucketName: aws.String(S3_INTEGRATION_BUCKET),
OutputS3KeyPrefix: aws.String(S3_INTEGRATION_BUCKET + "logs/"),
TimeoutSeconds: aws.Int32(timeout),

Comment: aws.String(enforceCommentLimit(comment)),
Expand Down Expand Up @@ -331,7 +334,8 @@ func WaitUntilAgentIsOn(client *ec2.Client, instance *types.Instance) {
fmt.Printf("Trying to connect to ec2 instance, try count : %d \n", retryCount)
output, err := client.DescribeInstanceStatus(context.Background(), input)
if err != nil {
panic(err)
fmt.Println(err)
return
}
if len(output.InstanceStatuses) == 0 {
time.Sleep(1 * time.Minute)
Expand All @@ -352,7 +356,8 @@ func GetInstanceFromID(client *ec2.Client, instanceID string) *types.Instance {
}
output, err := client.DescribeInstances(context.Background(), input)
if err != nil {
panic(err)
fmt.Println(err)
return nil
}
// Return instance object
if len(output.Reservations) == 0 || len(output.Reservations[0].Instances) == 0 {
Expand All @@ -365,7 +370,8 @@ func GetCommandsList(ssmClient *ssm.Client) {
// List all commands
resp, err := ssmClient.ListCommands(context.TODO(), &ssm.ListCommandsInput{})
if err != nil {
panic(err)
fmt.Println(err)
return
}
// Print the command IDs and statuses
for _, command := range resp.Commands {
Expand All @@ -377,7 +383,8 @@ func GetCommandInfo(ssmClient *ssm.Client, commandID string) ssmtypes.Command {
CommandId: &commandID,
})
if err != nil {
panic(err)
fmt.Println(err)
return ssmtypes.Command{}
}
return resp.Commands[0]
}
Expand Down
2 changes: 1 addition & 1 deletion packaging/uniformBuild/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
)

const S3_INTEGRATION_BUCKET = "buildenvtesting"
const S3_INTEGRATION_BUCKET = "uniform-build-env-test"

func mergeCommands(args ...string) string {
return strings.Join(args, "&&")
Expand Down
7 changes: 3 additions & 4 deletions packaging/uniformBuild/uniformBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,17 @@ func main() {
var branch string
var comment string
var accountID string
flag.StringVar(&accountID, "a", "", "accountID")
flag.StringVar(&accountID, "account_id", "", "accountID")
flag.StringVar(&repo, "r", "", "repository")
flag.StringVar(&repo, "repo", "", "repository")
flag.StringVar(&branch, "b", "", "branch")
flag.StringVar(&branch, "branch", "", "branch")
flag.StringVar(&comment, "c", "", "comment")
flag.StringVar(&comment, "comment", "", "comment")

flag.StringVar(&accountID, "a", "", "accountID")
flag.StringVar(&accountID, "account_id", "", "accountID")
flag.Parse()
rbm := CreateRemoteBuildManager(DEFAULT_INSTANCE_GUIDE, accountID)
defer rbm.Close()
//defer rbm.Close()
err := rbm.BuildCWAAgent(repo, branch, comment, "MainBuildEnv")
if err != nil {
panic(err)
Expand Down

0 comments on commit 2095744

Please sign in to comment.