From f9d57eff1973db6ddd00c5e9f4fc18b68d1d04c9 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Wed, 18 Nov 2026 21:43:44 +0100 Subject: [PATCH] Keep dev-key tests outside website-only deployment archive --- .forgejo/workflows/web-deploy.yml | 173 +++++++++--------- .../tests/jarvis-dev-clan-reset.test.mjs | 6 +- .../tests/jarvis-dev-key.test.mjs | 2 +- 3 files changed, 91 insertions(+), 90 deletions(-) rename {website => tools}/tests/jarvis-dev-clan-reset.test.mjs (93%) rename {website => tools}/tests/jarvis-dev-key.test.mjs (95%) diff --git a/.forgejo/workflows/web-deploy.yml b/.forgejo/workflows/web-deploy.yml index 101ef3e8..bd4621c4 100644 --- a/.forgejo/workflows/web-deploy.yml +++ b/.forgejo/workflows/web-deploy.yml @@ -1,86 +1,87 @@ -name: DuneRealms Web CI - -on: - push: - branches: - - main - paths: - - 'website/**' - - '.forgejo/workflows/web-deploy.yml' - workflow_dispatch: - -jobs: - web: - runs-on: dune-ci - steps: - - name: Checkout - shell: bash - env: - REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git init . - git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/MC.git "$GITHUB_SHA" - git checkout --detach FETCH_HEAD - - - name: Install Node 22 - uses: actions/setup-node@v4 - with: - node-version: '22' - - - name: Prepare publication comparison - shell: bash - env: - REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - BEFORE=$(node -e 'const fs=require("fs");const p=process.env.GITHUB_EVENT_PATH;const e=p&&fs.existsSync(p)?JSON.parse(fs.readFileSync(p)):{};process.stdout.write(e.before||"");') - if [[ ! "$BEFORE" =~ ^[0-9a-f]{40}$ || "$BEFORE" =~ ^0+$ ]]; then - git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --deepen=1 https://www.dunerealms.com/git/unimatrix/MC.git "$GITHUB_SHA" - BEFORE=$(git rev-parse HEAD^) - else - git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/MC.git "$BEFORE" - fi - node website/scripts/publication-changes.mjs "$BEFORE" "$GITHUB_SHA" - - - name: Verify deployment policy - run: | - node --test .forgejo/tests/web-deploy.test.mjs - python3 -m unittest discover -s website/ops -p 'test_*.py' - - - name: Build and test website - working-directory: website - run: | - corepack enable - corepack pnpm install --frozen-lockfile - corepack pnpm build - corepack pnpm test - - - name: Upload website build - if: github.ref == 'refs/heads/main' - uses: actions/upload-artifact@v3 - with: - name: DuneRealms-Website - path: website/dist/ - if-no-files-found: error - retention-days: 1 - - - name: Trigger deployment after successful CI - if: github.ref == 'refs/heads/main' - shell: bash - env: - DEPLOY_KEY: ${{ secrets.DUNEREALMS_DEPLOY_KEY }} - run: | - install -m 700 -d ~/.ssh - printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/deploy_key - chmod 600 ~/.ssh/deploy_key - trap 'rm -f ~/.ssh/deploy_key' EXIT - printf '%s\n' '91.107.196.242 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC8x/XocsIz41fWHGty0DbZhSvafSQFt9jaHHgzdr55W root@ubuntu-4gb-fsn1-1' >> ~/.ssh/known_hosts - ssh -p 22 -i ~/.ssh/deploy_key -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes dunedeploy@91.107.196.242 "$GITHUB_SHA" - rm -f ~/.ssh/deploy_key - - - name: Prune previous CI artifacts after confirmed publication - if: github.ref == 'refs/heads/main' - continue-on-error: true - shell: bash - env: - REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: node website/scripts/prune-ci-artifacts.mjs +name: DuneRealms Web CI + +on: + push: + branches: + - main + paths: + - 'website/**' + - '.forgejo/workflows/web-deploy.yml' + workflow_dispatch: + +jobs: + web: + runs-on: dune-ci + steps: + - name: Checkout + shell: bash + env: + REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git init . + git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/MC.git "$GITHUB_SHA" + git checkout --detach FETCH_HEAD + + - name: Install Node 22 + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Prepare publication comparison + shell: bash + env: + REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + BEFORE=$(node -e 'const fs=require("fs");const p=process.env.GITHUB_EVENT_PATH;const e=p&&fs.existsSync(p)?JSON.parse(fs.readFileSync(p)):{};process.stdout.write(e.before||"");') + if [[ ! "$BEFORE" =~ ^[0-9a-f]{40}$ || "$BEFORE" =~ ^0+$ ]]; then + git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --deepen=1 https://www.dunerealms.com/git/unimatrix/MC.git "$GITHUB_SHA" + BEFORE=$(git rev-parse HEAD^) + else + git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/MC.git "$BEFORE" + fi + node website/scripts/publication-changes.mjs "$BEFORE" "$GITHUB_SHA" + + - name: Verify deployment policy + run: | + node --test .forgejo/tests/web-deploy.test.mjs + python3 -m unittest discover -s website/ops -p 'test_*.py' + + - name: Build and test website + working-directory: website + run: | + corepack enable + corepack pnpm install --frozen-lockfile + corepack pnpm build + corepack pnpm test + node --test --test-concurrency=1 ../tools/tests/*.test.mjs + + - name: Upload website build + if: github.ref == 'refs/heads/main' + uses: actions/upload-artifact@v3 + with: + name: DuneRealms-Website + path: website/dist/ + if-no-files-found: error + retention-days: 1 + + - name: Trigger deployment after successful CI + if: github.ref == 'refs/heads/main' + shell: bash + env: + DEPLOY_KEY: ${{ secrets.DUNEREALMS_DEPLOY_KEY }} + run: | + install -m 700 -d ~/.ssh + printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + trap 'rm -f ~/.ssh/deploy_key' EXIT + printf '%s\n' '91.107.196.242 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC8x/XocsIz41fWHGty0DbZhSvafSQFt9jaHHgzdr55W root@ubuntu-4gb-fsn1-1' >> ~/.ssh/known_hosts + ssh -p 22 -i ~/.ssh/deploy_key -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes dunedeploy@91.107.196.242 "$GITHUB_SHA" + rm -f ~/.ssh/deploy_key + + - name: Prune previous CI artifacts after confirmed publication + if: github.ref == 'refs/heads/main' + continue-on-error: true + shell: bash + env: + REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: node website/scripts/prune-ci-artifacts.mjs diff --git a/website/tests/jarvis-dev-clan-reset.test.mjs b/tools/tests/jarvis-dev-clan-reset.test.mjs similarity index 93% rename from website/tests/jarvis-dev-clan-reset.test.mjs rename to tools/tests/jarvis-dev-clan-reset.test.mjs index d4e26874..b8ad15f8 100644 --- a/website/tests/jarvis-dev-clan-reset.test.mjs +++ b/tools/tests/jarvis-dev-clan-reset.test.mjs @@ -1,7 +1,7 @@ import test from 'node:test';import assert from 'node:assert/strict';import {randomUUID} from 'node:crypto'; -import {BankFixture} from './postbank-fixture.mjs'; -import {createDevKeyAuthority} from '../../tools/jarvis-dev-key.mjs'; -import {clanResetManifest,executeClanReset} from '../../tools/jarvis-dev-clan-reset.mjs'; +import {BankFixture} from '../../website/tests/postbank-fixture.mjs'; +import {createDevKeyAuthority} from '../jarvis-dev-key.mjs'; +import {clanResetManifest,executeClanReset} from '../jarvis-dev-clan-reset.mjs'; function fixture(){const db=new BankFixture();db.sqlite.exec(` CREATE TABLE site_accounts(id TEXT PRIMARY KEY,username TEXT); CREATE TABLE site_clans(id TEXT PRIMARY KEY,name TEXT,owner_id TEXT,active INT,version INT,updated_at INT); diff --git a/website/tests/jarvis-dev-key.test.mjs b/tools/tests/jarvis-dev-key.test.mjs similarity index 95% rename from website/tests/jarvis-dev-key.test.mjs rename to tools/tests/jarvis-dev-key.test.mjs index 3ee2be96..6e19600d 100644 --- a/website/tests/jarvis-dev-key.test.mjs +++ b/tools/tests/jarvis-dev-key.test.mjs @@ -1,5 +1,5 @@ import test from 'node:test';import assert from 'node:assert/strict'; -import {createDevKeyAuthority} from '../../tools/jarvis-dev-key.mjs'; +import {createDevKeyAuthority} from '../jarvis-dev-key.mjs'; const dev={id:'developer'},manifest={action:'clan-reset',state:'planned',deleteClanIds:['test'],retainClanIds:['official','mine']}; const setup=(extra={})=>createDevKeyAuthority({secret:'ab'.repeat(32),environment:'test',authorize:async actor=>actor.id===dev.id,...extra}); test('dev key binds exact manifest, actor and environment, and audit contains no secret',async()=>{