Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload api swagger-ui on release #6088

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

andres-spacemesh
Copy link
Contributor

Motivation

Automate the process of building and deploying the spacemeshos/api Swagger UI with each go-spacemesh release, ensuring consistent and up-to-date documentation.

Description

This PR introduces a new GitHub Action that automates the build and upload process of Swagger UI. It leverages the Swagger spec from the spacemeshos/api version in the current release of this repository.

Test Plan

Tested locally

Copy link

codecov bot commented Jun 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.5%. Comparing base (b40070a) to head (149f6d2).

Additional details and impacted files
@@            Coverage Diff            @@
##           develop   #6088     +/-   ##
=========================================
- Coverage     81.6%   81.5%   -0.1%     
=========================================
  Files          301     301             
  Lines        32257   32257             
=========================================
- Hits         26328   26314     -14     
- Misses        4211    4222     +11     
- Partials      1718    1721      +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- name: Extract dependency version
id: go-sm-api-version
run: |
version=$(grep -E 'github.com/spacemeshos/api/release/go' go.mod | awk '{print $2}')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A dependency can appear multiple times in the go.mod file (e.g. when using replacements) a safer command to get the version of a dependency that is used to build the binary would be:

Suggested change
version=$(grep -E 'github.com/spacemeshos/api/release/go' go.mod | awk '{print $2}')
version=$(go list -m 'github.com/spacemeshos/api/release/go' | awk '{print $2}')

uses: actions/checkout@v4
with:
fetch-depth: 0
ref: 'refs/tags/${{ github.event.release.tag_name }}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be specified? Won't the event be triggered on the reference of the tag anyway?

Comment on lines +57 to +63
env:
AWS_S3_BUCKET: ${{ secrets.CLOUDFLARE_API_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_SECRET_ACCESS_KEY }}
SOURCE_DIR: api/release/openapi/swagger/dist
DEST_DIR: ''
AWS_S3_ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am reading this as a new build overwrites an existing one? We also publish test builds that are not intended to be used on mainnet and it would be bad if those overwrote the existing swagger file.

Would it be possible to upload the swagger file to a path that is different on a per git reference / tag basis?

Comment on lines +65 to +75
- name: upload to testnet
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.CLOUDFLARE_TESTNET_API_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_SECRET_ACCESS_KEY }}
SOURCE_DIR: api/release/openapi/swagger/dist
DEST_DIR: ''
AWS_S3_ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely don't use the same versions on mainnet and testnet. Can this be changed that new versions don't overwrite the existing api definition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants