Skip to content

Commit d0e1005

Browse files
committed
Split github.com/opencontainers/image-spec/schema into a separate Go module
Signed-off-by: Miloslav Trmač <[email protected]>
1 parent 3483a92 commit d0e1005

File tree

7 files changed

+35
-16
lines changed

7 files changed

+35
-16
lines changed

.github/workflows/docs-and-linting.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
# current Go releases plus the version in the go.mod are tested
23-
go: ['go.mod', 'oldstable', 'stable']
22+
# Current Go releases plus the versions in **/go.mod are tested.
23+
# See also BUILD_SPEC_MODULE_ONLY below.
24+
go: ['go.mod', 'schema/go.mod', 'oldstable', 'stable']
2425
# https://github.com/actions/setup-go/tree/v5#getting-go-version-from-the-gomod-file
2526
# https://github.com/actions/setup-go/tree/v5#using-stableoldstable-aliases
2627

@@ -31,17 +32,19 @@ jobs:
3132

3233
- uses: actions/setup-go@v5
3334
with:
34-
go-version: ${{ matrix.go != 'go.mod' && matrix.go || null }}
35-
go-version-file: ${{ matrix.go == 'go.mod' && 'go.mod' || null }}
36-
# cache-dependency-path: go.sum
35+
go-version: ${{ !endsWith(matrix.go, 'go.mod') && matrix.go || null }}
36+
go-version-file: ${{ endsWith(matrix.go, 'go.mod') && matrix.go || null }}
37+
cache-dependency-path: ./**/go.sum
3738

3839
- name: Render and Lint
3940
env:
4041
# do not automatically upgrade go to a different version: https://go.dev/doc/toolchain
4142
GOTOOLCHAIN: local
43+
BUILD_SPEC_MODULE_ONLY: ${{ matrix.go == 'go.mod' }}
4244
run: |
4345
export PATH="$(go env GOPATH)/bin:$PATH"
4446
make install.tools
47+
go work init . schema
4548
go get -t -d ./...
4649
ls ../
4750
make

HACKING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Prerequisites:
1313
- Go - latest version is recommended, see the [go.mod](go.mod) file for the minimum requirement
1414
- make
1515

16+
While developing features spanning `specs-go` and `schema`, to break the dependency cycle on an uncommitted work:
17+
18+
```shell
19+
go work init . schema
20+
```
21+
1622
The following make targets are relevant for any work involving the Go packages.
1723

1824
### Linting

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ header.html: .tool/genheader.go specs-go/version.go
7575

7676
.PHONY: validate-examples
7777
validate-examples: schema/schema.go ## validate examples in the specification markdown files
78-
go test -run TestValidate ./schema
78+
cd schema && go test -run TestValidate .
7979

8080
.PHONY: check-license
8181
check-license: ## check license headers in source files
@@ -91,6 +91,7 @@ lint: lint-go lint-md ## Run all linters
9191
lint-go: .install.lint ## lint check of Go files using golangci-lint
9292
@echo "checking Go lint"
9393
@GO111MODULE=on $(GOPATH)/bin/golangci-lint run
94+
@[ "$$BUILD_SPEC_MODULE_ONLY" = true ] || { cd schema && GO111MODULE=on $(GOPATH)/bin/golangci-lint run; }
9495

9596
.PHONY: lint-md
9697
lint-md: ## Run linting for markdown
@@ -99,7 +100,8 @@ lint-md: ## Run linting for markdown
99100

100101
.PHONY: test
101102
test: ## run the unit tests
102-
go test -race -cover $(shell go list ./... | grep -v /vendor/)
103+
go test -race -cover ./...
104+
[ "$$BUILD_SPEC_MODULE_ONLY" = true ] || { cd schema && go test -race -cover ./...; }
103105

104106
img/%.png: img/%.dot ## generate PNG from dot file
105107
dot -Tpng $^ > $@

go.mod

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,4 @@ module github.com/opencontainers/image-spec
55
// For example, updating this version to 1.19 first requires Go 1.21 to be released.
66
go 1.18
77

8-
require (
9-
github.com/opencontainers/go-digest v1.0.0
10-
github.com/russross/blackfriday v1.6.0
11-
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
12-
)
8+
require github.com/opencontainers/go-digest v1.0.0

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
22
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
3-
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
4-
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
5-
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4=
6-
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=

schema/go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/opencontainers/image-spec/schema
2+
3+
go 1.21
4+
5+
require (
6+
github.com/opencontainers/go-digest v1.0.0
7+
github.com/opencontainers/image-spec v1.1.1
8+
github.com/russross/blackfriday v1.6.0
9+
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
10+
)

schema/go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
2+
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
3+
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
4+
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
5+
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4=
6+
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=

0 commit comments

Comments
 (0)