Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Bob
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Bob
Commits
cf42e31e
Verified
Commit
cf42e31e
authored
1 year ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
feat: new compile scripts
parent
1e625bde
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
development/script/go-compile.sh
+53
-0
53 additions, 0 deletions
development/script/go-compile.sh
development/script/go-coverage.sh
+35
-0
35 additions, 0 deletions
development/script/go-coverage.sh
with
88 additions
and
0 deletions
development/script/go-compile.sh
0 → 100755
+
53
−
0
View file @
cf42e31e
#!/usr/bin/env bash
##
## $(QUIET) $(DEVELOPMENT_SCRIPTS_PATH)/go-compile.sh $(SOURCE_PATH) $(BUILD_PATH) $(COMPONENT_SLUG) $(GO_RELEASE_PACKAGE_NAME) $(PROJECT_VERSION) $(PROJECT_BUILD_DATE)
SOURCE_PATH
=
$1
BUILD_PATH
=
$2
COMPONENT_SLUG
=
$3
GO_RELEASE_PACKAGE_NAME
=
$4
PROJECT_VERSION
=
$5
PROJECT_BUILD_DATE
=
$6
platforms
=
$(
go tool dist list
)
included_os
=(
"linux"
"windows"
)
# define a list of excluded architectures
included_arch
=(
"amd64"
"arm64"
)
cd
$SOURCE_PATH
||
exit
1
# Run and build loop through all platforms (except excluded ones)
for
platform
in
$platforms
;
do
# GOOS und GOARCH Variablen setzen
export
GOOS
=
$(
echo
$platform
|
cut
-d
'/'
-f1
)
export
GOARCH
=
$(
echo
$platform
|
cut
-d
'/'
-f2
)
if
[[
!
"
${
included_os
[@]
}
"
=
~
"
$GOOS
"
]]
;
then
echo
"Skipping excluded platform:
$GOOS
"
continue
fi
if
[[
!
"
${
included_arch
[@]
}
"
=
~
"
$GOARCH
"
]]
;
then
echo
"Skipping excluded architecture:
$GOARCH
"
continue
fi
echo
"============================================"
echo
"Building for
$GOOS
/
$GOARCH
"
output_name
=
$BUILD_PATH$COMPONENT_SLUG
-
$GOOS
-
$GOARCH
if
[
$GOOS
=
"windows"
]
;
then
output_name+
=
'.exe'
fi
env
GO111MODULE
=
on
GOOS
=
$GOOS
GOARCH
=
$GOARCH
go build
-ldflags
"-X
$GO_RELEASE_PACKAGE_NAME
.version=
$PROJECT_VERSION
-X
$GO_RELEASE_PACKAGE_NAME
.build=
$PROJECT_BUILD_DATE
"
-o
$output_name
if
[
$?
-ne
0
]
;
then
echo
"An error has occurred!
$output_name
build failed."
echo
"============================================"
fi
done
cd
-
||
exit
1
This diff is collapsed.
Click to expand it.
development/script/go-coverage.sh
0 → 100755
+
35
−
0
View file @
cf42e31e
#!/bin/bash
#
# Code coverage generation
COVERAGE_DIR
=
"
${
1
}
"
REPORT_DIR
=
"
${
2
}
"
TYPE
=
"
${
3
}
"
cd
"
$COVERAGE_DIR
"
||
exit
1
PKG_LIST
=
$(
go list ./... |
grep
-v
/vendor/
)
# Create the coverage files directory
mkdir
-p
"
$REPORT_DIR
"
;
# Create a coverage file for each package
for
package
in
${
PKG_LIST
}
;
do
go
test
-covermode
=
count
-coverprofile
"
${
REPORT_DIR
}
/
${
package
##*/
}
.cov"
"
$package
"
;
done
;
# Merge the coverage profile files
echo
'mode: count'
>
"
${
REPORT_DIR
}
"
/coverage.cov
;
tail
-q
-n
+2
"
${
REPORT_DIR
}
"
/
*
.cov
>>
"
${
REPORT_DIR
}
"
/coverage.cov
;
# Display the global code coverage
go tool cover
-func
=
"
${
REPORT_DIR
}
"
/coverage.cov
;
# If needed, generate HTML report
if
[
"
$TYPE
"
==
"html"
]
;
then
go tool cover
-html
=
"
${
REPORT_DIR
}
"
/coverage.cov
-o
"
${
REPORT_DIR
}
/"
coverage.html
;
fi
rm
-rf
${
REPORT_DIR
}
"/"
*
.cov
# Remove the coverage files directory
cd
-
||
exit
1
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment