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

feat: changesets and integration tests #13

Merged
merged 7 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
17 changes: 17 additions & 0 deletions .changeset/fuzzy-items-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@uberschrift/vite-chakra-ui-example": minor
"@uberschrift/vite-mui-example": minor
"@uberschrift/vite-example": minor
"@uberschrift/eslint-config": minor
"vue-vite-example": minor
"uberschrift": minor
"vueberschrift": minor
"@uberschrift/docs": minor
"nextjs-example": minor
"@uberschrift/tsconfig": minor
---

Substantial eco system changes:

- add vueberschrift package for Vue.js
- Make use of changesets
26 changes: 17 additions & 9 deletions .github/workflows/release.yml → .github/workflows/changeset.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
name: "🚀 Release to npm"
name: 🐕 changeset

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
publish:
release:
name: changesets-pr
runs-on: ubuntu-latest
steps:
- name: 🧺 checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: 🐱 use .nvmrc
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: 📌 npm install
run: npm ci --prefer-offline --no-audit
- name: 🕵️ npm test
run: npm test
- name: 🚀 release
- name: 😘 npm run build
run: npm run build
- name: ✨ create release PR
uses: changesets/action@v1
with:
commit: "chore: 🚀 release"
title: "chore: 🚀 release"
publish: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd packages/react
npm run build
npx semantic-release
24 changes: 24 additions & 0 deletions .github/workflows/integration_test_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "🔬 PR: integration test"

on:
push:
branches:
- main

concurrency:
group: integration_test_main.tests@${{ github.ref }}
cancel-in-progress: true

jobs:
integration-test:
runs-on: ubuntu-latest
steps:
- name: 🧺 checkout
uses: actions/checkout@v4
- name: 🐱 use .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: 🧲 run integration test script
run: ./integration-test/run.sh
30 changes: 30 additions & 0 deletions .github/workflows/integration_test_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "🔬 PR: integration test"

on:
pull_request:
types: [labeled, ready_for_review, opened, synchronize, reopened]

concurrency:
group: integration_test_pr.tests@${{ github.ref }}
cancel-in-progress: true

jobs:
no-draft:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- run: echo "🗞"

integration-test:
runs-on: ubuntu-latest
needs: [no-draft]
steps:
- name: 🧺 checkout
uses: actions/checkout@v4
- name: 🐱 use .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: 🧲 run integration test script
run: ./integration-test/run.sh local
37 changes: 37 additions & 0 deletions integration-test/integration.test.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Hx, HxBoundary, useHx } from "uberschrift";
import {
Hx as HxVue,
HxBoundary as HxBoundaryVue,
useHx as useHxVue,
} from "vueberschrift";
import { expect, test } from "vitest";

test("smoke test", () =>
expect({
Hx,
HxVue,
HxBoundary,
HxBoundaryVue,
useHx,
useHxVue,
}).toMatchInlineSnapshot(`
{
"Hx": [Function],
"HxBoundary": [Function],
"HxBoundaryVue": {
"__name": "HxBoundary",
"setup": [Function],
},
"HxVue": {
"__name": "Hx",
"props": {
"increment": {
"default": 0,
},
},
"setup": [Function],
},
"useHx": [Function],
"useHxVue": [Function],
}
`));
43 changes: 43 additions & 0 deletions integration-test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
CWD=$(pwd)

# make a temporary directory
TMP=$(mktemp -d 2>/dev/null || mktemp -d -t 'pprtmp')
TYPE=$1

# clean up
trap '{ rm -rf -- "$TMP"; }' EXIT
# trap '{ echo $TMP; }' EXIT

# copy the boilerplate to the temporary directory
cp -r ./integration-test/integration.test.ts.hbs ${TMP}/integration.test.ts

if [ "$TYPE" = "local" ]; then
cd $CWD/packages/react
npm install
npm run build

cd $CWD/packages/vue
npm install
npm run build

cd $TMP
npm init -y
npm install $CWD/packages/react
npm install $CWD/packages/vue
else
cd ${TMP}
npm init -y
npm install uberschrift vueberschrift
fi

# install dependencies
npm install vitest typescript
npx tsc --init

# run unit tests
npx vitest run
STATUS=$?

cat package.json

exit $STATUS
Loading
Loading