From a95cc980b40026a1821af86e340576ca7f774973 Mon Sep 17 00:00:00 2001 From: Paul Schultz Date: Wed, 7 Sep 2022 11:16:24 -0500 Subject: [PATCH 1/2] Update landing page release/publish scripts Signed-off-by: Paul Schultz --- .github/workflows/ci.yaml | 186 ++++++++++++++------------ .github/workflows/release-schema.yaml | 78 ++++------- 2 files changed, 129 insertions(+), 135 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d7281acd0..c3768d20d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,79 +3,80 @@ name: CI # Triggers the workflow on push or pull request events but only for the main branch on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: build-and-validate: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Setup Go environment - uses: actions/setup-go@v2.1.3 - with: - # The Go version to download (if necessary) and use. Supports semver spec and ranges. - go-version: 1.18 - - - name: Generate Go sources, CRDs and schemas - run: | - ./docker-run.sh ./build.sh - if [[ ! -z $(git status -s) ]] - then - echo 'Command `./docker-run.sh ./build.sh` did introduce changes, which should not be the case if it had been run as part of the PR. Please run it locally and check in the results as part of your PR.' - git --no-pager diff - exit 1 - fi - - - name: Validate samples against schemas - run: ./docker-run.sh ./validate-samples.sh - - - name: Run GO tests - run: go test -coverprofile test/v200/api-test-coverage.out -v ./... - - - name: Generate test coverage report - run: go tool cover -html=test/v200/api-test-coverage.out -o test/v200/api-test-coverage.html - - - name: Upload Test Coverage results - uses: actions/upload-artifact@v2 - with: - name: api-test-coverage-html - path: test/v200/api-test-coverage.html - - - name: Check typescript model generation - run: ./build/typescript-model/generate.sh - - - name: Check GO mod state - run: | - go mod tidy - go mod vendor - git diff --exit-code || { echo 'Go mod is not clean. Execute "go mod tidy && go mod vendor" locally and commit changes to fix an issue'; exit 1; } - - - name: Check GO format - run: | - go fmt -x ./... - git diff --exit-code || { echo 'Go sources need to be formated. Execute "go fmt -x ./..." locally and commit changes to fix an issue'; exit 1; } - - - name: Check Generator GO mod state - working-directory: generator - run: | - go mod tidy - go mod vendor - git diff --exit-code || { echo 'Go mod is not clean. Execute "go mod tidy && go mod vendor" locally in the 'generator' folder and commit changes to fix an issue'; exit 1; } - - - name: Check Generator GO format - working-directory: generator - run: | - go fmt -x ./... - 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; } - - name: Upload Json schemas - uses: actions/upload-artifact@v2 - with: - name: devfile-json-schema - path: schemas/latest/devfile.json + - uses: actions/checkout@v2 + + - name: Setup Go environment + uses: actions/setup-go@v2.1.3 + with: + # The Go version to download (if necessary) and use. Supports semver spec and ranges. + go-version: 1.18 + + - name: Generate Go sources, CRDs and schemas + run: | + ./docker-run.sh ./build.sh + if [[ ! -z $(git status -s) ]] + then + echo 'Command `./docker-run.sh ./build.sh` did introduce changes, which should not be the case if it had been run as part of the PR. Please run it locally and check in the results as part of your PR.' + git --no-pager diff + exit 1 + fi + + - name: Validate samples against schemas + run: ./docker-run.sh ./validate-samples.sh + + - name: Run GO tests + run: go test -coverprofile test/v200/api-test-coverage.out -v ./... + + - name: Generate test coverage report + run: go tool cover -html=test/v200/api-test-coverage.out -o test/v200/api-test-coverage.html + + - name: Upload Test Coverage results + uses: actions/upload-artifact@v2 + with: + name: api-test-coverage-html + path: test/v200/api-test-coverage.html + + - name: Check typescript model generation + run: ./build/typescript-model/generate.sh + + - name: Check GO mod state + run: | + go mod tidy + go mod vendor + git diff --exit-code || { echo 'Go mod is not clean. Execute "go mod tidy && go mod vendor" locally and commit changes to fix an issue'; exit 1; } + + - name: Check GO format + run: | + go fmt -x ./... + git diff --exit-code || { echo 'Go sources need to be formated. Execute "go fmt -x ./..." locally and commit changes to fix an issue'; exit 1; } + + - name: Check Generator GO mod state + working-directory: generator + run: | + go mod tidy + go mod vendor + git diff --exit-code || { echo 'Go mod is not clean. Execute "go mod tidy && go mod vendor" locally in the 'generator' folder and commit changes to fix an issue'; exit 1; } + + - name: Check Generator GO format + working-directory: generator + run: | + go fmt -x ./... + 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; } + + - name: Upload Json schemas + uses: actions/upload-artifact@v2 + with: + name: devfile-json-schema + path: schemas/latest/devfile.json publish-next-json-schema: if: success() && github.event_name == 'push' @@ -85,36 +86,49 @@ jobs: - name: Checkout devfile docs uses: actions/checkout@v2 with: - repository: devfile/docs + repository: devfile/devfile-web persist-credentials: false - path: docs-repo + path: devfile-web-repo + - name: Checkout devfile api uses: actions/checkout@v2 with: path: api-repo - - name: Download Json Schema - uses: actions/download-artifact@v2 - with: - name: devfile-json-schema - - name: Overwrite Next Json Schema in Docs - run: cp -f devfile.json docs-repo/docs/modules/user-guide/attachments/jsonschemas/next/devfile.json - - name: Push to the devfile/docs repo - working-directory: docs-repo/ + + - name: Get the version being published + id: get_version + run: echo ::set-output name=version::$(cat api-repo/schemas/latest/jsonSchemaVersion.txt) + + - name: Publish the new version on devfile-web run: | - if [ "$(git status -s)" == "" ] - then - echo "Nothing to commit, Json schema didn't change" + py devfile-web-repo/python/src/api_workflow/api_workflow.py --version ${{ steps.get_version.outputs.version }} --devfile-schema api-repo/schemas/latest/devfile.json --release + + - name: Push to the devfile/devfile-web repo + working-directory: devfile-web-repo/ + run: | + # Install dependencies to format the commit + yarn install + + # Format the commit + yarn nx format:write + + # Lint the commit + yarn nx affected --target=lint + yarn nx format:check + + # Don't commit if there are no changes + if [ "$(git status -s)" == "" ]; then + echo "Nothing to commit" exit 0 fi - + lastCommit="$(cd ../api-repo; git log -1 --format=%H)" lastCommitterName="$(cd ../api-repo; git log -1 --format=%an)" lastCommitterEmail="$(cd ../api-repo; git log -1 --format=%ae)" - + git config --global user.email "${lastCommitterEmail}" git config --global user.name "${lastCommitterName}" - - git add docs/modules/user-guide/attachments/jsonschemas/next/devfile.json - git commit -m "Update devfile schema based on devfile/api@${lastCommit}" - git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/docs" - + + git add . + git commit -asm "Update devfile schema based on devfile/api@${lastCommit}" + git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web" diff --git a/.github/workflows/release-schema.yaml b/.github/workflows/release-schema.yaml index c034f3409..317d80f13 100644 --- a/.github/workflows/release-schema.yaml +++ b/.github/workflows/release-schema.yaml @@ -9,71 +9,51 @@ jobs: release-json-schema: runs-on: ubuntu-latest steps: - - name: Checkout devfile docs + - name: Checkout devfile/devfile-web uses: actions/checkout@v2 with: - repository: devfile/docs + repository: devfile/devfile-web persist-credentials: false - path: docs-repo - - name: Checkout devfile api + path: devfile-web-repo + + - name: Checkout devfile/api uses: actions/checkout@v2 with: path: api-repo + - name: Get the version being released id: get_version run: echo ::set-output name=version::$(cat api-repo/schemas/latest/jsonSchemaVersion.txt) - - name: Overwrite Stable Json Schema in Docs if needed - run: | - if [ ! -f docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/jsonSchemaVersion.txt ]; then - # Stable version doesn't currently exist, so just copy over the schema we're releasing - mkdir -p docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable - cp -f api-repo/schemas/latest/{devfile.json,jsonSchemaVersion.txt} \ - docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/ - exit 0 - fi - - # Parse the schema version that's being released - IFS='.' read -a semver <<< "${{ steps.get_version.outputs.VERSION }}" - MAJOR=${semver[0]} - MINOR=${semver[1]} - BUGFIX=${semver[2]} - - # Parse the version currently set to stable - stableVersion=`cat docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/jsonSchemaVersion.txt` - IFS='.' read -a stableSemVer <<< "$stableVersion" - stableMajor=${stableSemVer[0]} - stableMinor=${stableSemVer[1]} - stableBugfix=$(echo ${stableSemVer[2]} | awk -F '-' '{print $1}') - # Compare the two versions, only update stable if needed - if ((stableMajor <= MAJOR)) && ((stableMinor <= MINOR)) && ((stableBugfix <= BUGFIX)); then - cp -f api-repo/schemas/latest/{devfile.json,jsonSchemaVersion.txt} \ - docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/ - else - echo "::warning::Current stable schema version is newer than the schema version being released, so the stable schema will not be updated." - fi - - name: Copy released Json Schema to Docs + - name: Release new version on devfile-web run: | - mkdir -p docs-repo/docs/modules/user-guide/attachments/jsonschemas/${{ steps.get_version.outputs.VERSION }} && \ - cp -f api-repo/schemas/latest/devfile.json \ - docs-repo/docs/modules/user-guide/attachments/jsonschemas/${{ steps.get_version.outputs.VERSION }}/devfile.json - - name: Push to the devfile/docs repo - working-directory: docs-repo/ + py devfile-web-repo/python/src/api_workflow/api_workflow.py --version ${{ steps.get_version.outputs.version }} --devfile-schema api-repo/schemas/latest/devfile.json --release + + - name: Push to the devfile/devfile-web repo + working-directory: devfile-web-repo/ run: | - if [ "$(git status -s)" == "" ] - then - echo "Nothing to commit, Json schema didn't change" + yarn install + + # Format the commit + yarn nx format:write + + # Lint the commit + yarn nx affected --target=lint + yarn nx format:check + + # Don't commit if there are no changes + if [ "$(git status -s)" == "" ]; then + echo "Nothing to commit" exit 0 fi - + lastCommit="$(cd ../api-repo; git log -1 --format=%H)" lastCommitterName="$(cd ../api-repo; git log -1 --format=%an)" lastCommitterEmail="$(cd ../api-repo; git log -1 --format=%ae)" - + git config --global user.email "${lastCommitterEmail}" git config --global user.name "${lastCommitterName}" - - git add --all - git commit -m "Update devfile schema based on devfile/api@${lastCommit}" - git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/docs" - + + git add . + git commit -asm "Update devfile schema based on devfile/api@${lastCommit}" + git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web" From c5f6195a5772e9acbee6b3c407c868dcbb8a7c8d Mon Sep 17 00:00:00 2001 From: Paul Schultz Date: Mon, 19 Sep 2022 10:24:28 -0500 Subject: [PATCH 2/2] update robot to devfile-robot Signed-off-by: Paul Schultz --- .github/workflows/ci.yaml | 2 +- .github/workflows/release-schema.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c3768d20d..5d662c6ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -131,4 +131,4 @@ jobs: git add . git commit -asm "Update devfile schema based on devfile/api@${lastCommit}" - git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web" + git push "https://devfile-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web" diff --git a/.github/workflows/release-schema.yaml b/.github/workflows/release-schema.yaml index 317d80f13..27c500d88 100644 --- a/.github/workflows/release-schema.yaml +++ b/.github/workflows/release-schema.yaml @@ -56,4 +56,4 @@ jobs: git add . git commit -asm "Update devfile schema based on devfile/api@${lastCommit}" - git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web" + git push "https://devfile-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web"