-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ramkumar Chinchani <[email protected]>
- Loading branch information
Showing
8 changed files
with
141 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Reusable stacker build for coverage | ||
on: | ||
workflow_call: | ||
inputs: | ||
go-version: | ||
required: true | ||
type: string | ||
description: 'Stringified JSON object listing go versions' | ||
privilege-level: | ||
required: true | ||
type: string | ||
description: 'Stringified JSON object listing stacker privilege-level' | ||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
services: | ||
registry: | ||
image: registry:2 | ||
ports: | ||
- 5000:5000 | ||
strategy: | ||
matrix: | ||
go-version: ${{fromJson(inputs.go-version)}} | ||
privilege-level: ${{fromJson(inputs.privilege-level)}} | ||
name: "golang ${{ matrix.go-version }} privilege ${{ matrix.privilege-level }}" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: benjlevesque/[email protected] | ||
id: short-sha | ||
- name: Set up golang ${{ matrix.go-version }} | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -yy lxc-utils lxc-dev libacl1-dev jq libcap-dev libseccomp-dev libpam-dev bats parallel libzstd-dev | ||
GO111MODULE=off go get github.com/opencontainers/umoci/cmd/umoci | ||
sudo cp ~/go/bin/umoci /usr/bin | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin | ||
sudo apt-get install -yy autoconf automake make autogen autoconf libtool binutils git squashfs-tools libcryptsetup-dev libdevmapper-dev cryptsetup-bin squashfuse | ||
(cd /tmp && git clone https://github.com/AgentD/squashfs-tools-ng && cd squashfs-tools-ng && ./autogen.sh && ./configure --prefix=/usr && make -j2 && sudo make -j2 install && sudo ldconfig -v) | ||
(cd /tmp && git clone https://github.com/anuvu/squashfs && cd squashfs && make && sudo cp squashtool/squashtool /usr/bin) | ||
- if: github.event_name != 'release' || github.event.action != 'published' | ||
name: Build and test | ||
run: | | ||
make check-cov PRIVILEGE_LEVEL=${{ matrix.privilege-level }} | ||
env: | ||
REGISTRY_URL: localhost:5000 | ||
- name: Upload code coverage | ||
uses: codecov/codecov-action@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//go:build testrunmain | ||
// +build testrunmain | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/signal" | ||
"stackerbuild.io/stacker/pkg/log" | ||
"syscall" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func init() { | ||
log.Infof("stacker[%d]: Running with sanity coverage enabled\n", os.Getpid()) | ||
os.Args = append([]string{os.Args[0]}, "-test.coverprofile", fmt.Sprintf("coverage-%d.txt", time.Now().Unix()), "--") | ||
os.Args = append(os.Args, os.Args[1:]...) | ||
} | ||
|
||
func TestRunMain(t *testing.T) { | ||
/* | ||
https://golang.org/pkg/os/signal/#Notify | ||
It is allowed to call Notify multiple times with different channels and the | ||
same signals: each channel receives copies of incoming signals | ||
independently. | ||
*/ | ||
sigs := make(chan os.Signal, 1) | ||
signal.Notify(sigs, syscall.SIGTERM) | ||
done := make(chan struct{}) | ||
go func() { | ||
<-sigs | ||
done <- struct{}{} | ||
}() | ||
|
||
go func() { main() }() | ||
<-done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package main |