Skip to content

Commit

Permalink
chore: add test workflow (#12)
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 authored Aug 30, 2024
1 parent 6edbb3d commit 4cd3ae5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ jobs:
- name: lint
run: |
make gofmt
- name : unit
run: |
make gotest
- name: make
run: |
go get -v ./...
make
make atomfs
cp ./bin/atomfs ~/bin
cp ./bin/atomfs atomfs-${{ matrix.os }}
- name: test
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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ $(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_DIRS := $(shell find . -name "*.go" | xargs -n1 dirname | sort -u)
GO_SRC := $(shell find . -name "*.go")
VERSION_LDFLAGS=-X main.Version=$(MAIN_VERSION)

.PHONY: gofmt
Expand All @@ -21,8 +21,8 @@ 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-*
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 4cd3ae5

Please sign in to comment.