diff --git a/.github/workflows/docs-and-linting.yml b/.github/workflows/docs-and-linting.yml index ec178b0..ba36054 100644 --- a/.github/workflows/docs-and-linting.yml +++ b/.github/workflows/docs-and-linting.yml @@ -19,8 +19,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # current Go releases plus the version in the go.mod are tested - go: ['go.mod', 'oldstable', 'stable'] + # Current Go releases plus the versions in **/go.mod are tested. + # See also BUILD_SPEC_MODULE_ONLY below. + go: ['go.mod', 'schema/go.mod', 'oldstable', 'stable'] # https://github.com/actions/setup-go/tree/v5#getting-go-version-from-the-gomod-file # https://github.com/actions/setup-go/tree/v5#using-stableoldstable-aliases @@ -31,17 +32,19 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go != 'go.mod' && matrix.go || null }} - go-version-file: ${{ matrix.go == 'go.mod' && 'go.mod' || null }} - # cache-dependency-path: go.sum + go-version: ${{ !endsWith(matrix.go, 'go.mod') && matrix.go || null }} + go-version-file: ${{ endsWith(matrix.go, 'go.mod') && matrix.go || null }} + cache-dependency-path: ./**/go.sum - name: Render and Lint env: # do not automatically upgrade go to a different version: https://go.dev/doc/toolchain GOTOOLCHAIN: local + BUILD_SPEC_MODULE_ONLY: ${{ matrix.go == 'go.mod' }} run: | export PATH="$(go env GOPATH)/bin:$PATH" make install.tools + go work init . schema go get -t -d ./... ls ../ make diff --git a/HACKING.md b/HACKING.md index 7f43292..785c5d1 100644 --- a/HACKING.md +++ b/HACKING.md @@ -13,6 +13,12 @@ Prerequisites: - Go - latest version is recommended, see the [go.mod](go.mod) file for the minimum requirement - make +While developing features spanning `specs-go` and `schema`, to break the dependency cycle on an uncommitted work: + +```shell +go work init . schema +``` + The following make targets are relevant for any work involving the Go packages. ### Linting diff --git a/Makefile b/Makefile index 509ebe8..ef82561 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,7 @@ header.html: .tool/genheader.go specs-go/version.go .PHONY: validate-examples validate-examples: schema/schema.go ## validate examples in the specification markdown files - go test -run TestValidate ./schema + cd schema && go test -run TestValidate . .PHONY: check-license check-license: ## check license headers in source files @@ -91,6 +91,7 @@ lint: lint-go lint-md ## Run all linters lint-go: .install.lint ## lint check of Go files using golangci-lint @echo "checking Go lint" @GO111MODULE=on $(GOPATH)/bin/golangci-lint run + @[ "$$BUILD_SPEC_MODULE_ONLY" = true ] || { cd schema && GO111MODULE=on $(GOPATH)/bin/golangci-lint run; } .PHONY: lint-md lint-md: ## Run linting for markdown @@ -99,7 +100,8 @@ lint-md: ## Run linting for markdown .PHONY: test test: ## run the unit tests - go test -race -cover $(shell go list ./... | grep -v /vendor/) + go test -race -cover ./... + [ "$$BUILD_SPEC_MODULE_ONLY" = true ] || { cd schema && go test -race -cover ./...; } img/%.png: img/%.dot ## generate PNG from dot file dot -Tpng $^ > $@ diff --git a/go.mod b/go.mod index 9a45167..61c1193 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,4 @@ module github.com/opencontainers/image-spec // For example, updating this version to 1.19 first requires Go 1.21 to be released. go 1.18 -require ( - github.com/opencontainers/go-digest v1.0.0 - github.com/russross/blackfriday v1.6.0 - github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 -) +require github.com/opencontainers/go-digest v1.0.0 diff --git a/go.sum b/go.sum index dcb5a93..30f45e9 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,2 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= -github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= diff --git a/schema/go.mod b/schema/go.mod new file mode 100644 index 0000000..2e9116e --- /dev/null +++ b/schema/go.mod @@ -0,0 +1,10 @@ +module github.com/opencontainers/image-spec/schema + +go 1.21 + +require ( + github.com/opencontainers/go-digest v1.0.0 + github.com/opencontainers/image-spec v1.1.1 + github.com/russross/blackfriday v1.6.0 + github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 +) diff --git a/schema/go.sum b/schema/go.sum new file mode 100644 index 0000000..dcb5a93 --- /dev/null +++ b/schema/go.sum @@ -0,0 +1,6 @@ +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= +github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=