Skip to content

Commit 35cda54

Browse files
authored
Merge pull request #1 from mmulholla/addgomodfortests
Addgomodfortests
2 parents 9232302 + cc47966 commit 35cda54

File tree

576 files changed

+103198
-23183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

576 files changed

+103198
-23183
lines changed

.github/workflows/ci.yaml

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v2
1616

1717
- name: Setup Go environment
18-
uses: actions/[email protected].2
18+
uses: actions/[email protected].3
1919
with:
2020
# The Go version to download (if necessary) and use. Supports semver spec and ranges.
2121
go-version: 1.13
@@ -56,4 +56,51 @@ jobs:
5656
working-directory: generator
5757
run: |
5858
go fmt -x ./...
59-
git diff --exit-code || { echo 'Go sources need to be formated. Execute "go fmt -x ./..." locally in the 'generator' folder and commit changes to fix an issue'; exit 1; }
59+
git diff --exit-code || { echo 'Go sources need to be formated. Execute "go fmt -x ./..." locally in the 'generator' folder and commit changes to fix an issue'; exit 1; }
60+
- name: Upload Json schemas
61+
uses: actions/upload-artifact@v2
62+
with:
63+
name: devfile-json-schema
64+
path: schemas/latest/devfile.json
65+
66+
publish-next-json-schema:
67+
if: success() && github.event_name == 'push'
68+
runs-on: ubuntu-latest
69+
needs: [build-and-validate]
70+
steps:
71+
- name: Checkout devfile docs
72+
uses: actions/checkout@v2
73+
with:
74+
repository: devfile/docs
75+
persist-credentials: false
76+
path: docs-repo
77+
- name: Checkout devfile api
78+
uses: actions/checkout@v2
79+
with:
80+
path: api-repo
81+
- name: Download Json Schema
82+
uses: actions/download-artifact@v2
83+
with:
84+
name: devfile-json-schema
85+
- name: Overwrite Next Json Schema in Docs
86+
run: cp -f devfile.json docs-repo/docs/modules/user-guide/attachments/jsonschemas/next/devfile.json
87+
- name: Push to the devfile/docs repo
88+
working-directory: docs-repo/
89+
run: |
90+
if [ "$(git status -s)" == "" ]
91+
then
92+
echo "Nothing to commit, Json schema didn't change"
93+
exit 0
94+
fi
95+
96+
lastCommit="$(cd ../api-repo; git log -1 --format=%H)"
97+
lastCommitterName="$(cd ../api-repo; git log -1 --format=%an)"
98+
lastCommitterEmail="$(cd ../api-repo; git log -1 --format=%ae)"
99+
100+
git config --global user.email "${lastCommitterEmail}"
101+
git config --global user.name "${lastCommitterName}"
102+
103+
git add docs/modules/user-guide/attachments/jsonschemas/next/devfile.json
104+
git commit -m "Update devfile schema based on devfile/api@${lastCommit}"
105+
git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/docs"
106+

.github/workflows/release-schema.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release Devfile Schema
2+
3+
# Triggers the workflow when a release is published on GitHub.
4+
on:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
release-json-schema:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout devfile docs
13+
uses: actions/checkout@v2
14+
with:
15+
repository: devfile/docs
16+
persist-credentials: false
17+
path: docs-repo
18+
- name: Checkout devfile api
19+
uses: actions/checkout@v2
20+
with:
21+
path: api-repo
22+
- name: Get the version being released
23+
id: get_version
24+
run: echo ::set-output name=version::$(cat api-repo/schemas/latest/jsonSchemaVersion.txt)
25+
- name: Overwrite Stable Json Schema in Docs if needed
26+
run: |
27+
if [ ! -f docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/jsonSchemaVersion.txt ]; then
28+
# Stable version doesn't currently exist, so just copy over the schema we're releasing
29+
mkdir -p docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable
30+
cp -f api-repo/schemas/latest/{devfile.json,jsonSchemaVersion.txt} \
31+
docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/
32+
exit 0
33+
fi
34+
35+
# Parse the schema version that's being released
36+
IFS='.' read -a semver <<< "${{ steps.get_version.outputs.VERSION }}"
37+
MAJOR=${semver[0]}
38+
MINOR=${semver[1]}
39+
BUGFIX=${semver[2]}
40+
41+
# Parse the version currently set to stable
42+
stableVersion=`cat docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/jsonSchemaVersion.txt`
43+
IFS='.' read -a stableSemVer <<< "$stableVersion"
44+
stableMajor=${stableSemVer[0]}
45+
stableMinor=${stableSemVer[1]}
46+
stableBugfix=$(echo ${stableSemVer[2]} | awk -F '-' '{print $1}')
47+
48+
# Compare the two versions, only update stable if needed
49+
if ((stableMajor <= MAJOR)) && ((stableMinor <= MINOR)) && ((stableBugfix <= BUGFIX)); then
50+
cp -f api-repo/schemas/latest/{devfile.json,jsonSchemaVersion.txt} \
51+
docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/
52+
else
53+
echo "::warning::Current stable schema version is newer than the schema version being released, so the stable schema will not be updated."
54+
fi
55+
- name: Copy released Json Schema to Docs
56+
run: |
57+
mkdir -p docs-repo/docs/modules/user-guide/attachments/jsonschemas/${{ steps.get_version.outputs.VERSION }} && \
58+
cp -f api-repo/schemas/latest/devfile.json \
59+
docs-repo/docs/modules/user-guide/attachments/jsonschemas/${{ steps.get_version.outputs.VERSION }}/devfile.json
60+
- name: Push to the devfile/docs repo
61+
working-directory: docs-repo/
62+
run: |
63+
if [ "$(git status -s)" == "" ]
64+
then
65+
echo "Nothing to commit, Json schema didn't change"
66+
exit 0
67+
fi
68+
69+
lastCommit="$(cd ../api-repo; git log -1 --format=%H)"
70+
lastCommitterName="$(cd ../api-repo; git log -1 --format=%an)"
71+
lastCommitterEmail="$(cd ../api-repo; git log -1 --format=%ae)"
72+
73+
git config --global user.email "${lastCommitterEmail}"
74+
git config --global user.name "${lastCommitterName}"
75+
76+
git add --all
77+
git commit -m "Update devfile schema based on devfile/api@${lastCommit}"
78+
git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/docs"
79+

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Temporary Build Files
22
build/_output
33
build/_test
4+
test/**/tmp
5+
test/go/pkg
46
# Created by https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
57
### Emacs ###
68
# -*- mode: gitignore; -*-
@@ -78,3 +80,5 @@ tags
7880
# IDE folders
7981
.idea
8082
generator/build/generator
83+
#Mac file
84+
.DS_Store

.theia/settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"go.lintFlags": ["--fast"],
44
"go.useLanguageServer": true,
55
"yaml.schemas": {
6-
"./schemas/latest/ide-targeted/devfile.json": [ "samples/devfiles/*devfile.yaml", "samples/devfile-registry/*.yaml" ],
7-
"./schemas/latest/ide-targeted/dev-workspace.json": [ "samples/devworkspaces/*.yaml" ],
8-
"./schemas/latest/ide-targeted/dev-workspace-template.json": [ "samples/devworkspace-templates/*.yaml" ],
6+
"./schemas/latest/ide-targeted/devfile.json": [ "samples/*/*devfile.yaml", "samples/devfile-registry/*.yaml" ],
7+
"./schemas/latest/ide-targeted/dev-workspace.json": [ "samples/*/*devworkspace.yaml" ],
8+
"./schemas/latest/ide-targeted/dev-workspace-template.json": [ "samples/*/*devworkspacetemplate.yaml" ],
99
"./schemas/latest/ide-targeted/dev-workspace-template-spec.json": [ "pkg/utils/overriding/test-fixtures/patches/**/original.yaml", "pkg/utils/overriding/test-fixtures/patches/**/result.yaml", "pkg/utils/overriding/test-fixtures/merges/*.yaml" ],
1010
"./schemas/latest/ide-targeted/parent-overrides.json": [ "pkg/utils/overriding/test-fixtures/**/patch.yaml" ]
1111
}

build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ generator/build/generator "interfaces" "paths=./pkg/apis/workspaces/v1alpha2"
5151

5252
echo "Generating K8S CRDs"
5353

54-
generator/build/generator "crds" "output:crds:artifacts:config=crds" "paths=./pkg/apis/workspaces/v1alpha2"
54+
generator/build/generator "crds" "output:crds:artifacts:config=crds" "paths=./pkg/apis/workspaces/v1alpha2;./pkg/apis/workspaces/v1alpha1"
5555

5656
echo "Generating DeepCopy implementations"
5757

58-
generator/build/generator "deepcopy" "paths=./pkg/apis/workspaces/v1alpha2"
58+
generator/build/generator "deepcopy" "paths=./pkg/apis/workspaces/v1alpha2;./pkg/apis/workspaces/v1alpha1"
5959

6060
echo "Generating JsonSchemas"
6161

62-
generator/build/generator "schemas" "output:schemas:artifacts:config=schemas" "paths=./pkg/apis/workspaces/v1alpha2"
62+
generator/build/generator "schemas" "output:schemas:artifacts:config=schemas" "paths=./pkg/apis/workspaces/v1alpha2;./pkg/apis/workspaces/v1alpha1"
6363

6464
echo "Finished generation of required GO sources, K8S CRDs, and Json Schemas"

0 commit comments

Comments
 (0)