Skip to content

Commit

Permalink
chore: add test workflow
Browse files Browse the repository at this point in the history
* add gotest step to build
* add coverage upload to codecov

Signed-off-by: Ravi Chamarthy <[email protected]>
  • Loading branch information
rchamarthy committed Aug 27, 2024
1 parent 6edbb3d commit 9a625e2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ jobs:
- name: lint
run: |
make gofmt
- name : unit
run: |
make gotest
- name: make
run: |
go get -v ./...
Expand All @@ -77,7 +80,12 @@ jobs:
atomfs umount dest
[ -f upper/zz ]
EOF
- name: Upload code coverage
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true # optional (default = false)
files: ./coverage.txt
token: ${{ secrets.CODECOV_TOKEN }} # required
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ bin/
/snapshot
/.tool
/.task
tools/

# changelog generation
CHANGELOG.md
Expand Down Expand Up @@ -59,9 +60,11 @@ VERSION
*.so
*.dylib
.made-gofmt
.lint

# Test binary, build with `go test -c`
*.test
coverage.txt

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
all: gotest atomfs
all: lint gotest atomfs

MAIN_VERSION ?= $(shell git describe --always --dirty || echo no-git)
ifeq ($(MAIN_VERSION),$(filter $(MAIN_VERSION), "", no-git))
$(error "Bad value for MAIN_VERSION: '$(MAIN_VERSION)'")
endif

ROOT := $(shell git rev-parse --show-toplevel)
GO_SRC_DIRS := . $(ROOT)/cmd/atomfs
GO_SRC := $(shell find $(GO_SRC_DIRS) -name "*.go")
GO_SRC := $(shell find . -name "*.go")
VERSION_LDFLAGS=-X main.Version=$(MAIN_VERSION)

.PHONY: gofmt
Expand All @@ -21,8 +20,9 @@ atomfs: .made-gofmt $(GO_SRC)
cd $(ROOT)/cmd/atomfs && go build -buildvcs=false -ldflags "$(VERSION_LDFLAGS)" -o $(ROOT)/bin/atomfs ./...

gotest: $(GO_SRC)
go test -ldflags "$(VERSION_LDFLAGS)" ./...
go test -coverprofile=coverage.txt -ldflags "$(VERSION_LDFLAGS)" ./...

clean:
rm -f $(ROOT)/cmd/atomfs/atomfs
rm -f $(ROOT)/bin
rm .made-*
rm .lint
3 changes: 2 additions & 1 deletion molecule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (
)

func TestAllowMissingVerityData(t *testing.T) {
t.Parallel()
assert := assert.New(t)

// no root hash annotations on this descriptor...
const hash = "73cd1a9ab86defeb5e22151ceb96b347fc58b4318f64be05046c51d407a364eb"
d := digest.NewDigestFromEncoded(digest.Algorithm("sha256"), hash)
mol := Molecule{
Atoms: []ispec.Descriptor{ispec.Descriptor{Digest: d}},
Atoms: []ispec.Descriptor{{Digest: d}},
}

err := mol.mountUnderlyingAtoms()
Expand Down
1 change: 1 addition & 0 deletions squashfs/verity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var uidmapTests = []uidmapTestcase{
}

func TestAmHostRoot(t *testing.T) {
t.Parallel()
assert := assert.New(t)
for _, testcase := range uidmapTests {
v := uidmapIsHost(testcase.uidmap)
Expand Down

0 comments on commit 9a625e2

Please sign in to comment.