diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index c1f3e5f..bdf274b 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -9,15 +9,22 @@ on: - main pull_request: {} +concurrency: + group: cos-upload-${{ github.repository }}-${{ github.event_name == 'pull_request' && format('pr-{0}-{1}', github.event.pull_request.number, github.run_id) || 'production' }} + cancel-in-progress: false + jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - - uses: actions/setup-node@v6 + - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 with: node-version: 24 + package-manager-cache: false - name: Enable Corepack run: | @@ -25,10 +32,14 @@ jobs: corepack prepare yarn@4.18.0 --activate yarn --version - - uses: calcit-lang/setup-calcit@v1 + - uses: calcit-lang/setup-calcit@ca701be5a471759e442aa053cd100720bbe1f09f # v1.5.0 + with: + tools: calcit,caps + caps-version: "0.1.1" - name: Install dependencies run: | + set -euo pipefail caps --strict --ci yarn install --immutable @@ -37,20 +48,76 @@ jobs: - name: Validate snapshot and types run: | + set -euo pipefail + test "$(calcit --version)" = "0.27.0" + test -f calcit.cirru + test -f deps.cirru + test ! -e compact.cirru + test ! -e package.cirru calcit calcit.cirru edit format git diff --exit-code -- calcit.cirru calcit calcit.cirru --check-only + calcit calcit.cirru analyze check-public \ + --ns app.comp.container --ns app.config --ns app.main \ + --ns app.schema --ns app.updater --summary-only --format json calcit calcit.cirru analyze dynamic-methods --summary-only --format json | jq -e '.data.summary.findings == 0' + - name: Select frontend CDN path + id: asset-path + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then + prefix="${GITHUB_REPOSITORY}/pr/${PR_NUMBER}/${GITHUB_RUN_ID}/" + else + prefix="${GITHUB_REPOSITORY}/" + fi + base_url="https://cos-sh.tiye.me/${prefix}" + echo "VITE_BASE_URL=${base_url}" >> "$GITHUB_ENV" + echo "prefix=${prefix}" >> "$GITHUB_OUTPUT" + echo "base-url=${base_url}" >> "$GITHUB_OUTPUT" + - name: Compile and build run: | + set -euo pipefail calcit calcit.cirru js node --test scripts/typed-reel-render.test.mjs - yarn vite build --base=./ + yarn vite build --base="$VITE_BASE_URL" + + - name: Check COS credentials + id: cos-credentials + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository + env: + COS_BUCKET: ${{ secrets.COS_BUCKET }} + COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }} + COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }} + run: | + if [[ -n "$COS_BUCKET" && -n "$COS_SECRET_ID" && -n "$COS_SECRET_KEY" ]]; then + echo "available=true" >> "$GITHUB_OUTPUT" + elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then + echo "available=false" >> "$GITHUB_OUTPUT" + echo "::warning::COS secrets missing; upload verification skipped." + else + echo "::error::COS_BUCKET, COS_SECRET_ID and COS_SECRET_KEY are required." + exit 1 + fi + + - name: Upload and verify frontend assets + if: steps.cos-credentials.outputs.available == 'true' + uses: worktools/cos-upload-action@17e6d213fe9f6772a6090a13c8ba044cd6cbcb09 # v1.1.1 + with: + source-dir: dist + bucket: ${{ secrets.COS_BUCKET }} + region: ap-shanghai + prefix: ${{ steps.asset-path.outputs.prefix }} + public-base-url: ${{ steps.asset-path.outputs.base-url }} + secret-id: ${{ secrets.COS_SECRET_ID }} + secret-key: ${{ secrets.COS_SECRET_KEY }} - name: Deploy to server + if: github.event_name == 'push' && github.ref == 'refs/heads/main' id: deploy - uses: Pendect/action-rsyncer@v2.0.0 + uses: Pendect/action-rsyncer@8e05ffa5c93e5d9c9b167796b26044d2c616b2b9 # v2.0.0 env: DEPLOY_KEY: ${{secrets.rsync_private_key}} with: @@ -61,4 +128,5 @@ jobs: dest: "rsync-user@tiye.me:/web-assets/repo/${{ github.repository }}/${{ github.event_name == 'pull_request' && format('pr/{0}/', github.event.pull_request.number) || '' }}" - name: Display status from deploy + if: github.event_name == 'push' && github.ref == 'refs/heads/main' run: echo "${{ steps.deploy.outputs.status }}" diff --git a/.gitignore b/.gitignore index 6e945ca..77c078d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ .compact-inc.cirru .calcit-error.cirru +.calcit/ +compact.cirru +package.cirru js-out/ node_modules/ diff --git a/.yarnrc.yml b/.yarnrc.yml index 06687fe..6f63f08 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1,3 +1,3 @@ nodeLinker: node-modules npmPreapprovedPackages: - - "@calcit/procs@0.23.1" + - "@calcit/procs@0.27.0" diff --git a/README.md b/README.md index 06c6ae8..dac87de 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,29 @@ Demo http://repo.respo-mvc.org/markup/ . ### Usages -_TODO_ +Use Calcit/procs 0.27.0, Caps 0.1.1, Node.js 24 and Yarn 4.18.0. +Canonical source and dependencies are `calcit.cirru` and `deps.cirru`; +retired compact/package snapshots are not used. Edit source with the Calcit CLI. + +```sh +caps --strict --ci +yarn install --immutable +caps verify --toolchain +calcit calcit.cirru js +yarn vite +``` + +CI retains strict dependency resolution, entry/type checks and the existing +typed Reel rendering test, and checks all application public definitions. + +### Deployment + +Frontend build uses `VITE_BASE_URL`, pointing to +`https://cos-sh.tiye.me/Respo/markup/` on main and +`https://cos-sh.tiye.me/Respo/markup/pr///` for PR previews. +COS action v1.1.1 uploads `dist` and verifies through `public-base-url`; +no separate upload verification script is needed. Production server deployment +keeps its original source and destination; PRs do not deploy to the server. ### Workflow diff --git a/calcit.cirru b/calcit.cirru index 72ccb85..ac2053f 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -3,7 +3,7 @@ :about "|Machine-generated snapshot. Do not edit directly — changes will be overwritten. Use `calcit query` to inspect and `calcit edit`/`calcit tree` to modify. Run `calcit docs agents --contract` before mutations; use `--full` for first orientation or changed contract digest. Manual edits must follow format and schema conventions, then run `calcit edit format`." :package |app :entries $ {} $ :default - {} (:description |) (:init-fn 'app.main/main!) (:mode :native) (:reload-fn 'app.main/reload!) + {} (:description |) (:init-fn 'app.main/main!) (:mode :js) (:reload-fn 'app.main/reload!) (:target :browser) :feature-policy $ {} :modules $ [] |respo.calcit/ |respo-ui.calcit/ |reel.calcit/ :type-slots $ {} diff --git a/deps.cirru b/deps.cirru index 7e2a2a4..d5a4e52 100644 --- a/deps.cirru +++ b/deps.cirru @@ -1,6 +1,6 @@ -{} (:calcit-version |0.23.1) +{} (:calcit-version |0.27.0) :version |0.0.5 - :dependencies $ {} (|Respo/reel.calcit |0.6.32) - |Respo/respo-ui.calcit |0.7.31 - |Respo/respo.calcit |0.16.113 + :dependencies $ {} (|Respo/reel.calcit |0.6.33-alpha.2) + |Respo/respo-ui.calcit |0.7.32-alpha.3 + |Respo/respo.calcit |0.16.114-alpha.5 diff --git a/package.json b/package.json index e8731dc..f39ee29 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "packageManager": "yarn@4.18.0", "dependencies": { - "@calcit/procs": "0.23.1" + "@calcit/procs": "0.27.0" }, "devDependencies": { "bottom-tip": "^0.1.5", diff --git a/yarn.lock b/yarn.lock index ed24637..9df413a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,14 +5,14 @@ __metadata: version: 10 cacheKey: 10c0 -"@calcit/procs@npm:0.23.1": - version: 0.23.1 - resolution: "@calcit/procs@npm:0.23.1" +"@calcit/procs@npm:0.27.0": + version: 0.27.0 + resolution: "@calcit/procs@npm:0.27.0" dependencies: "@calcit/ternary-tree": "npm:0.0.26" "@cirru/parser.ts": "npm:^0.0.9" "@cirru/writer.ts": "npm:^0.1.9" - checksum: 10c0/8061e6572ee4c02815edef57002cb9778ee7627647c68528d2bac30dd866a91b7c9a855e66457b152f430818ce35fc89eee9fdf190351068289491cf790a28c1 + checksum: 10c0/85edf1724beaf5e3b895f456b9d81ae93100316802b19bc20ab7cbcc61e295892e787c2f9cca0c9c231ba1cc3c3d320ae158d3f8c9fd39eda24500c56ebe99b1 languageName: node linkType: hard @@ -629,7 +629,7 @@ __metadata: version: 0.0.0-use.local resolution: "root-workspace-0b6124@workspace:." dependencies: - "@calcit/procs": "npm:0.23.1" + "@calcit/procs": "npm:0.27.0" bottom-tip: "npm:^0.1.5" vite: "npm:^8.3.0" languageName: unknown