From f98d8c046cc5c84dc8389fbfe9769a199ba06ac0 Mon Sep 17 00:00:00 2001 From: CFC4N Date: Sun, 25 Feb 2024 10:47:05 +0800 Subject: [PATCH] workflows: add LDFLAGS/CFLAGS env into workflows. Signed-off-by: CFC4N --- .github/workflows/go-c-cpp.yml | 43 +++++++++++++--------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/.github/workflows/go-c-cpp.yml b/.github/workflows/go-c-cpp.yml index de6c054144..078cd10de2 100644 --- a/.github/workflows/go-c-cpp.yml +++ b/.github/workflows/go-c-cpp.yml @@ -10,6 +10,10 @@ jobs: build-on-ubuntu2004: runs-on: ubuntu-20.04 name: build on ubuntu-20.04 x86_64 + env: + CGO_CFLAGS: -O2 -g -gdwarf-4 -I$GITHUB_WORKSPACE/lib/libpcap/ + CGO_LDFLAGS: -O2 -g -L$GITHUB_WORKSPACE/lib/libpcap/ -lpcap -static + CC: /usr/bin/clang steps: - uses: actions/setup-go@v5 with: @@ -17,7 +21,7 @@ jobs: - name: Install Compilers run: | sudo apt-get update - sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-9 clang-9 linux-tools-common linux-tools-generic + sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-9 clang-9 linux-tools-common linux-tools-generic gcc for tool in "clang" "llc" "llvm-strip" do sudo rm -f /usr/bin/$tool @@ -28,35 +32,16 @@ jobs: with: submodules: 'recursive' fetch-depth: 0 - - name: Build + - name: Build && golangci-lint run: | make clean make env make nocore -j4 - - name: golangci-lint - uses: golangci/golangci-lint-action@v4 - with: - # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - # version: v3.2.0 - - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - args: --disable-all -E errcheck - - # Optional: show only new issues if it's a pull request. The default value is `false`. - # only-new-issues: true - - # Optional: if set to true then the all caching functionality will be complete disabled, - # takes precedence over all other caching options. - skip-cache: true - - # Optional: if set to true then the action don't cache or restore ~/go/pkg. - skip-pkg-cache: true - - # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. - skip-build-cache: true + cd lib/libpcap/ && sudo make install + cd $GITHUB_WORKSPACE + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.2 + pwd + $(go env GOPATH)/bin/golangci-lint run --disable-all -E errcheck - name: Build NOCORE run: | make clean @@ -75,7 +60,7 @@ jobs: - name: Install Compilers run: | sudo apt-get update - sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-14 clang-14 linux-tools-common linux-tools-generic + sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-14 clang-14 linux-tools-common linux-tools-generic gcc for tool in "clang" "llc" "llvm-strip" do sudo rm -f /usr/bin/$tool @@ -93,6 +78,10 @@ jobs: make -j8 - name: golangci-lint uses: golangci/golangci-lint-action@v4 + env: + CGO_CFLAGS: -O2 -g -gdwarf-4 -I$GITHUB_WORKSPACE/lib/libpcap/ + CGO_LDFLAGS: -O2 -g -L$GITHUB_WORKSPACE/lib/libpcap/ -lpcap -static + CC: /usr/bin/clang with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version # version: v3.2.0