diff --git a/.github/workflows/.spec.pr.yml b/.github/workflows/.spec.pr.yml new file mode 100644 index 00000000..c3b9ac55 --- /dev/null +++ b/.github/workflows/.spec.pr.yml @@ -0,0 +1,84 @@ +name: Spec PR +# This workflow uploads a copy of the spec with the respective changes in the PR +# to the team Space. +# +# The name of the uploaded file will be prefixed with the PR number. +# e.g. `spec-ci/previews/123-spec.yaml + +on: [pull_request] + +jobs: + lint: + name: Validate spec + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run linter + run: make lint + + bundle-spec: + name: Bundle Spec + runs-on: ubuntu-latest + + needs: lint + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + + - name: Bundle + run: make bundle + + - uses: actions/upload-artifact@v2 + with: + name: openapi-bundled + path: tests/openapi-bundled.yaml + + generate-preview: + # As this job needs access to secrets, skip it if the PR comes from a fork. + if: github.event.pull_request.head.repo.full_name == github.repository + name: Generate Preview + runs-on: ubuntu-latest + + needs: bundle-spec + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + + # - name: Bundle + # run: make bundle + + # - uses: actions/upload-artifact@v2 + # with: + # name: openapi-bundled + # path: tests/openapi-bundled.yaml + + # - name: Upload PR spec + # run: >- + # aws s3 cp tests/openapi-bundled.yaml + # ${{ env.SPACES_PATH }}/previews/${{ github.event.number }}-spec.yaml + # --endpoint=${{ env.SPACES_ENDPOINT }} + # --acl public-read + # env: + # AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_ACCESS_SECRET }} + # AWS_DEFAULT_OUTPUT: json + # SPACES_PATH: ${{ secrets.SPACES_PATH }} + # SPACES_ENDPOINT: ${{ secrets.SPACES_ENDPOINT }} + # AWS_EC2_METADATA_DISABLED: true + + # - uses: Sibz/github-status-action@v1 + # with: + # authToken: ${{secrets.GITHUB_TOKEN}} + # context: Spec Preview URL + # description: Ready + # state: success + # sha: ${{ github.event.pull_request.head.sha }} + # target_url: https://api-engineering.nyc3.digitaloceanspaces.com/spec-ci/redoc-index.html?pr=${{ github.event.number }} diff --git a/.github/workflows/spec.main.yml b/.github/workflows/spec.main.yml index 74f11d12..2beacb9f 100644 --- a/.github/workflows/spec.main.yml +++ b/.github/workflows/spec.main.yml @@ -30,43 +30,50 @@ jobs: with: node-version: '14.x' - - name: Bundle - run: make bundle + # - name: Bundle + # run: make bundle - - uses: actions/upload-artifact@v2 - with: - name: openapi-bundled - path: tests/openapi-bundled.yaml + # - uses: actions/upload-artifact@v2 + # with: + # name: openapi-bundled + # path: tests/openapi-bundled.yaml - name: Set outputs id: vars run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Check outputs run: echo ${{ steps.vars.outputs.sha_short }} - - name: Upload Main spec - run: >- - aws s3 cp tests/openapi-bundled.yaml - ${{ env.SPACES_PATH }}/DigitalOcean-public.v2.yaml - --endpoint=${{ env.SPACES_ENDPOINT }} - --acl public-read - env: - AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_ACCESS_SECRET }} - AWS_DEFAULT_OUTPUT: json - SPACES_PATH: ${{ secrets.SPACES_PATH }} - SPACES_ENDPOINT: ${{ secrets.SPACES_ENDPOINT }} - AWS_EC2_METADATA_DISABLED: true - - name: Upload revision spec - # this uploads a duplicate of the bundled spec with the short sha - # appended to the file name for reference during client generation. - run: >- - aws s3 cp tests/openapi-bundled.yaml - ${{ secrets.SPACES_PATH }}/DigitalOcean-public-${{ steps.vars.outputs.sha_short }}.v2.yaml - --endpoint=${{ secrets.SPACES_ENDPOINT }} - --acl public-read + - name: Print Title of PR + id: title_var + run: echo "PR_TITLE=$(gh pr list --search "${{ steps.vars.outputs.sha_short }}" --json title --jq '.[0].title')" >> "$GITHUB_OUTPUT" env: - AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_ACCESS_SECRET }} - AWS_DEFAULT_OUTPUT: json - SPACES_PATH: ${{ secrets.SPACES_PATH }} - SPACES_ENDPOINT: ${{ secrets.SPACES_ENDPOINT }} - AWS_EC2_METADATA_DISABLED: true + GITHUB_TOKEN: ${{ secrets.WORKFLOW_TRIGGER_TOKEN }} + - name: Check PR TITLE outputs + run: echo ${{ steps.title_var.outputs.PR_TITLE }} + # - name: Upload Main spec + # run: >- + # aws s3 cp tests/openapi-bundled.yaml + # ${{ env.SPACES_PATH }}/DigitalOcean-public.v2.yaml + # --endpoint=${{ env.SPACES_ENDPOINT }} + # --acl public-read + # env: + # AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_ACCESS_SECRET }} + # AWS_DEFAULT_OUTPUT: json + # SPACES_PATH: ${{ secrets.SPACES_PATH }} + # SPACES_ENDPOINT: ${{ secrets.SPACES_ENDPOINT }} + # AWS_EC2_METADATA_DISABLED: true + # - name: Upload revision spec + # # this uploads a duplicate of the bundled spec with the short sha + # # appended to the file name for reference during client generation. + # run: >- + # aws s3 cp tests/openapi-bundled.yaml + # ${{ secrets.SPACES_PATH }}/DigitalOcean-public-${{ steps.vars.outputs.sha_short }}.v2.yaml + # --endpoint=${{ secrets.SPACES_ENDPOINT }} + # --acl public-read + # env: + # AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_ACCESS_SECRET }} + # AWS_DEFAULT_OUTPUT: json + # SPACES_PATH: ${{ secrets.SPACES_PATH }} + # SPACES_ENDPOINT: ${{ secrets.SPACES_ENDPOINT }} + # AWS_EC2_METADATA_DISABLED: true diff --git a/.github/workflows/spec.pr-comment-trigger.yml b/.github/workflows/spec.pr-comment-trigger.yml index 05f15405..f41d8d4a 100644 --- a/.github/workflows/spec.pr-comment-trigger.yml +++ b/.github/workflows/spec.pr-comment-trigger.yml @@ -66,41 +66,41 @@ jobs: repository: ${{ fromJSON(steps.get-pr-branch.outputs.result).repo.full_name }} ref: ${{ github.event.review.commit_id }} - - name: Bundle - if: steps.is-digitalocean-member.outputs.result == 'true' - run: make bundle + # - name: Bundle + # if: steps.is-digitalocean-member.outputs.result == 'true' + # run: make bundle - - uses: actions/upload-artifact@v2 - if: steps.is-digitalocean-member.outputs.result == 'true' - with: - name: openapi-bundled - path: tests/openapi-bundled.yaml + # - uses: actions/upload-artifact@v2 + # if: steps.is-digitalocean-member.outputs.result == 'true' + # with: + # name: openapi-bundled + # path: tests/openapi-bundled.yaml - - name: Upload PR spec - if: steps.is-digitalocean-member.outputs.result == 'true' - run: >- - aws s3 cp tests/openapi-bundled.yaml - ${{ env.SPACES_PATH }}/previews/${{ github.event.issue.number }}-spec.yaml - --endpoint=${{ env.SPACES_ENDPOINT }} - --acl public-read - env: - AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_ACCESS_SECRET }} - AWS_DEFAULT_OUTPUT: json - SPACES_PATH: ${{ secrets.SPACES_PATH }} - SPACES_ENDPOINT: ${{ secrets.SPACES_ENDPOINT }} - AWS_EC2_METADATA_DISABLED: true + # - name: Upload PR spec + # if: steps.is-digitalocean-member.outputs.result == 'true' + # run: >- + # aws s3 cp tests/openapi-bundled.yaml + # ${{ env.SPACES_PATH }}/previews/${{ github.event.issue.number }}-spec.yaml + # --endpoint=${{ env.SPACES_ENDPOINT }} + # --acl public-read + # env: + # AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_ACCESS_SECRET }} + # AWS_DEFAULT_OUTPUT: json + # SPACES_PATH: ${{ secrets.SPACES_PATH }} + # SPACES_ENDPOINT: ${{ secrets.SPACES_ENDPOINT }} + # AWS_EC2_METADATA_DISABLED: true - - name: Comment on PR - if: steps.is-digitalocean-member.outputs.result == 'true' && success() - uses: actions/github-script@v3 - with: - script: | - var previewComment = '🔎 API documentation preview: https://api-engineering.nyc3.digitaloceanspaces.com/spec-ci/redoc-index.html?pr=' + '${{ github.event.pull_request.number }}'; - var repository = '${{ github.repository }}' - github.issues.createComment({ - issue_number: '${{ github.event.pull_request.number }}', - owner: repository.split('/')[0], - repo: repository.split('/')[1], - body: previewComment - }); + # - name: Comment on PR + # if: steps.is-digitalocean-member.outputs.result == 'true' && success() + # uses: actions/github-script@v3 + # with: + # script: | + # var previewComment = '🔎 API documentation preview: https://api-engineering.nyc3.digitaloceanspaces.com/spec-ci/redoc-index.html?pr=' + '${{ github.event.pull_request.number }}'; + # var repository = '${{ github.repository }}' + # github.issues.createComment({ + # issue_number: '${{ github.event.pull_request.number }}', + # owner: repository.split('/')[0], + # repo: repository.split('/')[1], + # body: previewComment + # }); diff --git a/.github/workflows/spec.pr.yml b/.github/workflows/spec.pr.yml deleted file mode 100644 index 475ef895..00000000 --- a/.github/workflows/spec.pr.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Spec PR -# This workflow uploads a copy of the spec with the respective changes in the PR -# to the team Space. -# -# The name of the uploaded file will be prefixed with the PR number. -# e.g. `spec-ci/previews/123-spec.yaml - -on: [pull_request] - -jobs: - lint: - name: Validate spec - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Run linter - run: make lint - - bundle-spec: - name: Bundle Spec - runs-on: ubuntu-latest - - needs: lint - - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - - name: Bundle - run: make bundle - - - uses: actions/upload-artifact@v2 - with: - name: openapi-bundled - path: tests/openapi-bundled.yaml - - generate-preview: - # As this job needs access to secrets, skip it if the PR comes from a fork. - if: github.event.pull_request.head.repo.full_name == github.repository - name: Generate Preview - runs-on: ubuntu-latest - - needs: bundle-spec - - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - - name: Bundle - run: make bundle - - - uses: actions/upload-artifact@v2 - with: - name: openapi-bundled - path: tests/openapi-bundled.yaml - - - name: Upload PR spec - run: >- - aws s3 cp tests/openapi-bundled.yaml - ${{ env.SPACES_PATH }}/previews/${{ github.event.number }}-spec.yaml - --endpoint=${{ env.SPACES_ENDPOINT }} - --acl public-read - env: - AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_ACCESS_SECRET }} - AWS_DEFAULT_OUTPUT: json - SPACES_PATH: ${{ secrets.SPACES_PATH }} - SPACES_ENDPOINT: ${{ secrets.SPACES_ENDPOINT }} - AWS_EC2_METADATA_DISABLED: true - - - uses: Sibz/github-status-action@v1 - with: - authToken: ${{secrets.GITHUB_TOKEN}} - context: Spec Preview URL - description: Ready - state: success - sha: ${{ github.event.pull_request.head.sha }} - target_url: https://api-engineering.nyc3.digitaloceanspaces.com/spec-ci/redoc-index.html?pr=${{ github.event.number }} diff --git a/.github/workflows/trigger-python-client-gen.yml b/.github/workflows/trigger-python-client-gen.yml index 5afeb001..05efa3f9 100644 --- a/.github/workflows/trigger-python-client-gen.yml +++ b/.github/workflows/trigger-python-client-gen.yml @@ -16,9 +16,15 @@ jobs: - name: Set outputs id: vars run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - name: Check outputs + - name: Print Title of PR + run: gh pr list --search "${{ steps.vars.outputs.sha_short }}" --json title --jq '.[0].title' + env: + GITHUB_TOKEN: ${{ secrets.WORKFLOW_TRIGGER_TOKEN }} + - name: Check short sha outputs run: echo ${{ steps.vars.outputs.sha_short }} + - name: Check pr title outputs + run: echo $TITLE - name: trigger-workflow - run: gh workflow run --repo digitalocean/pydo python-client-gen.yml --ref main -f openapi_short_sha=${{ steps.vars.outputs.sha_short }} + run: gh workflow run --repo danaelhe/pydo python-client-gen.yml --ref main -f openapi_short_sha=${{ steps.vars.outputs.sha_short }} pr_title=$TITLE env: GITHUB_TOKEN: ${{ secrets.WORKFLOW_TRIGGER_TOKEN }} diff --git a/.github/workflows/validate-client-generation.yml b/.github/workflows/validate-client-generation.yml index 6ed1b6d3..82718b8a 100644 --- a/.github/workflows/validate-client-generation.yml +++ b/.github/workflows/validate-client-generation.yml @@ -46,36 +46,36 @@ jobs: virtualenvs-in-project: true installer-parallel: false - - name: Download PR spec - run: | - gh run download ${{ github.event.workflow_run.id }} -n openapi-bundled - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Download PR spec + # run: | + # gh run download ${{ github.event.workflow_run.id }} -n openapi-bundled + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Test Python client generation - id: test-client - working-directory: pydo - run: | - SPEC_FILE=../openapi-bundled.yaml make generate - make test-mocked + # - name: Test Python client generation + # id: test-client + # working-directory: pydo + # run: | + # SPEC_FILE=../openapi-bundled.yaml make generate + # make test-mocked - - name: Results - if: always() - run: | - if [[ ${{ steps.test-client.outcome }} == 'success' ]]; then - echo "test_result=success" >> $GITHUB_ENV - echo "check_description=Successfully validated generated client" >> $GITHUB_ENV - else - echo "test_result=failure" >> $GITHUB_ENV - echo "check_description=Failed to validate generated client" >> $GITHUB_ENV - fi + # - name: Results + # if: always() + # run: | + # if [[ ${{ steps.test-client.outcome }} == 'success' ]]; then + # echo "test_result=success" >> $GITHUB_ENV + # echo "check_description=Successfully validated generated client" >> $GITHUB_ENV + # else + # echo "test_result=failure" >> $GITHUB_ENV + # echo "check_description=Failed to validate generated client" >> $GITHUB_ENV + # fi - - name: Update check on PR - if: always() - run: | - gh api --method POST -H "Accept: application/vnd.github+json" \ - /repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha }} \ - -f state='${{ env.test_result }}' \ - -f target_url='${{ env.target_url }}' \ - -f description='${{ env.check_description }}' \ - -f context='${{ github.workflow }}' + # - name: Update check on PR + # if: always() + # run: | + # gh api --method POST -H "Accept: application/vnd.github+json" \ + # /repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha }} \ + # -f state='${{ env.test_result }}' \ + # -f target_url='${{ env.target_url }}' \ + # -f description='${{ env.check_description }}' \ + # -f context='${{ github.workflow }}' diff --git a/specification/DigitalOcean-public.v2.yaml b/specification/DigitalOcean-public.v2.yaml index 7bcc2bfe..28fa1370 100644 --- a/specification/DigitalOcean-public.v2.yaml +++ b/specification/DigitalOcean-public.v2.yaml @@ -530,9 +530,9 @@ tags: resources assigned to them. paths: - /v2/1-clicks: - get: - $ref: 'resources/1-clicks/oneClicks_list.yml' + # /v2/1-clicks: + # get: + # $ref: 'resources/1-clicks/oneClicks_list.yml' /v2/1-clicks/kubernetes: post: