From 1ff2bdb0d10b4ce2d2d686f852609032306b6697 Mon Sep 17 00:00:00 2001 From: 7c00d Date: Tue, 23 Mar 2027 07:21:07 +0800 Subject: [PATCH] adding github workflow to render docs and lint This should be equivalent to the .travis-ci workflow, but run in GitHub actions. I am using the exact commit of the v1 release, as that is considered safer practice than the tag/release itself. Signed-off-by: vsoch --- .github/workflows/docs-and-linting.yml | 49 ++++++++++++++++++++++ .travis.yml | 30 ------------- Makefile | 9 ++-- schema/fs.go | 58 ++++++++++++++++++++++---- 4 files changed, 102 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/docs-and-linting.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/docs-and-linting.yml b/.github/workflows/docs-and-linting.yml new file mode 100644 index 00000000..30be61e3 --- /dev/null +++ b/.github/workflows/docs-and-linting.yml @@ -0,0 +1,49 @@ +name: Render and Lint Documentation + +on: + pull_request: + branches_ignore: [] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + go: ['1.10', '1.11', '1.12'] + + name: Documentation and Linting + steps: + + - uses: actions/checkout@v2 + with: + path: go/src/github.com/opencontainers/image-spec + + # commit for v1 release + - uses: actions/setup-go@0caeaed6fd66a828038c2da3c0f662a42862658f + with: + go-version: ${{ matrix.go }} + + - name: Render and Lint + env: + GOPATH: /home/runner/work/image-spec/image-spec/go + run: | + export PATH=$GOPATH/bin:$PATH + docker pull quay.io/oci/pandoc:1.17.0.3-2.fc25.x86_64 + cd go/src/github.com/opencontainers/image-spec + make install.tools + go get -u github.com/alecthomas/gometalinter + gometalinter --install + go get -t -d ./... + ls ../ + make + make .gitvalidation + make lint + make check-license + make test + make docs + + - name: documentation artifacts + uses: actions/upload-artifact@v2 + with: + name: oci-docs + path: go/src/github.com/opencontainers/image-spec/output diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 624e455e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: go -go: - - 1.10.x - - 1.11.x - - 1.12.x - -sudo: required - -services: - - docker - -before_script: - - export PATH=$HOME/gopath/bin:$PATH - -before_install: - - docker pull quay.io/oci/pandoc:1.17.0.3-2.fc25.x86_64 - - make install.tools - - go get -u github.com/alecthomas/gometalinter - - gometalinter --install - - go get -t -d ./... - -install: true - -script: - - env | grep TRAVIS_ - - make .gitvalidation - - make lint - - make check-license - - make test - - make docs diff --git a/Makefile b/Makefile index 56bfadfc..e84625af 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,13 @@ export GO15VENDOREXPERIMENT DOCKER ?= $(shell command -v docker 2>/dev/null) PANDOC ?= $(shell command -v pandoc 2>/dev/null) -OUTPUT_DIRNAME ?= output/ +OUTPUT_DIRNAME ?= output DOC_FILENAME ?= oci-image-spec PANDOC_CONTAINER ?= quay.io/oci/pandoc:1.17.0.3-2.fc25.x86_64 ifeq "$(strip $(PANDOC))" '' ifneq "$(strip $(DOCKER))" '' PANDOC = $(DOCKER) run \ - -it \ --rm \ -v $(shell pwd)/:/input/:ro \ -v $(shell pwd)/$(OUTPUT_DIRNAME)/:/$(OUTPUT_DIRNAME)/ \ @@ -107,11 +106,11 @@ img/%.png: img/%.dot dot -Tpng $^ > $@ -# When this is running in travis, it will only check the travis commit range +# When this is running in GitHub, it will only check the commit range .gitvalidation: @which git-validation > /dev/null 2>/dev/null || (echo "ERROR: git-validation not found. Consider 'make install.tools' target" && false) -ifdef TRAVIS_COMMIT_RANGE - git-validation -q -run DCO,short-subject,dangling-whitespace +ifdef GITHUB_SHA + git-validation -q -run DCO,short-subject,dangling-whitespace -range $(GITHUB_SHA)..HEAD else git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD endif diff --git a/schema/fs.go b/schema/fs.go index 5baeeaec..ca5bbe95 100644 --- a/schema/fs.go +++ b/schema/fs.go @@ -20,6 +20,8 @@ import ( "bytes" "compress/gzip" "encoding/base64" + "fmt" + "io" "io/ioutil" "net/http" "os" @@ -114,7 +116,24 @@ func (f *_escFile) Close() error { } func (f *_escFile) Readdir(count int) ([]os.FileInfo, error) { - return nil, nil + if !f.isDir { + return nil, fmt.Errorf(" escFile.Readdir: '%s' is not directory", f.name) + } + + fis, ok := _escDirs[f.local] + if !ok { + return nil, fmt.Errorf(" escFile.Readdir: '%s' is directory, but we have no info about content of this dir, local=%s", f.name, f.local) + } + limit := count + if count <= 0 || limit > len(fis) { + limit = len(fis) + } + + if len(fis) == 0 && count > 0 { + return nil, io.EOF + } + + return fis[0:limit], nil } func (f *_escFile) Stat() (os.FileInfo, error) { @@ -205,9 +224,10 @@ func _escFSMustString(useLocal bool, name string) string { var _escData = map[string]*_escFile{ "/config-schema.json": { + name: "config-schema.json", local: "config-schema.json", size: 2771, - modtime: 1515512099, + modtime: 1619819526, compressed: ` H4sIAAAAAAAC/+RWQY/TPBC951dE2T22m+/wnXot3JCKVAGHFarcZNLOEnvMeIKIUP87itNCkjpp6apc OEUaz7z35nns+EcUx0kOLmO0gmSSRZysLJglGVFogOMlmQJ38dpChgVmymfNmrJHl+1Bq6ZkL2IXafri @@ -223,9 +243,10 @@ MzuH6GcAAAD//0pj2wvTCgAA }, "/content-descriptor.json": { + name: "content-descriptor.json", local: "content-descriptor.json", size: 1079, - modtime: 1537191585, + modtime: 1619819526, compressed: ` H4sIAAAAAAAC/5yTsW7cMAyGdz8F4QTIkos6BB2MIEu7d2i3ooNOok5Mz5JK8RBci7x7QcvX2G2RILfZ xP+Rn2zqVwfQe6yOqQjl1A/QfyqYPuQklhIy6BMmgY9zKDN8LugokLMTca0tLquLOFrFo0gZjHmoOW1a @@ -238,9 +259,10 @@ dIbaEm+G3WzZM/44EKMqff37riz3dL0uHcC37qn7HQAA//9DKIMKNwQAAA== }, "/defs-descriptor.json": { + name: "defs-descriptor.json", local: "defs-descriptor.json", size: 844, - modtime: 1537191664, + modtime: 1619819526, compressed: ` H4sIAAAAAAAC/5SST2/TTBDG7/kU826jt0DiOHBAqlWKKnrnUE6t0mi6O7aneP9od6IqVPnuaG03SYtA cLC1+2jmefwbz9MEQBlKOnIQ9k5VoK6oZsf5liBgFNabDiOIh6+B3BfvBNlRhKuxzUe4DqS5Zo29x3ww @@ -254,9 +276,10 @@ TAMAAA== }, "/defs.json": { + name: "defs.json", local: "defs.json", size: 1670, - modtime: 1515512099, + modtime: 1619819526, compressed: ` H4sIAAAAAAAC/7STza6bMBCF9zzFyO2S9oJtbGDb7hMpy6oLSiaJq2AjY6RWEe9e8RNChFuJKneRgGc8 3zmeMbcAgByxKa2qnTKa5EC+4klp1a8aaBs8grtY054vpnXgLgi7GvUXo12hNFo41FiqkyqLoTwceTOA @@ -269,9 +292,10 @@ fIvD7in0ryMEy+fK1G6UfmdTE+tvpoL+1wV/AgAA//96IpqyhgYAAA== }, "/image-index-schema.json": { + name: "image-index-schema.json", local: "image-index-schema.json", size: 2993, - modtime: 1515512099, + modtime: 1619819526, compressed: ` H4sIAAAAAAAC/6yWz0/jOhDH7/0rRgGJC5CnJ/QOFeLy9sJpD4v2suJg7EkybGNnx1Ogu+r/vrJN2qRJ C4Te2rHnO5/vxL/+zAAyg14zNULOZnPIvjZo/3dWFFlkuK1ViXBrDb7AtwY1FaRVnHoeck+9rrBWIa8S @@ -289,9 +313,10 @@ VmZjL8HOE24GcD9bz/4GAAD//yCnv52xCwAA }, "/image-layout-schema.json": { + name: "image-layout-schema.json", local: "image-layout-schema.json", size: 439, - modtime: 1515512099, + modtime: 1619819526, compressed: ` H4sIAAAAAAAC/2yPQUvEMBCF7/0VQ/Sg4DYVPOW6pwVhD4IX8VDTaTvLNonJVFik/12SaRXRU5g38+W9 91kBqA6TjRSYvFMG1DGg23vHLTmMcJjaAeGxvfiZ4cmOOLXqLlPXSQYDamQORutT8m4nau3joLvY9rxr @@ -302,9 +327,10 @@ HrRoV8JRtyHJaO0DOruZpYLJtaZsrM/FWEi+BMysfzuhXbUQfcDIhEkZyG2yQyYl8TPGJLVk97fth1yA }, "/image-manifest-schema.json": { + name: "image-manifest-schema.json", local: "image-manifest-schema.json", size: 921, - modtime: 1515512099, + modtime: 1619819526, compressed: ` H4sIAAAAAAAC/5ySMW8iMRCF+/0VI0MJ+O501bZXUZxSJEoTpXB2x7uDWNsZmygo4r9HtnHAkCKifTvv zTdv/dEAiB59x+QCWSNaEHcOzT9rgiKDDOtJDQj/lSGNPsC9w440dSpNL6J97rsRJxWtYwiulXLjrVlm @@ -317,7 +343,21 @@ Dj+ZAwAA }, "/": { + name: "/", + local: `.`, isDir: true, - local: "", + }, +} + +var _escDirs = map[string][]os.FileInfo{ + + ".": { + _escData["/config-schema.json"], + _escData["/content-descriptor.json"], + _escData["/defs-descriptor.json"], + _escData["/defs.json"], + _escData["/image-index-schema.json"], + _escData["/image-layout-schema.json"], + _escData["/image-manifest-schema.json"], }, }