Skip to content
phalconPublic

About

This repository holds all the assets that Phalcon sites use

Resources

Security policy

Stars

3 stars

Watchers

6 watching

Forks

Repository files navigation

Phalcon

Phalcon Assets

This repository holds all the assets that Phalcon sites use: the design tokens and the shared stylesheets, the sponsor and GitHub data, the images, logos and icons, and the assets of the Phalcon debug page. assets.phalcon.io serves them.

The site is built with Astro. The CI workflow (.github/workflows/main.yml) checks the PHP and runs the tests, builds the site, and publishes the build to the production branch, which Cloudflare Pages serves. It runs after every push and after each data workflow.

The folders

  • public/phalcon/, public/zephir/, public/debug/: the assets, served at /phalcon/…, /zephir/… and /debug/…. The other sites load them by address, so a file keeps its path and its bytes (npm run verify checks it).
  • public/phalcon/css/: the shared stylesheets of the sites: tokens.css (the design tokens), common.css (the shared nav and footer), sidebar.css (the shared sidebar) and code-theme.json (the code theme).
  • public/phalcon/footer.json and public/phalcon/sidebar.json: the links of the shared footer, and the titles and text of the shared sidebar.
  • public/phalcon/tools/: the shared tools that each site gets before every build: design-checks.mjs and design-refresh.mjs (the checks and the refresh of the design files) and stars.mjs (the star count of the nav).
  • scripts/: the generators of the data (generateSponsors.php, generateGithub.php, with sponsors/ and github/), the roster script of the other repositories (updateBackers.php, with backers/), the PHP checks of the shared files (tokens/), the feed watch (watch-feeds.mjs, with watch/), and the checks of the build (verify-build.mjs).
  • tests/: the PHP tests (tokens.php, github.php, sponsors.php, backers.php) and the Node tests.
  • src/: the page of the site (the shared nav, footer and sidebar).

The data workflows

  • sponsors.yml (daily): php scripts/generateSponsors.php writes public/phalcon/sponsors.json from GitHub Sponsors, Open Collective and scripts/sponsors/partners.json.
  • github-data.yml (daily): php scripts/generateGithub.php writes public/phalcon/repositories.json and public/phalcon/contributors.json for the repositories of scripts/github/repositories.json.

Each commits when its data changed. The CI workflow runs after each of them, so the new data is live some minutes later.

watch.yml (daily, 05:47 UTC) checks that the feeds are current: the last scheduled runs of the two data workflows passed and are less than 26 hours old, the last CI run on master passed, and the live feeds are the files of master. When a check fails, it opens the issue "The assets feeds need attention" (or adds a comment to the open one) and the run fails. When every check passes again, it closes the issue. A failed scheduled run of a data workflow stays a problem until a re-run of that run passes: a manual run of the workflow does not clear it, because the watch reads only the scheduled runs. The checks are in scripts/watch/checks.mjs. To see the state now, with the files of master in the working tree (after git pull): docker run --rm -v "$PWD:/app" -w /app node:26-alpine node scripts/watch-feeds.mjs --dry-run.

The backers workflow

backers.yml is a reusable workflow. It runs php scripts/updateBackers.php on a file of the repository that calls it (README.md by default). The script replaces the text between <!-- backers:start --> and <!-- backers:end --> with the roster of https://assets.phalcon.io/phalcon/sponsors.json. When the file changed, the workflow pushes the change to the branch backers-roster-update and opens a pull request Updating the backers roster. There is at most one open pull request: a new change replaces the change of an earlier run, and when the roster is the same as on the base branch again, the workflow closes the pull request. The repository must allow GitHub Actions to create pull requests (Settings, Actions, General).

A repository calls it every day, one hour after the roster job:

name: Update backers

on:
  schedule:
    - cron: "17 5 * * *"

  workflow_dispatch:

permissions:
  contents: write
  pull-requests: write

jobs:
  backers:
    uses: phalcon/assets/.github/workflows/backers.yml@<commit SHA> # master
    # Only when the file is not README.md:
    with:
      file: BACKERS.md

The workflow runs the script of the commit that the caller pins. When the script changes, change the SHA in each caller.

Local use

The tools run in Docker:

  • Install: docker run --rm -v "$PWD:/app" -w /app node:26-alpine npm ci
  • Tests: docker run --rm -v "$PWD:/app" -w /app node:26-alpine npm test
  • PHP tests: docker run --rm -v "$PWD:/app" -w /app php:8.4-cli sh -c 'php tests/tokens.php && php tests/github.php && php tests/sponsors.php && php tests/backers.php'
  • PHP analyzers: phpcs (PSR-12, phpcs.xml) and phpstan analyse (level max, phpstan.neon).
  • Build and checks: docker run --rm -v "$PWD:/app" -w /app node:26-alpine sh -c 'npm run build && npm run verify'
  • Preview: docker run --rm -p 4321:4321 -v "$PWD:/app" -w /app node:26-alpine npx astro preview --host 0.0.0.0

The docs kit

docs-kit/ is the package @phalcon/docs-kit: the shared base of the Phalcon documentation sites (Astro and nimbus-docs). It has the components, the layouts, the styles, the routes, the scripts and the docs-kit command. A site keeps its values, its pages and its sidebars, and pins a kit version. docs-kit/README.md is the guide for a site.

Two ways of updating in this repository.

  • public/ is live: assets.phalcon.io serves it, and a change is on all sites at once (their next build downloads it).
  • docs-kit/ is pinned: a site gets a change of the kit only with a new kit version in its docs/package.json.
  • Nothing of docs-kit/ or docs-kit-fixture/ is published on assets.phalcon.io.

Local commands. There are no tools on the host: docs-kit/run runs a command in the phalcon-docs image, and builds the image when it does not exist. It mounts the root of the repository at /repo and works in docs-kit/, or in the folder of --in <path>. The temp files and the pnpm store are in .tmp/ (ignored by git).

  • Install: docs-kit/run pnpm install
  • Tests: docs-kit/run pnpm test
  • The fixture site (docs-kit-fixture/: a stable version, a pre-release and a deprecated version), with docs-kit/run --in docs-kit-fixture/docs before each command:
    • after a kit change, pnpm install --force (the fixture has a copy of the kit);
    • pnpm build, pnpm test, pnpm lint:docs, pnpm exec docs-kit nimbus check, pnpm typecheck.
  • The sites on the kit (docs-kit/sites.json), built and checked with the packed kit of the work tree: docs-kit/run node scripts/check-sites.mjs [name].
  • The compare of two builds: docs-kit/run node scripts/compare-dist.mjs /repo/<dist> /repo/<dist>.

CI. .github/workflows/docs-kit.yml runs on a change of the kit, of the fixture or of the three docs workflows:

  • kit: the tests of the kit;
  • fixture: the shared workflow (.github/workflows/docs-site.yml) on the fixture, with no publish;
  • sites: each site of sites.json, built with the packed kit of the commit. A failed build or check fails the run. The compare with the build on the pinned kit of the site is in the job summary: read it before the merge;
  • install: a copy of the fixture builds, checks, type-checks and lints with the packed kit of the commit (pnpm pack: the file of a release), from a new lock into an empty store, as the CI of a site does. A file that the files list of docs-kit/package.json leaves out fails here (the kit and fixture jobs use the kit folder).

.github/workflows/docs-kit-release.yml runs on the push of a kit-v* tag: see "Release a kit version".

Update nimbus-docs. The kit pins nimbus-docs to an exact version, because a nimbus update is code work. The update run of the team reports a new version as kit work. On a branch:

  1. Set the new version of @cloudflare/nimbus-docs in docs-kit/package.json, then docs-kit/run pnpm install.

  2. docs-kit/run pnpm exec nimbus-docs migrate --dry-run lists the reviews of the upgrade. Make them in the kit. A review that names astro.config.ts applies to docs-kit/config.mjs and docs-kit/starter/shared/astro.config.ts.

  3. docs-kit/run pnpm exec nimbus-docs migrate --yes records the version in docs-kit/nimbus.json.

  4. docs-kit/run pnpm exec nimbus-docs outdated lists the registry components and the starter files that changed upstream; docs-kit/run pnpm exec nimbus-docs diff <file> shows one. Take the changes that the sites need.

  5. Run the tests, then the fixture:

    • docs-kit/run --in docs-kit-fixture/docs pnpm install: the fixture lock records the dependencies of the kit, and the fixture must build on the new nimbus;
    • docs-kit/run --in docs-kit-fixture/docs pnpm exec docs-kit sync (it copies the new nimbus.json), the build and the checks.

    Then check-sites.mjs. For a large change, compare the fixture build before and after with compare-dist.mjs.

  6. Commit the two lock files, docs-kit/pnpm-lock.yaml and docs-kit-fixture/docs/pnpm-lock.yaml (a kit test checks that both have the nimbus version of the kit). Write the kit changelog, then release (below).

If a review needs a site, run migrate in the fixture (docs-kit/run --in docs-kit-fixture/docs pnpm exec nimbus-docs migrate --dry-run) and copy its nimbus.json to docs-kit/.

Release a kit version.

  1. In the pull request:

    • set the version in docs-kit/package.json;
    • add a section to docs-kit/CHANGELOG.md, with the date of the release in place of (unreleased) when you know it;
    • change the kit pin of a new site to the new release: docs-kit/starter/new/package.json (https://github.com/phalcon/assets/releases/download/kit-vX.Y.Z/phalcon-docs-kit-X.Y.Z.tgz) and the comment of docs-kit/starter/new/docs.yml (# kit-vX.Y.Z; its commit stays a TODO, a new site takes it from the tag). A kit test checks both.

    The version: major when a site must change a file that it writes by hand, minor for a new feature, patch for a fix. Say so in the changelog when a file of docs-kit/starter/shared/ changes.

  2. After the merge, when the CI of the merge commit is green, tag the merge commit and push the tag. Only an organization admin can create, move or delete a kit-v* tag (the tag ruleset kit-tags).

    git tag kit-vX.Y.Z <merge commit>
    git push origin kit-vX.Y.Z

    The tag push starts .github/workflows/docs-kit-release.yml. Its release job checks that the tag is the version of docs-kit/package.json and that the starter pins the release of the tag. Then it packs the kit, makes the release with the file phalcon-docs-kit-X.Y.Z.tgz and the notes of the version in docs-kit/CHANGELOG.md, and checks that the release cannot change. Its check job, which cannot write, compares the file at the release address with the packed file, and installs a new site from that address. If the run fails:

    • in the release job, before the step Make the release (a wrong tag, a starter that pins another release, no changelog section): there is no release. Delete the tag (git push origin :refs/tags/kit-vX.Y.Z, then git tag -d kit-vX.Y.Z), fix the cause in a pull request, then tag again;
    • in the step Make the release, because the release can change (release immutability is off): delete the release and the tag, turn on release immutability, then tag again;
    • in the check job, because of the network: run the failed job again;
    • in the check job, because the file is not the packed file or a new site cannot install it: the release is bad. A release cannot change (release immutability): fix it with a new patch version.
  3. The commit of the tag, for the caller pin of a site (uses: phalcon/assets/.github/workflows/docs-site.yml@<commit> # kit-vX.Y.Z): git rev-parse kit-vX.Y.Z^{commit}.

How the sites get a new kit version. The update scripts of the team support the kit after a later change of phalcon/team. Then the next update-all-projects run changes the kit version of each site: docs/package.json (the release address), the caller .github/workflows/docs.yml, the lock file, and the synced files (docs-kit sync). The CI of each site builds and checks the change. A new major kit version is reported, not written: --major phalcon/assets writes it. Until then, change the two pins of a site by hand, then run pnpm install and pnpm exec docs-kit sync in its docs/.

Colors, fonts, the nav and the footer

  • To change a color, change public/phalcon/css/tokens.css. The PHP checks (tests/tokens.php) and the Node tests check the shared files; the other sites get them on their next CI run.
  • public/css/site.css has the rules of this site. Use a color through the tokens: var(--nd-…) or var(--ph-…). npm test fails on a typed color in public/css/site.css and src/.
  • The nav (src/components/Header.astro) and the footer (src/components/Footer.astro) are the ones of phalcon.io, with the classes of common.css. public/js/nav.js is a copy of the mobile menu script of phalcon.io.

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

About

This repository holds all the assets that Phalcon sites use

Resources

Security policy

Stars

3 stars

Watchers

6 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages