Support generation migration for generated columns (#424) #537
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and Release | |
# limit CI to run one workflow per branch at a time to prevent any race conditions | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
pull_request: | |
types: [opened, synchronize] | |
env: | |
PG_URL: postgres://postgres:password@localhost:5432/orchid-orm | |
PG_GENERATE_URL: postgres://postgres:password@localhost:5432/orchid-orm-generate | |
MYSQL_URL: mysql://root:password@localhost:3306/mysql | |
PNPM_CACHE_FOLDER: .pnpm-store | |
jobs: | |
test-and-release: | |
runs-on: ubuntu-latest | |
outputs: | |
coverage: ${{ steps.coverage.outputs.COVERAGE }} | |
services: | |
postgres: | |
image: postgis/postgis:16-3.4 | |
env: | |
POSTGRES_PASSWORD: password | |
ports: | |
- 5432:5432 | |
mysql: | |
image: mysql:latest | |
env: | |
MYSQL_ROOT_PASSWORD: password | |
options: >- | |
--health-cmd="mysqladmin ping" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
ports: | |
- 3306:3306 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
# fetch all history to get the tags needed for `changeset tag` command when publishing | |
fetch-depth: 0 | |
- name: Cache turbo build setup | |
uses: actions/cache@v3 | |
with: | |
path: .turbo | |
key: ${{ runner.os }}-turbo-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-turbo- | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
# Install bun to run the bun-specific test in pqb | |
- name: Use Bun | |
uses: oven-sh/setup-bun@v1 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 9.5.0 | |
- name: Setup pnpm config | |
run: pnpm config set store-dir $PNPM_CACHE_FOLDER | |
- name: Install dependencies | |
run: pnpm install | |
- name: Create database | |
working-directory: packages/rake-db | |
run: pnpm db create | |
- name: Run migrations | |
working-directory: packages/rake-db | |
run: pnpm db migrate | |
- name: Run tests | |
run: pnpm test:ci | |
# This step will run changeset version, setting the step output to if there were changesets found | |
- name: Version command | |
if: github.ref == 'refs/heads/main' | |
id: version | |
run: | | |
echo ::set-output name=changes::$(pnpm changeset version 2>&1 | grep -q 'No unreleased changesets found' && echo 'false' || echo 'true') | |
# Push the updated package.json, and CHANGESET.md files | |
# the || echo 'No changes' is to ignore errors from git when trying to commit and there are no changes | |
- name: Push changes | |
if: ${{ github.ref == 'refs/heads/main' && steps.version.outputs.changes == 'true' }} | |
run: | | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
git add -A | |
git commit -m "Version packages" || echo "No changes to commit" | |
git push | |
- name: Creating .npmrc | |
if: github.ref == 'refs/heads/main' | |
run: | | |
cat << EOF > "$HOME/.npmrc" | |
//registry.npmjs.org/:_authToken=$NPM_TOKEN | |
EOF | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Release | |
if: github.ref == 'refs/heads/main' | |
uses: changesets/action@v1 | |
with: | |
publish: pnpm publish:ci | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Get total coverage | |
id: coverage | |
if: github.ref == 'refs/heads/main' | |
run: echo "COVERAGE=$(./node_modules/.bin/ts-node scripts/getTestCoverageTotal.ts)" >> $GITHUB_OUTPUT | |
badge: | |
name: Generate badge image with test coverage value | |
needs: test-and-release | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: badges | |
- name: Generate the badge SVG image | |
uses: emibcn/badge-action@v1 | |
id: badge | |
with: | |
label: 'test coverage' | |
status: ${{ needs.test-and-release.outputs.COVERAGE }} | |
color: 'green' | |
path: coverage-badge.svg | |
- name: Upload badge as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: badge | |
path: coverage-badge.svg | |
overwrite: true | |
- name: Commit badge | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add coverage-badge.svg | |
# Will give error if badge did not changed | |
git commit -m "Update coverage badge" || true | |
- name: Push badge commit | |
uses: ad-m/github-push-action@master | |
if: success() | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: badges |