diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46142d5b..c0482cf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: git diff --exit-code -- go.mod go.sum - name: Build Source - run: go run ./magefiles/mage.go build:source + run: go build ./... - name: Install Lint uses: golangci/golangci-lint-action@v2 @@ -44,7 +44,7 @@ jobs: golangci-lint run - name: Run Tests - run: go run ./magefiles/mage.go cover:unit cover.out + run: go test -coverprofile cover.out -race ./... - name: Upload coverage report uses: codecov/codecov-action@v2 diff --git a/.golangci.yml b/.golangci.yml index bc922c1e..5e9952b1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,10 +2,6 @@ # For website terms of use, trademark policy, privacy policy and other # project policies see https://lfprojects.org/policies -run: - build-tags: - - mage - linters: disable-all: true enable: diff --git a/README.md b/README.md index e5fb8b28..4d165032 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Build Status](https://github.com/apptainer/sif/actions/workflows/ci.yml/badge.svg)](https://github.com/apptainer/sif/actions/workflows/ci.yml) [![Code Coverage](https://codecov.io/gh/apptainer/sif/branch/master/graph/badge.svg)](https://codecov.io/gh/apptainer/sif) [![Go Report Card](https://goreportcard.com/badge/github.com/apptainer/sif)](https://goreportcard.com/report/github.com/apptainer/sif) -[![Built with Mage](https://magefile.org/badge.svg)](https://magefile.org) +[![Powered By GoReleaser](https://img.shields.io/badge/powered%20by-goreleaser-green.svg)](https://github.com/goreleaser) This module contains an open source implementation of the Singularity Image Format (SIF) that makes it easy to create complete and @@ -15,22 +15,9 @@ encapsulated container environments stored in a single file. Unless otherwise noted, the SIF source files are distributed under the BSD-style license found in the [LICENSE.md](LICENSE.md) file. -## Download and Install From Source +## Install Siftool -To get the sif package to use directly from your programs: - -```sh -go get -d github.com/apptainer/sif/v2 -``` - -To get the siftool CLI program installed to `$(go env GOPATH)/bin` to -manipulate SIF container files: - -```sh -git clone https://github.com/apptainer/sif -cd sif -go run ./magefiles/mage.go install -``` +Pre-built binaries are available with the [latest release](https://github.com/apptainer/sif/releases). ## Go Version Compatibility diff --git a/cmd/siftool/siftool.go b/cmd/siftool/siftool.go index 774bd545..2151417f 100644 --- a/cmd/siftool/siftool.go +++ b/cmd/siftool/siftool.go @@ -29,7 +29,6 @@ var ( date = "" builtBy = "" commit = "" - state = "" ) func writeVersion(w io.Writer) error { @@ -43,11 +42,7 @@ func writeVersion(w io.Writer) error { } if commit != "" { - if state == "" { - fmt.Fprintf(tw, "Commit:\t%v\n", commit) - } else { - fmt.Fprintf(tw, "Commit:\t%v (%v)\n", commit, state) - } + fmt.Fprintf(tw, "Commit:\t%v\n", commit) } if date != "" { diff --git a/go.mod b/go.mod index be64dc06..6c29fa86 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/blang/semver/v4 v4.0.0 github.com/go-git/go-git/v5 v5.4.2 github.com/google/uuid v1.3.0 - github.com/magefile/mage v1.13.0 github.com/sebdah/goldie/v2 v2.5.3 github.com/spf13/cobra v1.4.0 github.com/spf13/pflag v1.0.5 @@ -28,7 +27,7 @@ require ( github.com/sergi/go-diff v1.1.0 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect - golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect - golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect + golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect + golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 7df736c2..3a09e9a8 100644 --- a/go.sum +++ b/go.sum @@ -52,8 +52,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/magefile/mage v1.13.0 h1:XtLJl8bcCM7EFoO8FyH8XK3t7G5hQAeK+i4tq+veT9M= -github.com/magefile/mage v1.13.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -90,9 +88,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -100,16 +97,13 @@ golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211205182925-97ca703d548d h1:FjkYO/PPp4Wi0EAUOVLxePm7qVW4r4ctbWpURyuOD0E= -golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/magefiles/mage.go b/magefiles/mage.go deleted file mode 100644 index a8104792..00000000 --- a/magefiles/mage.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Contributors to the Apptainer project, established as -// Apptainer a Series of LF Projects LLC. -// For website terms of use, trademark policy, privacy policy and other -// project policies see https://lfprojects.org/policies -// Copyright (c) 2021-2022, Sylabs Inc. All rights reserved. -// This software is licensed under a 3-clause BSD license. Please consult the -// LICENSE file distributed with the sources of this project regarding your -// rights to use or distribute this software. - -//go:build ignore - -package main - -import ( - "os" - - "github.com/magefile/mage/mage" -) - -func main() { os.Exit(mage.Main()) } diff --git a/magefiles/magefile.go b/magefiles/magefile.go deleted file mode 100644 index f2e8a605..00000000 --- a/magefiles/magefile.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) Contributors to the Apptainer project, established as -// Apptainer a Series of LF Projects LLC. -// For website terms of use, trademark policy, privacy policy and other -// project policies see https://lfprojects.org/policies -// Copyright (c) 2021-2022, Sylabs Inc. All rights reserved. -// This software is licensed under a 3-clause BSD license. Please consult the -// LICENSE file distributed with the sources of this project regarding your -// rights to use or distribute this software. - -//go:build mage - -package main - -import ( - "fmt" - "os" - "strings" - "time" - - "github.com/apptainer/sif/v2/internal/pkg/git" - "github.com/magefile/mage/mg" - "github.com/magefile/mage/sh" -) - -// Aliases defines command-line aliases exposed by Mage. -//nolint:deadcode -var Aliases = map[string]interface{}{ - "build": Build.All, - "cover": Cover.All, - "install": Install.All, - "test": Test.All, -} - -// env returns the environment to use when running Go commands. -func env() map[string]string { - return map[string]string{"CGO_ENABLED": "0"} -} - -// ldFlags returns linker flags to pass to various Go commands. -func ldFlags() string { - vals := []string{"-s", "-w", "-X", "main.builtBy=mage"} - - // Attempt to get git details. - if d, err := git.Describe("."); err == nil { - vals = append(vals, "-X", fmt.Sprintf("main.commit=%v", d.CommitHash())) - - if d.IsClean() { - vals = append(vals, - "-X", fmt.Sprintf("main.date=%v", d.CommitTime().UTC().Format(time.RFC3339)), - "-X", "main.state=clean", - ) - } else { - vals = append(vals, - "-X", fmt.Sprintf("main.date=%v", time.Now().UTC().Format(time.RFC3339)), - "-X", "main.state=dirty", - ) - } - - if v, err := d.Version(); err == nil { - vals = append(vals, "-X", fmt.Sprintf("main.version=%v", v)) - } else { - fmt.Fprintf(os.Stderr, "warning: failed to get version: %v\n", err) - } - } else { - fmt.Fprintf(os.Stderr, "warning: failed to describe git HEAD: %v\n", err) - - vals = append(vals, "-X", fmt.Sprintf("main.date=%v", time.Now().UTC().Format(time.RFC3339))) - } - - return strings.Join(vals, " ") -} - -type Build mg.Namespace - -// All compiles all assets. -func (ns Build) All() { - mg.Deps(ns.Source) -} - -// Source compiles all source code. -func (Build) Source() error { - return sh.RunWith(env(), mg.GoCmd(), "build", "-trimpath", "-ldflags", ldFlags(), "./...") -} - -type Install mg.Namespace - -// All installs all assets. -func (ns Install) All() { - mg.Deps(ns.Bin) -} - -// Bin installs binary to GOBIN. -func (Install) Bin() error { - return sh.RunWith(env(), mg.GoCmd(), "install", "-trimpath", "-ldflags", ldFlags(), "./cmd/siftool") -} - -type Test mg.Namespace - -// All runs all tests. -func (ns Test) All() { - mg.Deps(ns.Unit) -} - -// Unit runs all unit tests. -func (Test) Unit() error { - return sh.RunV(mg.GoCmd(), "test", "-race", "-cover", "./...") -} - -type Cover mg.Namespace - -// All runs all tests, writing coverage profile to the specified path. -func (ns Cover) All(path string) { - mg.Deps(mg.F(ns.Unit, path)) -} - -// Unit runs all unit tests, writing coverage profile to the specified path. -func (Cover) Unit(path string) error { - return sh.RunV(mg.GoCmd(), "test", "-race", "-coverprofile", path, "./...") -}