Skip to content
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
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ desktop:
# its docs or tests is still listed as a feature.
documentation:
- changed-files:
- any-glob-to-all-files: ["**/*.md", "docs/**", "LICENSE"]
- any-glob-to-all-files: ["**/*.md", "docs/**", "LICENSE", "site/**"]

tests:
- changed-files:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ jobs:
files=$(git diff --name-only --no-renames "$BASE" "$GITHUB_SHA"); then
echo "Changed files:"
echo "$files"
# Markdown, docs/, the licence and the repository's settings in .github/ can't change
# what the end-to-end tests see; this workflow can. The checks job always runs: one of
# its tests checks every file name, docs included.
code=$(grep -vE '\.md$|^docs/|^LICENSE$|^\.github/' <<< "$files" || true)
# Markdown, docs/, the licence, the website (site/, tested by pages.yml) and the
# repository's settings in .github/ can't change what the end-to-end tests see; this
# workflow can. The checks job always runs: it type-checks, lints and unit-tests the
# website too, and one of its tests checks every file name, docs included.
code=$(grep -vE '\.md$|^docs/|^LICENSE$|^\.github/|^site/' <<< "$files" || true)
if [[ -z "$code" ]] && ! grep -qx '.github/workflows/ci.yml' <<< "$files"; then e2e=false; fi
grep -qE '^src-tauri/|^\.github/workflows/ci\.yml$' <<< "$files" || rust=false
fi
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Website

# Builds, tests and publishes the website in site/ to GitHub Pages. Its releases and changelog come
# from the repository's version tags and the commits between them, so it is rebuilt when the site
# changes on main and after every release (release.yml starts it). Pull requests that change the
# site only build and test it. One-time set-up: Settings → Pages → Source: GitHub Actions.
on:
push:
branches: [main]
paths:
- "site/**"
- "public/favicon.svg"
- "public/logo.svg"
- "public/apple-touch-icon.png"
- "docs/screenshots/**"
- "package-lock.json"
- ".github/workflows/pages.yml"
pull_request:
paths:
- "site/**"
- "public/favicon.svg"
- "public/logo.svg"
- "public/apple-touch-icon.png"
- "docs/screenshots/**"
- "package-lock.json"
- ".github/workflows/pages.yml"
workflow_dispatch:

permissions:
contents: read

concurrency:
# A newer build replaces one still running, but a publish already under way finishes.
group: pages-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build:
name: Build and test the website
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Every tag and the commits between them: they are the releases and their changes.
fetch-depth: 0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- name: Install Playwright's browser
run: npx playwright install --with-deps --only-shell chromium
- name: Test the website (axe, layout from phone to 4K, downloads, changelog)
run: npm run site:test
- name: Upload screenshots of failed tests
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: site-test-failures
path: test-results/
retention-days: 7
- run: npm run site:build
- name: Package the website for Pages
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: site/dist

publish:
name: Publish to GitHub Pages
needs: build
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- id: deploy
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
4 changes: 3 additions & 1 deletion .github/workflows/release-on-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ jobs:
needs: check
if: needs.check.outputs.release == 'true'
permissions:
# Creating the tag and the release (only release.yml's publish job uses it).
# Creating the tag and the release, then starting the Website workflow (only release.yml's
# publish job uses them).
contents: write
actions: write
uses: ./.github/workflows/release.yml
with:
tag: ${{ needs.check.outputs.tag }}
10 changes: 10 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
# Starting the Website workflow (pages.yml) once the release is out.
actions: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
Expand Down Expand Up @@ -205,3 +207,11 @@ jobs:
fi
gh release create "$TAG" release/* --repo "$GITHUB_REPOSITORY" "${flags[@]}"
gh release edit "$TAG" --draft=false --repo "$GITHUB_REPOSITORY" || refused
- name: Update the website
# The website lists the releases and links their files, so it's built again with this one.
# Its failing leaves the release as it is.
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow run pages.yml --ref main --repo "$GITHUB_REPOSITORY" ||
echo "::warning::The website wasn't rebuilt. Run the Website workflow by hand to list this release."
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Dependencies and build output (Rust build output: src-tauri/.gitignore)
node_modules
/dist/
# The website's build, and the build its tests use
/site/dist/
/site/dist-test/
*.tsbuildinfo

# Tests and coverage
Expand Down
24 changes: 23 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ npm run e2e # Playwright: builds, previews on :4173, runs desktop/
E2E_PORT=4801 npm run e2e # the same on another port (several runs on one machine)
npm run check # typecheck + lint + test + build
npm run version:set -- 1.2.0 # set the version in all six places (--check 1.2.0, --print)
npm run site:dev # the website (site/) on http://127.0.0.1:5174
npm run site:build # the website -> site/dist/ (site:preview serves it on :4174)
npm run site:test # the website's Playwright tests (builds it first)

# Rust (inside src-tauri/). The crate embeds dist/, so build the web app first or create a
# placeholder: mkdir -p dist && echo '<!doctype html><title>ci</title>' > dist/index.html
Expand All @@ -70,14 +73,16 @@ cargo clippy --all-targets -- -D warnings
cargo test
```

Ports are fixed (`strictPort`): 5173 dev, 4173 preview/e2e, 43821 desktop sign-in listener.
Ports are fixed (`strictPort`): 5173 dev, 4173 preview/e2e, 43821 desktop sign-in listener,
5174 and 4174 the website's dev server and preview.

## Repository map

```
app/ the React app (web and desktop UI)
src-tauri/ the desktop shell (Rust, Tauri 2)
e2e/ Playwright specs and their fakes
site/ the website on GitHub Pages: downloads, changelog, set-up guide, troubleshooting, FAQ
scripts/ test set-up, repository-wide checks, the version script
docs/ user guide, development, database and release docs, README screenshots
public/ static files served as-is (icons, web manifest, logo)
Expand Down Expand Up @@ -133,6 +138,17 @@ Tests sit next to the code they test (`*.test.ts` / `*.test.tsx`).
differ only by case (they would clash on Windows and macOS). `scripts/set-version.mjs`: sets or
checks the version in `package.json`, `package-lock.json`, `tauri.conf.json`, `Cargo.toml` and
`Cargo.lock` (`npm run version:set`).
- `site/`: the project's website, published by `pages.yml` at https://kkkermit.github.io/Statsify/.
Plain TypeScript and CSS built by its own Vite config (`site/vite.config.ts`, with a `<meta>`
CSP), no framework and no network calls. Its releases come from git while it builds: each
`v*` tag is a release, and the commit subjects since the tag before it (squash-merged pull
request titles) are its changes, bundled into the page as `virtual:releases`. Download links
follow the file names `release.yml` gives; keep `downloadsFor` in `releases.ts` in step with
it. `index.html` holds the content; `main.ts` adds the downloads, the changelog, install tabs,
copy buttons, the help search and the menu; `releases.ts` is the pure part, tested in
`releases.test.ts`; `e2e/` has its Playwright tests and the fixture release list they build
with (`SITE_RELEASES`). It uses the app's colours and font and follows the system's light or
dark mode. Keep its text in step with the README and the user guide.
- `docs/GUIDE.md` user guide, `docs/DEVELOPMENT.md` developer set-up and debugging,
`docs/DATABASE.md` the SQLite schema and binary format, `docs/RELEASING.md` the release process,
`docs/screenshots/` README images.
Expand Down Expand Up @@ -848,6 +864,12 @@ label)` (axe WCAG 2.2 A/AA, no serious or critical violations), `enterDemo`, `se
actor); otherwise the release is left as a draft for an admin to publish. Pull requests
that change it or the version script run a dry run, which calls `ci.yml` with `run: build`
(the pull request's own CI run has the checks).
- `pages.yml` (**Website**): builds `site/` from the full git history and tags, runs its tests
(`npm run site:test`: axe in both colour schemes, no sideways scroll from 320 px to 4K, the
downloads per system, the changelog, tabs, search and the menu) and publishes it to GitHub
Pages, on pushes to `main` that change the site and when `release.yml` starts it after a
release; pull requests that change the site run the build and tests only. CI's end-to-end
tests skip changes that only touch `site/`.
- `codeql.yml`: code scanning for TypeScript, Rust and the workflows, on pull requests,
pushes to `main` and weekly.
- `labeler.yml`: labels pull requests by files (`.github/labeler.yml`) and title type; the
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ release notes group changes by those labels; the maintainer may adjust them.
- **Desktop app** (when a pull request changes `src-tauri/`, dependencies or the build): the
installers build on Windows, Linux and macOS, and can be downloaded from the run's page, handy
for testing.
- **Website** (when a pull request changes `site/`): builds the website and runs its tests.
- **CodeQL:** security scanning of the TypeScript, the Rust and the workflows.

All of them must pass before merging. If an end-to-end test fails, that job's `e2e-failures-<n>`
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<img src="docs/screenshots/overview.webp" alt="Overview: now playing, 30-day listening time, plays, top artist, streak, top tracks and recent plays" width="900" />
</p>

**Website:** [kkkermit.github.io/Statsify](https://kkkermit.github.io/Statsify/) has the downloads,
the set-up guide, the changelog and answers to common problems.

Statsify works with your own Spotify account through Spotify's official Web API. You create a free
**Client ID** for it once (about two minutes, [see below](#one-time-spotify-setup-about-2-minutes)),
or click **Explore the demo** to look around with fictional data first.
Expand Down
25 changes: 23 additions & 2 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ Set `VITE_SPOTIFY_CLIENT_ID` at build time to fill in the Client ID for everyone
five accounts, see the [README](../README.md#why-do-i-need-my-own-client-id)); leave it unset and
each person enters their own.

### The website

`site/` is the project's website at https://kkkermit.github.io/Statsify/: downloads, the
changelog, the set-up guide, troubleshooting and the FAQ. It's a separate static page built with
its own Vite config, and the **Website** workflow publishes it to GitHub Pages.

```bash
npm run site:dev # http://127.0.0.1:5174
npm run site:build # builds into site/dist/
npm run site:preview # serves site/dist/ on http://127.0.0.1:4174
npm run site:test # its Playwright tests (they build it first)
```

The downloads and changelog come from the repository's version tags and the pull requests merged
between them, read with git while the site builds. A clone without tags shows links to GitHub
Releases instead: `git fetch --tags` fills them in.

### Ports and settings

The ports are fixed (`strictPort`), because Spotify needs the exact redirect address. If one is
Expand All @@ -144,6 +161,8 @@ taken, stop whatever uses it rather than picking another port.
| ----- | ------------------------------------------ |
| 5173 | `npm run dev` (and `npm run desktop:dev`) |
| 4173 | `npm run preview` and the end-to-end tests |
| 5174 | `npm run site:dev` (the website) |
| 4174 | `npm run site:preview` and its tests |
| 43821 | The desktop app's sign-in listener |

| Variable | What it does |
Expand Down Expand Up @@ -255,6 +274,7 @@ them, and npm and Cargo dependencies, every week (`.github/dependabot.yml`).
| **Desktop app** (`desktop.yml`) | Changes to the app reaching `main`; pull requests that change `src-tauri/`, dependencies or the build | Builds the installers on Windows, Linux and macOS and keeps them as downloadable artifacts for 14 days |
| **Release on main** (`release-on-main.yml`) | Pushes to `main` | Releases the version in `package.json` when it has no tag yet, by running **Release** on that commit |
| **Release** (`release.yml`) | Called by Release on main, version tags (`v1.2.0`); dry runs when the workflow itself changes | Checks the version, runs CI and the desktop builds, and publishes a GitHub Release ([RELEASING.md](RELEASING.md)) |
| **Website** (`pages.yml`) | Website changes on `main` and in pull requests; after each release | Builds and tests `site/` and, from `main`, publishes it to GitHub Pages |
| **CodeQL** (`codeql.yml`) | Pull requests, pushes to `main`, weekly | Security scanning of the TypeScript, the Rust and the workflows |
| **Label pull requests** (`labeler.yml`) | Pull requests | Labels each pull request by its files and its title's type, for the release notes |

Expand All @@ -270,8 +290,9 @@ How **CI** is laid out, and why:
as each other (see [End-to-end tests](#end-to-end-tests-playwright)). Each job runs two
browsers, half of a 4-core runner. A failing job uploads its screenshots as `e2e-failures-<n>`;
the other jobs still run to the end.
- **What changed** decides what a change needs. Changes to Markdown, `docs/` or `.github/` (other
than `ci.yml`) skip the end-to-end tests; changes outside `src-tauri/` skip the Rust checks.
- **What changed** decides what a change needs. Changes to Markdown, `docs/`, the website
(`site/`, which the **Website** workflow tests) or `.github/` (other than `ci.yml`) skip the
end-to-end tests; changes outside `src-tauri/` skip the Rust checks.
Runs by hand and releases run everything.
- The branch rules require **Lint, test & build** and **Desktop shell (Rust)**. **Lint, test &
build** waits for the build, the checks and every end-to-end job, and passes only if each passed
Expand Down
18 changes: 16 additions & 2 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ npm run version:set -- --print # show the current version
- runs all of CI (tests, end-to-end and accessibility checks, Rust checks);
- builds the installers on Windows, Linux and macOS, and the web app;
- publishes a GitHub Release tagged `v1.3.0` on the merged commit, with the files, their
SHA-256 checksums and the generated notes.
SHA-256 checksums and the generated notes;
- starts the [Website workflow](https://github.com/Kkkermit/Statsify/actions/workflows/pages.yml),
so [the website](https://kkkermit.github.io/Statsify/) offers the new version a few minutes
later.

When the tag already exists, the run stops after its first step: merges that don't change the
version release nothing.
Expand Down Expand Up @@ -104,6 +107,17 @@ A published tag still can't be moved or deleted. Only people with write access,
running this repository's own code on `main`, a tag or a feature branch, can create tags;
pull requests from forks get a read-only token.

### One-time set-up: the website

The website is published with GitHub Actions. Once, in **Settings → Pages**, set **Source** to
**GitHub Actions**, or with an admin's `gh`:

```bash
gh api -X POST repos/Kkkermit/Statsify/pages -f build_type=workflow
```

Then run the **Website** workflow from the Actions tab, or merge a change to `site/`.

### What a release contains

| File | For |
Expand Down Expand Up @@ -132,7 +146,7 @@ their own, and the app asks for it on first run.
replaces its files and publishes it.
- **"The repository's rules don't let GitHub Actions" create the tag:** the release is a draft
with every file. Publish it from the Releases page, and do the one-time set-up above so the next
one publishes itself.
one publishes itself. Then run the **Website** workflow by hand, so the website lists it.
- **A published release has a bug:** release a patch version. Never move or reuse a published
tag: people's checksums and links depend on it. The pipeline refuses to change the files of a
published release.
Expand Down
4 changes: 2 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import tseslint from "typescript-eslint";

export default tseslint.config(
// .claude/worktrees: copies of the repo that coding agents work in.
{ ignores: ["dist", "coverage", "src-tauri/target", "src-tauri/gen", "playwright-report", "test-results", ".claude"] },
{ ignores: ["dist", "site/dist", "site/dist-test", "coverage", "src-tauri/target", "src-tauri/gen", "playwright-report", "test-results", ".claude"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx}"],
Expand All @@ -26,7 +26,7 @@ export default tseslint.config(
},
},
{
files: ["e2e/**/*.ts", "*.config.ts"],
files: ["e2e/**/*.ts", "*.config.ts", "site/e2e/**/*.ts", "site/*.config.ts"],
languageOptions: { globals: { ...globals.node } },
},
);
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@
"preview": "vite preview",
"typecheck": "tsc -b",
"lint": "eslint .",
"format": "prettier --write \"app/**/*.{ts,tsx,css}\" \"e2e/**/*.ts\" \"docs/**/*.md\" \"*.md\"",
"format": "prettier --write \"app/**/*.{ts,tsx,css}\" \"site/**/*.{ts,css,html}\" \"e2e/**/*.ts\" \"docs/**/*.md\" \"*.md\"",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"e2e": "playwright test",
"check": "npm run typecheck && npm run lint && npm run test && npm run build",
"version:set": "node scripts/set-version.mjs",
"site:dev": "vite --config site/vite.config.ts",
"site:build": "vite build --config site/vite.config.ts",
"site:preview": "vite preview --config site/vite.config.ts",
"site:test": "playwright test --config site/playwright.config.ts",
"tauri": "tauri",
"desktop:dev": "tauri dev",
"desktop:build": "tauri build"
Expand Down
Loading
Loading