mirror of
https://github.com/octoleo/restic.git
synced 2024-10-31 19:02:32 +00:00
CI: Use build-release-binaries to run the cross-compilation tests
gox silently ignored linux/mips and aix/ppc64. This change also removes the duplicate platform list.
This commit is contained in:
parent
faec0ff816
commit
4e9e2c3229
33
.github/workflows/tests.yml
vendored
33
.github/workflows/tests.yml
vendored
@ -201,27 +201,19 @@ jobs:
|
|||||||
cross_compile:
|
cross_compile:
|
||||||
strategy:
|
strategy:
|
||||||
|
|
||||||
# ATTENTION: the list of architectures must be in sync with helpers/build-release-binaries/main.go!
|
|
||||||
matrix:
|
matrix:
|
||||||
# run cross-compile in three batches parallel so the overall tests run faster
|
# run cross-compile in three batches parallel so the overall tests run faster
|
||||||
targets:
|
subset:
|
||||||
- "linux/386 linux/amd64 linux/arm linux/arm64 linux/ppc64le linux/mips linux/mipsle linux/mips64 linux/mips64le linux/riscv64 linux/s390x"
|
- "0/3"
|
||||||
|
- "1/3"
|
||||||
- "openbsd/386 openbsd/amd64 \
|
- "2/3"
|
||||||
freebsd/386 freebsd/amd64 freebsd/arm \
|
|
||||||
aix/ppc64 \
|
|
||||||
darwin/amd64 darwin/arm64"
|
|
||||||
|
|
||||||
- "netbsd/386 netbsd/amd64 \
|
|
||||||
windows/386 windows/amd64 \
|
|
||||||
solaris/amd64"
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GOPROXY: https://proxy.golang.org
|
GOPROXY: https://proxy.golang.org
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
name: Cross Compile for ${{ matrix.targets }}
|
name: Cross Compile for subset ${{ matrix.subset }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go ${{ env.latest_go }}
|
- name: Set up Go ${{ env.latest_go }}
|
||||||
@ -229,21 +221,14 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: ${{ env.latest_go }}
|
go-version: ${{ env.latest_go }}
|
||||||
|
|
||||||
- name: Install gox
|
|
||||||
run: |
|
|
||||||
go install github.com/mitchellh/gox@latest
|
|
||||||
|
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Cross-compile with gox for ${{ matrix.targets }}
|
- name: Cross-compile for subset ${{ matrix.subset }}
|
||||||
env:
|
|
||||||
GOFLAGS: "-trimpath"
|
|
||||||
GOX_ARCHS: "${{ matrix.targets }}"
|
|
||||||
run: |
|
run: |
|
||||||
mkdir build-output
|
mkdir build-output build-output-debug
|
||||||
gox -parallel 2 -verbose -osarch "$GOX_ARCHS" -output "build-output/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/restic
|
go run ./helpers/build-release-binaries/main.go -o build-output -s . --platform-subset ${{ matrix.subset }}
|
||||||
gox -parallel 2 -verbose -osarch "$GOX_ARCHS" -tags debug -output "build-output/{{.Dir}}_{{.OS}}_{{.Arch}}_debug" ./cmd/restic
|
go run ./helpers/build-release-binaries/main.go -o build-output-debug -s . --platform-subset ${{ matrix.subset }} --tags debug
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
name: lint
|
name: lint
|
||||||
|
@ -20,6 +20,7 @@ var opts = struct {
|
|||||||
Verbose bool
|
Verbose bool
|
||||||
SourceDir string
|
SourceDir string
|
||||||
OutputDir string
|
OutputDir string
|
||||||
|
Tags string
|
||||||
PlatformSubset string
|
PlatformSubset string
|
||||||
Version string
|
Version string
|
||||||
}{}
|
}{}
|
||||||
@ -28,6 +29,7 @@ func init() {
|
|||||||
pflag.BoolVarP(&opts.Verbose, "verbose", "v", false, "be verbose")
|
pflag.BoolVarP(&opts.Verbose, "verbose", "v", false, "be verbose")
|
||||||
pflag.StringVarP(&opts.SourceDir, "source", "s", "/restic", "path to the source code `directory`")
|
pflag.StringVarP(&opts.SourceDir, "source", "s", "/restic", "path to the source code `directory`")
|
||||||
pflag.StringVarP(&opts.OutputDir, "output", "o", "/output", "path to the output `directory`")
|
pflag.StringVarP(&opts.OutputDir, "output", "o", "/output", "path to the output `directory`")
|
||||||
|
pflag.StringVar(&opts.Tags, "tags", "", "additional build `tags`")
|
||||||
pflag.StringVar(&opts.PlatformSubset, "platform-subset", "", "specify `n/t` to only build this subset")
|
pflag.StringVar(&opts.PlatformSubset, "platform-subset", "", "specify `n/t` to only build this subset")
|
||||||
pflag.StringVar(&opts.Version, "version", "", "use `x.y.z` as the version for output files")
|
pflag.StringVar(&opts.Version, "version", "", "use `x.y.z` as the version for output files")
|
||||||
pflag.Parse()
|
pflag.Parse()
|
||||||
@ -100,10 +102,15 @@ func build(sourceDir, outputDir, goos, goarch string) (filename string) {
|
|||||||
}
|
}
|
||||||
outputFile := filepath.Join(outputDir, filename)
|
outputFile := filepath.Join(outputDir, filename)
|
||||||
|
|
||||||
|
tags := "selfupdate"
|
||||||
|
if opts.Tags != "" {
|
||||||
|
tags += "," + opts.Tags
|
||||||
|
}
|
||||||
|
|
||||||
c := exec.Command("go", "build",
|
c := exec.Command("go", "build",
|
||||||
"-o", outputFile,
|
"-o", outputFile,
|
||||||
"-ldflags", "-s -w",
|
"-ldflags", "-s -w",
|
||||||
"-tags", "selfupdate",
|
"-tags", tags,
|
||||||
"./cmd/restic",
|
"./cmd/restic",
|
||||||
)
|
)
|
||||||
c.Stdout = os.Stdout
|
c.Stdout = os.Stdout
|
||||||
@ -225,7 +232,6 @@ func buildTargets(sourceDir, outputDir string, targets map[string][]string) {
|
|||||||
msg("build finished in %.3fs", time.Since(start).Seconds())
|
msg("build finished in %.3fs", time.Since(start).Seconds())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ATTENTION: the list of architectures must be in sync with .github/workflows/tests.yml!
|
|
||||||
var defaultBuildTargets = map[string][]string{
|
var defaultBuildTargets = map[string][]string{
|
||||||
"aix": {"ppc64"},
|
"aix": {"ppc64"},
|
||||||
"darwin": {"amd64", "arm64"},
|
"darwin": {"amd64", "arm64"},
|
||||||
|
Loading…
Reference in New Issue
Block a user