ci: build binaries for lvscare and image-cri-shim (#1283)

* ci: build binaries for lvscare and image-cri-shim

Signed-off-by: Mercurio <signormercurio@gmail.com>

* attempt to simplify the workflow

Signed-off-by: Mercurio <signormercurio@gmail.com>

* restore dependencies

Signed-off-by: Mercurio <signormercurio@gmail.com>

* merge workflow steps

Signed-off-by: Mercurio <signormercurio@gmail.com>

* add sources.list

Signed-off-by: Mercurio <signormercurio@gmail.com>

* fix apt error

Signed-off-by: Mercurio <signormercurio@gmail.com>

* fix apt update error

Signed-off-by: Mercurio <signormercurio@gmail.com>

* restore build tags

Signed-off-by: Mercurio <signormercurio@gmail.com>

* explicitly set CGO_ENABLED

Signed-off-by: Mercurio <signormercurio@gmail.com>

* upgrade golangci-lint

Signed-off-by: Mercurio <signormercurio@gmail.com>

* fix lint error

Signed-off-by: Mercurio <signormercurio@gmail.com>

* fix lint error

Signed-off-by: Mercurio <signormercurio@gmail.com>
This commit is contained in:
Mercurio
2022-07-09 15:02:04 +08:00
committed by GitHub
parent 93dc618e3c
commit abf894497e
9 changed files with 21 additions and 28 deletions
+9 -13
View File
@@ -55,11 +55,11 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Dependencies
run: sudo apt install -y libgpgme-dev libdevmapper-dev libbtrfs-dev
run: sudo apt install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Run Linter
uses: golangci/golangci-lint-action@v3
with:
version: v1.39.0
version: v1.46.2
working-directory: ${{ matrix.workdir }}
args: "--out-${NO_FUTURE}format colored-line-number"
@@ -74,18 +74,18 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Dependencies
run: sudo apt install -y libgpgme-dev libdevmapper-dev libbtrfs-dev
run: sudo apt install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Run Coverage
run: make coverage
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
build:
needs: [golangci-lint, coverage]
runs-on: ubuntu-latest
strategy:
matrix:
binary: [sealos, sealctl]
binary: [sealos, sealctl, lvscare, image-cri-shim]
arch: [arm64, amd64]
steps:
- name: Checkout
@@ -99,18 +99,14 @@ jobs:
if: ${{ matrix.arch == 'arm64' }}
run: |
sudo \cp .github/sources.list /etc/apt/sources.list
sudo apt update || true
sudo dpkg --add-architecture ${{ matrix.arch }}
sudo apt update || true
- name: Install Build Dependencies
run: |
sudo apt update || true
sudo apt install -y libbtrfs-dev:${{ matrix.arch }} libgpgme-dev:${{ matrix.arch }}
- name: Install gcc
if: ${{ matrix.arch == 'arm64' }}
run: sudo apt install -y gcc-aarch64-linux-gnu
sudo apt install -y libgpgme-dev:${{ matrix.arch }} libbtrfs-dev:${{ matrix.arch }}
# Note: CGO_ENABLED=0
- name: Build Binaries
run: |
make build BINS=${{ matrix.binary }} PLATFORM=linux_${{ matrix.arch }}
@@ -120,7 +116,7 @@ jobs:
make compress BINS=${{ matrix.binary }} PLATFORM=linux_${{ matrix.arch }}
- name: Save binaries
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.binary }}-${{ matrix.arch }}
path: bin/linux_${{ matrix.arch}}/${{ matrix.binary }}
+1 -1
View File
@@ -50,4 +50,4 @@ linters-settings:
# https://github.com/golangci/golangci/wiki/Configuration
service:
# use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.39.0
golangci-lint-version: 1.46.2
+5
View File
@@ -43,6 +43,7 @@ builds:
- -X github.com/labring/sealos/pkg/version.gitCommit={{.ShortCommit}}
- -X github.com/labring/sealos/pkg/version.buildDate={{.Date}}
- -extldflags "-static -fpic"
- -trimpath
- -s -w
- -linkmode external
@@ -71,6 +72,7 @@ builds:
- -X github.com/labring/sealos/pkg/version.gitCommit={{.ShortCommit}}
- -X github.com/labring/sealos/pkg/version.buildDate={{.Date}}
- -extldflags "-static -fpic"
- -trimpath
- -s -w
- -linkmode external
@@ -90,6 +92,7 @@ builds:
- -X github.com/labring/sealos/pkg/version.gitVersion={{.Version}}
- -X github.com/labring/sealos/pkg/version.gitCommit={{.ShortCommit}}
- -X github.com/labring/sealos/pkg/version.buildDate={{.Date}}
- -trimpath
- -s -w
- env:
@@ -108,6 +111,7 @@ builds:
- -X github.com/labring/sealos/pkg/version.gitVersion={{.Version}}
- -X github.com/labring/sealos/pkg/version.gitCommit={{.ShortCommit}}
- -X github.com/labring/sealos/pkg/version.buildDate={{.Date}}
- -trimpath
- -s -w
- env:
@@ -126,6 +130,7 @@ builds:
- -X github.com/labring/sealos/pkg/version.gitVersion={{.Version}}
- -X github.com/labring/sealos/pkg/version.gitCommit={{.ShortCommit}}
- -X github.com/labring/sealos/pkg/version.buildDate={{.Date}}
- -trimpath
- -s -w
#archives:
+1 -1
View File
@@ -179,7 +179,7 @@ As a contributor, if you want to make any contribution to sealos project, we sho
Here are some dependents with specific version:
- golang : v1.16+
- golangci-lint: 1.39.0
- golangci-lint: 1.46.2
When you develop the sealos project at the local environment, you should use subcommands of Makefile to help yourself to check and build the latest version of sealos. For the convenience of developers, we use the docker to build sealos. It can reduce problems of the developing environment.
+1 -1
View File
@@ -52,7 +52,7 @@ go.build.%:
@echo "===========> Building binary $(COMMAND) for $(PLATFORM)"
@mkdir -p $(BIN_DIR)/$(PLATFORM)
GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(BIN_DIR)/$(PLATFORM)/$(COMMAND) $(ROOT_PACKAGE)/cmd/$(COMMAND)
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(BIN_DIR)/$(PLATFORM)/$(COMMAND) $(ROOT_PACKAGE)/cmd/$(COMMAND)
.PHONY: go.build
go.build: go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BINS)))
@@ -966,9 +966,7 @@ func (l *loggingT) setV(pc uintptr) Level {
fn := runtime.FuncForPC(pc)
file, _ := fn.FileLine(pc)
// The file is something like /a/b/c/d.go. We want just the d.
if strings.HasSuffix(file, ".go") {
file = file[:len(file)-3]
}
file = strings.TrimSuffix(file, ".go")
if slash := strings.LastIndex(file, "/"); slash >= 0 {
file = file[slash+1:]
}
@@ -59,9 +59,7 @@ func (l *loggingT) swap(writers [numSeverity]flushSyncWriter) (old [numSeverity]
l.mu.Lock()
defer l.mu.Unlock()
old = l.file
for i, w := range writers {
logging.file[i] = w
}
logging.file = writers
return
}
@@ -966,9 +966,7 @@ func (l *loggingT) setV(pc uintptr) Level {
fn := runtime.FuncForPC(pc)
file, _ := fn.FileLine(pc)
// The file is something like /a/b/c/d.go. We want just the d.
if strings.HasSuffix(file, ".go") {
file = file[:len(file)-3]
}
file = strings.TrimSuffix(file, ".go")
if slash := strings.LastIndex(file, "/"); slash >= 0 {
file = file[slash+1:]
}
@@ -59,9 +59,7 @@ func (l *loggingT) swap(writers [numSeverity]flushSyncWriter) (old [numSeverity]
l.mu.Lock()
defer l.mu.Unlock()
old = l.file
for i, w := range writers {
logging.file[i] = w
}
logging.file = writers
return
}