Skip to content

Commit

Permalink
fix: FOAS Prod GH Action creates wrong issue (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaangiolillo authored Jul 31, 2024
1 parent ee7f25c commit 5be2d23
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/optional-spec-validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
github-token: ${{ secrets.api_bot_pat }}
run-id: ${{ github.run_id }}
- name: Validate the FOAS can be used to generate Postman collection
id: spectral-validation
env:
SPECTRAL_VERSION: ${{ inputs.spectral_version }}
run: |
Expand All @@ -41,7 +42,7 @@ jobs:
npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint ./tmp/collection.json --ruleset=./validation/spectral.yaml
popd
- name: Create Issue
if: ${{ failure() }}
if: ${{ failure() && steps.spectral-validation.outcome == 'failure' }}
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
env:
target_env: ${{ inputs.env }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release-spec-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ jobs:
working-directory: tools/cli
run: make build
- name: Run foascli split command
id: split
run: |
./tools/cli/bin/foascli split -s openapi-foas.json --env prod -o ./openapi/v2/openapi.json
cp -rf "openapi-foas.json" "./openapi/v2.json"
./tools/cli/bin/foascli split -s openapi-foas.yaml --env prod -o ./openapi/v2/openapi.yaml
cp -rf "openapi-foas.yaml" "./openapi/v2.yaml"
- name: Create Issue
if: ${{ failure() }}
if: ${{ failure() && steps.split.outcome == 'failure' }}
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
with:
labels: failed-release
Expand All @@ -82,6 +83,7 @@ jobs:

- name: Create Pull Request
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c
id: create-pr
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "release: (prod) Release OpenAPI Spec :rocket:"
Expand All @@ -94,7 +96,7 @@ jobs:
Automatic Release for MongoDB Atlas OpenAPI Specification.
PR contains autogenerated changes of the OpenAPI specification based on the latest services deployed in production.
- name: Create Issue
if: ${{ failure() }}
if: ${{ failure() && steps.create-pr.outcome == 'failure' }}
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
with:
labels: failed-release
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-spec-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
aws_s3_bucket: ${{ vars.S3_BUCKET_DEV}}
env: dev
spectral_version: ${{ vars.SPECTRAL_VERSION }}
foascli_version: ${{ vars.FOASCLI_VERSION }}
release-spec-qa:
name: Release OpenAPI Spec for QA
uses: ./.github/workflows/release-spec.yml
Expand All @@ -33,6 +34,7 @@ jobs:
aws_s3_bucket: ${{ vars.S3_BUCKET_QA}}
env: qa
spectral_version: ${{ vars.SPECTRAL_VERSION }}
foascli_version: ${{ vars.FOASCLI_VERSION }}
release-spec-staging:
name: Release OpenAPI Spec for STAGING
uses: ./.github/workflows/release-spec.yml
Expand All @@ -45,3 +47,4 @@ jobs:
aws_s3_bucket: ${{ vars.S3_BUCKET_STAGING}}
env: staging
spectral_version: ${{ vars.SPECTRAL_VERSION }}
foascli_version: ${{ vars.FOASCLI_VERSION }}
14 changes: 11 additions & 3 deletions .github/workflows/release-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
description: 'Version of Spectral to use.'
required: true
type: string
foascli_version:
description: 'Version of FOASCLI to use.'
required: true
type: string
secrets: # all secrets are passed explicitly in this workflow
api_bot_pat:
required: true
Expand Down Expand Up @@ -81,13 +85,16 @@ jobs:
github-token: ${{ secrets.api_bot_pat }}
run-id: ${{ github.run_id }}
- name: Install FOASCLI
env:
foascli_version: ${{ inputs.foascli_version }}
run: |
wget https://github.com/mongodb/openapi/releases/download/v0.0.8/mongodb-foas-cli_0.0.8_linux_x86_64.tar.gz -O foascli.tar.gz
wget https://github.com/mongodb/openapi/releases/download/v"${foascli_version}"/mongodb-foas-cli_"${foascli_version}"_linux_x86_64.tar.gz -O foascli.tar.gz
tar -xzvf foascli.tar.gz
pushd mongodb-foas-cli_*
echo "$(pwd)/bin" >> "${GITHUB_PATH}"
popd
- name: Run foascli split command
id: split
env:
target_env: ${{ inputs.env }}
run: |
Expand All @@ -97,7 +104,7 @@ jobs:
foascli split -s openapi-foas.yaml --env "${target_env}" -o ./openapi/v2/openapi.yaml
cp -rf "openapi-foas.yaml" "./openapi/v2.yaml"
- name: Create Issue
if: ${{ failure() }}
if: ${{ failure() && steps.split.outcome == 'failure' }}
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
env:
target_env: ${{ inputs.env }}
Expand All @@ -107,6 +114,7 @@ jobs:
body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changes
id: commit
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842
env:
target_env: ${{ inputs.env }}
Expand All @@ -116,7 +124,7 @@ jobs:
branch: ${{env.target_env}}
file_pattern: "openapi/*"
- name: Create Issue
if: ${{ failure() }}
if: ${{ failure() && steps.commit.outcome == 'failure' }}
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
env:
target_env: ${{ inputs.env }}
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/required-spec-validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ jobs:
name: openapi-foas-${{ inputs.env }}
github-token: ${{ secrets.api_bot_pat }}
run-id: ${{ github.run_id }}
- name: Run Spectral
- name: Run
id: spectral-validation
env:
SPECTRAL_VERSION: ${{ inputs.spectral_version }}
run: npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint openapi-foas.yaml --ruleset=.spectral.yaml # we will update this to lint the FOAS in CLOUDP-263186
- name: Create Issue
if: ${{ failure() }}
if: ${{ failure() && steps.spectral-validation.outcome == 'failure' }}
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
env:
target_env: ${{ inputs.env }}
Expand All @@ -62,13 +63,14 @@ jobs:
github-token: ${{ secrets.api_bot_pat }}
run-id: ${{ github.run_id }}
- name: Validate the FOAS can be used with the Go SDK
id: go-sdk-validation
run: |
cp -rf "openapi-foas.yaml" "atlas-sdk-go/openapi/atlas-sdk.yaml"
pushd atlas-sdk-go
make -e openapi-pipeline
popd
- name: Create Issue
if: ${{ failure() }}
if: ${{ failure() && steps.go-sdk-validation.outcome == 'failure' }}
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
env:
target_env: ${{ inputs.env }}
Expand Down

0 comments on commit 5be2d23

Please sign in to comment.