Skip to content

Commit

Permalink
Fixed packaging issue
Browse files Browse the repository at this point in the history
  • Loading branch information
okankoAMZ committed Oct 12, 2023
1 parent e0a4c77 commit ef30346
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
with:
ContainerRepositoryNameAndTag: "cwagent-integration-test:${{ github.sha }}"
BucketKey: "integration-test/binary/${{ github.sha }}"
PackageBucketKey: "integration-test/binary/${{ github.sha }}"
PackageBucketKey: "integration-test/packaging/${{ github.sha }}"

GenerateTestMatrix:
name: 'GenerateTestMatrix'
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,11 @@ jobs:
run: |
cd packaging/uniformBuild
go build .
# ./uniformBuild -r "https://github.com/${{env.CWA_GITHUB_REPO_NAME}}.git" -b "main" -c "${{github.sha}}" -a "${{secrets.AWS_TEST_ACCOUNT_ID}}"
- name: Run Uniform Build Env.
if: contains(inputs.BucketKey, 'test') == false || steps.cached_binaries.outputs.cache-hit == false
run: |
cd packaging/uniformBuild
./uniformBuild -r "https://github.com/${{env.CWA_GITHUB_REPO_NAME}}.git" -b "main" -c "${{inputs.BucketKey}}" -a "${{secrets.AWS_TEST_ACCOUNT_ID}}"
./uniformBuild -r "https://github.com/${{env.CWA_GITHUB_REPO_NAME}}.git" -b "main" -o "${{inputs.BucketKey}}" -p "${{inputs.PackageBucketKey}}" -a "${{secrets.AWS_TEST_ACCOUNT_ID}}"
# - name: Cache go ^^^ make it not main
# # Only skip for integration builds not release builds.
# if: contains(inputs.BucketKey, 'test') == false || steps.cached_binaries.outputs.cache-hit == false
Expand Down Expand Up @@ -135,7 +134,7 @@ jobs:
aws-region: us-west-2
- name: Download RPM
run: |
aws s3 cp s3://${{ secrets.S3_INTEGRATION_BUCKET }}/${{ inputs.PackageBucketKey }}/linux/amd64/amazon-cloudwatch-agent.deb .
aws s3 cp s3://${{ secrets.S3_INTEGRATION_BUCKET }}/${{ inputs.BucketKey }}/linux/amd64/amazon-cloudwatch-agent.deb .
aws s3 cp s3://${{ secrets.S3_INTEGRATION_BUCKET }}/${{ inputs.PackageBucketKey }}/amd64/amazon-cloudwatch-agent.pkg .
aws s3 cp s3://${{ secrets.S3_INTEGRATION_BUCKET }}/${{ inputs.PackageBucketKey }}/amazon-cloudwatch-agent.msi .
Expand Down
Binary file added packaging/uniformBuild/uniformBuild
Binary file not shown.
31 changes: 17 additions & 14 deletions packaging/uniformBuild/uniformBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,22 @@ func (rbm *RemoteBuildManager) MakeMsiZip(instanceName string, commitHash string
)
return rbm.RunCommand(command, instanceName, fmt.Sprintf("Making MSI zip file for %s", commitHash))
}
func (rbm *RemoteBuildManager) BuildMSI(instanceName string, commitHash string) error {
func (rbm *RemoteBuildManager) BuildMSI(instanceName string, bucketKey string, packageKey string) error {
if err := rbm.instanceManager.insertOSRequirement(instanceName, WINDOWS); err != nil {
return err
}
if isAlreadyBuilt := rbm.fileExistsInS3(fmt.Sprintf("%s/amazon-cloudwatch-agent.msi", commitHash)); isAlreadyBuilt {
if isAlreadyBuilt := rbm.fileExistsInS3(fmt.Sprintf("%s/amazon-cloudwatch-agent.msi", packageKey)); isAlreadyBuilt {
fmt.Println("\033Found cache skipping build")
return nil
}
command := mergeCommandsWin(
CopyMsi(commitHash),
CopyMsi(bucketKey),
"Expand-Archive buildMSI.zip -DestinationPat C:\\buildMSI -Force",
"cd C:\\buildMSI\\msi_dep",
fmt.Sprintf(".\\create_msi.ps1 \"nosha\" %s/%s", S3_INTEGRATION_BUCKET, commitHash),
fmt.Sprintf(".\\create_msi.ps1 \"nosha\" %s/%s", S3_INTEGRATION_BUCKET, packageKey),
)

return rbm.RunCommand(command, instanceName, fmt.Sprintf("Making MSI Build file for %s", commitHash))
return rbm.RunCommand(command, instanceName, fmt.Sprintf("Making MSI Build file for %s", packageKey))
}

// / MACOS ------------
Expand Down Expand Up @@ -204,40 +204,43 @@ func (rbm *RemoteBuildManager) fileExistsInS3(targetFile string) bool {
func main() {
var repo string
var branch string
var comment string
var bucketKey string
var packageBucketKey string
var accountID string
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(&bucketKey, "o", "", "bucketKey")
flag.StringVar(&bucketKey, "bucketKey", "", "bucketKey")
flag.StringVar(&packageBucketKey, "p", "", "packageBucketKey")
flag.StringVar(&packageBucketKey, "packageBucketKey", "", "packageBucketKey")
flag.StringVar(&accountID, "a", "", "accountID")
flag.StringVar(&accountID, "account_id", "", "accountID")
flag.Parse()
rbm := CreateRemoteBuildManager(DEFAULT_INSTANCE_GUIDE, accountID)
//rbm := CreateRemoteBuildManager(WINDOWS_TEST_INSTANCE_GUIDE, accountID)
//comment = "GHA_DEBUG_RUN"
//bucketKey = "GHA_DEBUG_RUN"
var err error
eg := new(errgroup.Group)
defer rbm.Close()
err = rbm.BuildCWAAgent(repo, branch, comment, "MainBuildEnv")
err = rbm.BuildCWAAgent(repo, branch, bucketKey, "MainBuildEnv")
if err != nil {
panic(err)
}
eg.Go(func() error { // windows
err = rbm.MakeMsiZip("WindowsMSIPacker", comment)
err = rbm.MakeMsiZip("WindowsMSIPacker", bucketKey)
if err != nil {
return err
}
err = rbm.BuildMSI("WindowsMSIBuilder", comment)
err = rbm.BuildMSI("WindowsMSIBuilder", bucketKey, packageBucketKey)
if err != nil {
return err
}
return nil
})
eg.Go(func() error {
err = rbm.MakeMacPkg("MacPkgMaker", comment)
err = rbm.MakeMacPkg("MacPkgMaker", packageBucketKey)
if err != nil {
return err
}
Expand All @@ -248,6 +251,6 @@ func main() {
return
}
fmt.Printf("\033[32mSuccesfully\033[0m built CWA from %s with %s branch, check \033[32m%s \033[0m bucket with \033[1;32m%s\033[0m hash\n",
repo, branch, S3_INTEGRATION_BUCKET, comment)
repo, branch, S3_INTEGRATION_BUCKET, bucketKey)

}

0 comments on commit ef30346

Please sign in to comment.