feat(codegen): commit generated client types to codebase (#3492)
## What Commit generated client types to codebase. ## Why As a developer, we will provides better visibility on the impact of OAS changes to the generated type. Also allow for browser the types on GitHub. ## How * Remove `/lib` from .gitignore * Add a non-blocking github action check validating if the latest generated build has been committed. * Runs `yarn build --force --no-cache` on GitHub. Caching was creating false positives. * Use `git status` and filter the output to target only `packages/generated` directory. ## Test Proof of a failing check: https://github.com/medusajs/medusa/actions/runs/4432323763/jobs/7776235128 UPDATE: Failing check after updating branch with latest develop https://github.com/medusajs/medusa/actions/runs/4436707954/jobs/7785472045
This commit is contained in:
30
scripts/assert-codegen-build-committed-actions.sh
Executable file
30
scripts/assert-codegen-build-committed-actions.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Stackoverflow: How do I programmatically determine if there are uncommitted changes?
|
||||
# https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommitted-changes
|
||||
|
||||
IS_CI="${CI:-false}"
|
||||
|
||||
if [ "$IS_CI" = true ]; then
|
||||
git config --local url."https://github.com/".insteadOf git@github.com:
|
||||
git config --local user.name "Medusajs Bot"
|
||||
git config --local user.email "core@medusa-commerce.com"
|
||||
fi
|
||||
|
||||
FILE_CHANGES=$(git status --porcelain=v1 | grep 'packages/generated')
|
||||
FILE_CHANGES_COUNT=$(git status --porcelain=v1 | grep 'packages/generated' | wc -l)
|
||||
|
||||
if [ "$IS_CI" = true ]; then
|
||||
git config --local --unset user.name
|
||||
git config --local --unset user.email
|
||||
git config --local --unset url."https://github.com/".insteadOf
|
||||
fi
|
||||
|
||||
if [ "$FILE_CHANGES_COUNT" -ne 0 ]; then
|
||||
echo "$FILE_CHANGES"
|
||||
echo "Latest codegen build was not committed. Run 'yarn build' and commit generated files."
|
||||
exit 1
|
||||
else
|
||||
echo "All has been committed."
|
||||
exit 0
|
||||
fi
|
||||
Reference in New Issue
Block a user