diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..94f15dc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,31 @@ +name: Build + +on: + pull_request: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.2 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run build + run: pnpm build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 6843b2d..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: CI - -on: - pull_request: - push: - branches: - - main - -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.12.2 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 22 - cache: pnpm - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Run lint - run: pnpm lint - - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.12.2 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 22 - cache: pnpm - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Run build - run: pnpm build - - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.12.2 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 22 - cache: pnpm - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Run tests - run: pnpm test diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..7d5e3ed --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +name: Lint + +on: + pull_request: + push: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.2 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run lint + run: pnpm lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ffd95d8 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,73 @@ +name: Test + +on: + pull_request: + push: + branches: + - main + paths-ignore: + - docs/badges/test-count.json + +jobs: + test: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.2 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run tests with JSON report + run: pnpm exec vitest run --reporter=json --outputFile=tmp/vitest-report.json + + - name: Generate test count badge payload + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + run: | + mkdir -p docs/badges + node <<'EOF' + const fs = require('node:fs') + const report = JSON.parse(fs.readFileSync('tmp/vitest-report.json', 'utf8')) + const passed = report.numPassedTests ?? 0 + const failed = report.numFailedTests ?? 0 + const skipped = report.numPendingTests ?? 0 + const suffix = skipped > 0 ? `, ${skipped} skipped` : '' + const message = failed > 0 + ? `${passed} passing, ${failed} failed${suffix}` + : `${passed} passing${suffix}` + const color = failed > 0 ? 'red' : passed >= 50 ? 'brightgreen' : 'green' + const badge = { + schemaVersion: 1, + label: 'tests', + message, + color, + } + fs.writeFileSync('docs/badges/test-count.json', `${JSON.stringify(badge, null, 2)}\n`) + EOF + + - name: Commit badge update + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + run: | + if git diff --quiet -- docs/badges/test-count.json; then + exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add docs/badges/test-count.json + git commit -m "chore: update test count badge" + git push diff --git a/README.md b/README.md index 3878228..c256d94 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # Ontic +![Lint](https://github.com/jdleo/ontic/actions/workflows/lint.yml/badge.svg) +![Build](https://github.com/jdleo/ontic/actions/workflows/build.yml/badge.svg) +![Test](https://github.com/jdleo/ontic/actions/workflows/test.yml/badge.svg) +![Test Count](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/jdleo/ontic/main/docs/badges/test-count.json) ![React](https://img.shields.io/badge/React-19-20232a?logo=react) ![TypeScript](https://img.shields.io/badge/TypeScript-5-3178c6?logo=typescript&logoColor=white) ![Vite](https://img.shields.io/badge/Vite-8-646cff?logo=vite&logoColor=white) ![pnpm](https://img.shields.io/badge/pnpm-9-f69220?logo=pnpm&logoColor=white) -![Local-first](https://img.shields.io/badge/architecture-local--first-111111) -![Browser-first](https://img.shields.io/badge/runtime-browser--first-111111) Ontic is a browser-first, local-first ontology and simulation tool for modeling a situation, asking questions about it, and mutating world state over time. diff --git a/docs/badges/test-count.json b/docs/badges/test-count.json new file mode 100644 index 0000000..3dbe33f --- /dev/null +++ b/docs/badges/test-count.json @@ -0,0 +1,6 @@ +{ + "schemaVersion": 1, + "label": "tests", + "message": "local run", + "color": "lightgrey" +} diff --git a/docs/readme-screenshot.png b/docs/readme-screenshot.png new file mode 100644 index 0000000..bd12e00 Binary files /dev/null and b/docs/readme-screenshot.png differ