Compare commits
No commits in common. "f4dd351f8776fcf4d4e913e5096c7f8d8e5f41ef" and "4a5cac259381e0e3065a81df36cb1ecdd9c2a0af" have entirely different histories.
f4dd351f87
...
4a5cac2593
|
|
@ -6,33 +6,42 @@ script, and activates the release through SSH. The sole deployment secret is
|
||||||
|
|
||||||
## One-time server setup
|
## One-time server setup
|
||||||
|
|
||||||
Server inspection on 19 November 2026 found an HTTP-only site at
|
Obtain this branch's files on server1 using your existing repository access,
|
||||||
`/etc/nginx/sites-enabled/ManiCandles.midastix.com.conf`, with its old root at
|
or transfer the Nginx snippet from your workstation. From the repository directory,
|
||||||
`/var/www/ManiCandles.midastix.com`. Certbot is installed. The setup script is
|
run the following as `mihir`.
|
||||||
specific to that configuration and refuses to overwrite a site with TLS settings.
|
|
||||||
|
|
||||||
Obtain this branch's files on server1 using your existing repository access.
|
|
||||||
From the repository directory, run the following as `mihir`.
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo sh scripts/setup-static-host.sh
|
sudo install -d -o mihir -g "$(id -gn mihir)" -m 0755 \
|
||||||
sudo certbot --nginx -d manicandles.midastix.com --redirect
|
/var/www/manicandles /var/www/manicandles/releases /var/www/manicandles/incoming
|
||||||
sudo nginx -t
|
sudo install -d -m 0755 /etc/nginx/snippets
|
||||||
curl --fail --show-error https://manicandles.midastix.com/
|
sudo install -m 0644 deploy/nginx-locations.conf /etc/nginx/snippets/manicandles.conf
|
||||||
|
command -v flock
|
||||||
|
command -v curl
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, copy `scripts/setup-static-host.sh` and
|
Identify the existing Nginx site file for `manicandles.midastix.com`.
|
||||||
`deploy/nginx-locations.conf` together to `/tmp/` on server1, and run
|
|
||||||
`sudo sh /tmp/setup-static-host.sh`, followed by the Certbot and verification
|
|
||||||
commands above. The snippet must be beside the setup script for this layout.
|
|
||||||
|
|
||||||
Setup backs up the original site under `/var/backups`, prepares writable release
|
```sh
|
||||||
directories, installs the snippet, validates Nginx, and reloads it. Validation or
|
sudo nginx -T 2>&1 | grep -E '^# configuration file|server_name.*manicandles'
|
||||||
reload failure restores the saved site file. If the old root contains an index,
|
```
|
||||||
setup retains it as the initial `current` release and a rollback target. If no
|
|
||||||
old index exists, the frontend awaits its first deployment. DNS must point to
|
Back up that site file before editing it. Inside its existing HTTPS `server`
|
||||||
server1 and public port 80 must be reachable for certificate issuance. Complete
|
block for `manicandles.midastix.com`, replace the old `root`, `index`, and
|
||||||
Certbot's email and agreement prompts yourself. Verify HTTPS before merging.
|
`location` directives with this include. Preserve its `listen`, `server_name`,
|
||||||
|
certificate paths, TLS settings, and HTTP-to-HTTPS redirect. Resolve any duplicate
|
||||||
|
security header definitions against the snippet.
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
include /etc/nginx/snippets/manicandles.conf;
|
||||||
|
```
|
||||||
|
|
||||||
|
Validate and reload. If validation fails, restore the saved site file before
|
||||||
|
continuing. Reload preserves existing connections. The frontend will begin
|
||||||
|
serving when the first release supplies `/var/www/manicandles/current`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo nginx -t && sudo systemctl reload nginx
|
||||||
|
```
|
||||||
|
|
||||||
Save the complete matching private key in Drone's `manicandles_deploy_key`
|
Save the complete matching private key in Drone's `manicandles_deploy_key`
|
||||||
secret. Its public key must be authorized for `mihir` on server1. Keep the
|
secret. Its public key must be authorized for `mihir` on server1. Keep the
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ test "$(cat "$release/release.txt")" = "$release_id"
|
||||||
|
|
||||||
# A slow older pipeline must not replace a newer successful release.
|
# A slow older pipeline must not replace a newer successful release.
|
||||||
last_build=0
|
last_build=0
|
||||||
if [ -L current ] && [ -f current/release.txt ]; then
|
if [ -L current ]; then
|
||||||
last_release=$(cat current/release.txt)
|
last_release=$(cat current/release.txt)
|
||||||
last_build=${last_release%%-*}
|
last_build=${last_release%%-*}
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
set -eu
|
|
||||||
test "$(id -u)" = 0 || { echo 'Run this setup script with sudo.' >&2; exit 1; }
|
|
||||||
script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
|
|
||||||
snippet="$script_dir/../deploy/nginx-locations.conf"
|
|
||||||
if [ ! -f "$snippet" ]; then snippet="$script_dir/nginx-locations.conf"; fi
|
|
||||||
test -s "$snippet"
|
|
||||||
site=$(readlink -f /etc/nginx/sites-enabled/ManiCandles.midastix.com.conf)
|
|
||||||
test -f "$site"
|
|
||||||
if grep -Eq 'listen[[:space:]].*443|ssl_certificate' "$site"; then
|
|
||||||
echo 'This site already contains TLS settings. Review its configuration before running setup.' >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
nginx -t
|
|
||||||
command -v curl
|
|
||||||
command -v flock
|
|
||||||
command -v certbot
|
|
||||||
root=/var/www/manicandles
|
|
||||||
install -d -o mihir -g "$(id -gn mihir)" -m 0755 "$root" "$root/releases" "$root/incoming"
|
|
||||||
if [ ! -e "$root/current" ] && [ ! -L "$root/current" ] && [ -s /var/www/ManiCandles.midastix.com/index.html ]; then
|
|
||||||
ln -s /var/www/ManiCandles.midastix.com "$root/current"
|
|
||||||
chown -h mihir:"$(id -gn mihir)" "$root/current"
|
|
||||||
fi
|
|
||||||
install -d -m 0755 /etc/nginx/snippets /var/backups
|
|
||||||
backup="/var/backups/manicandles-nginx-$(date +%Y%m%d%H%M%S)-$$.conf"
|
|
||||||
cp -p "$site" "$backup"
|
|
||||||
if [ -e /etc/nginx/snippets/manicandles.conf ] && ! cmp -s "$snippet" /etc/nginx/snippets/manicandles.conf; then
|
|
||||||
echo 'A different deployment snippet exists. Review the existing setup before continuing.' >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
install -m 0644 "$snippet" /etc/nginx/snippets/manicandles.conf
|
|
||||||
cat > "$site" <<'NGINX'
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name manicandles.midastix.com;
|
|
||||||
include /etc/nginx/snippets/manicandles.conf;
|
|
||||||
}
|
|
||||||
NGINX
|
|
||||||
if ! nginx -t || ! systemctl reload nginx; then
|
|
||||||
cp -p "$backup" "$site"
|
|
||||||
nginx -t && systemctl reload nginx
|
|
||||||
echo "Setup failed. Restored $backup" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Site prepared. Original configuration saved at $backup"
|
|
||||||
echo 'Next run: sudo certbot --nginx -d manicandles.midastix.com --redirect'
|
|
||||||
|
|
@ -51,15 +51,4 @@ test "$(cat "$fixture/site/current/release.txt")" = 2-bbb
|
||||||
rm "$fixture/site/wrong-marker"
|
rm "$fixture/site/wrong-marker"
|
||||||
deploy 1-aaa
|
deploy 1-aaa
|
||||||
test "$(cat "$fixture/site/current/release.txt")" = 2-bbb
|
test "$(cat "$fixture/site/current/release.txt")" = 2-bbb
|
||||||
# The existing HTTP site has no release metadata and must remain a rollback target.
|
|
||||||
rm "$fixture/site/current"
|
|
||||||
mkdir -p "$fixture/site/legacy"
|
|
||||||
echo legacy > "$fixture/site/legacy/index.html"
|
|
||||||
ln -s "$fixture/site/legacy" "$fixture/site/current"
|
|
||||||
touch "$fixture/site/fail-health"
|
|
||||||
if deploy 3-ccc; then echo 'Expected rollback to legacy site' >&2; exit 1; fi
|
|
||||||
test "$(cat "$fixture/site/current/index.html")" = legacy
|
|
||||||
rm "$fixture/site/fail-health"
|
|
||||||
deploy 3-ccc
|
|
||||||
test "$(cat "$fixture/site/previous/index.html")" = legacy
|
|
||||||
printf 'Deployment activation, rollback and stale-build checks passed.\n'
|
printf 'Deployment activation, rollback and stale-build checks passed.\n'
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { type ReactNode } from "react";
|
import { type ReactNode } from "react";
|
||||||
import { fireEvent, render, screen } from "@testing-library/react";
|
import { render, screen } from "@testing-library/react";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
import { ThemeProvider } from "@mui/material/styles";
|
import { ThemeProvider } from "@mui/material/styles";
|
||||||
|
|
@ -92,9 +92,11 @@ test("an uncertain sample request retries with its original account, variant, qu
|
||||||
|
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||||
fireEvent.change(await screen.findByRole("textbox", { name: /Variant ID/ }), { target: { value: variantId } });
|
await user.type(await screen.findByRole("textbox", { name: /Variant ID/ }), variantId);
|
||||||
fireEvent.change(screen.getByRole("spinbutton", { name: /Sample quantity/ }), { target: { value: "4" } });
|
const quantity = screen.getByRole("spinbutton", { name: /Sample quantity/ });
|
||||||
fireEvent.change(screen.getByRole("textbox", { name: /Sample purpose/ }), { target: { value: sample.purpose } });
|
await user.clear(quantity);
|
||||||
|
await user.type(quantity, "4");
|
||||||
|
await user.type(screen.getByRole("textbox", { name: /Sample purpose/ }), sample.purpose);
|
||||||
await user.click(screen.getByRole("button", { name: "Request samples" }));
|
await user.click(screen.getByRole("button", { name: "Request samples" }));
|
||||||
await user.click(await screen.findByRole("button", { name: "Retry sample request" }));
|
await user.click(await screen.findByRole("button", { name: "Retry sample request" }));
|
||||||
await screen.findByText(sample.purpose);
|
await screen.findByText(sample.purpose);
|
||||||
|
|
@ -155,11 +157,10 @@ test("an independent reviewer can approve a request and retry a manual dispatch"
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||||
await user.selectOptions(await screen.findByRole("combobox", { name: /Review decision/ }), "APPROVED");
|
await user.selectOptions(await screen.findByRole("combobox", { name: /Review decision/ }), "APPROVED");
|
||||||
fireEvent.change(screen.getByRole("textbox", { name: /Review note/ }), { target: { value: approved.note } });
|
await user.type(screen.getByRole("textbox", { name: /Review note/ }), approved.note);
|
||||||
await user.click(screen.getByRole("button", { name: "Record sample decision" }));
|
await user.click(screen.getByRole("button", { name: "Record sample decision" }));
|
||||||
expect(decision).toEqual({ decision: "APPROVED", note: approved.note, idempotencyKey: expect.any(String) });
|
await user.type(await screen.findByRole("textbox", { name: /Dispatch reference/ }), dispatched.dispatchReference);
|
||||||
fireEvent.change(await screen.findByRole("textbox", { name: /Dispatch reference/ }), { target: { value: dispatched.dispatchReference } });
|
await user.type(screen.getByRole("textbox", { name: /Dispatch note/ }), dispatched.note);
|
||||||
fireEvent.change(screen.getByRole("textbox", { name: /Dispatch note/ }), { target: { value: dispatched.note } });
|
|
||||||
await user.click(screen.getByRole("button", { name: "Record dispatch" }));
|
await user.click(screen.getByRole("button", { name: "Record dispatch" }));
|
||||||
await user.click(await screen.findByRole("button", { name: "Retry dispatch" }));
|
await user.click(await screen.findByRole("button", { name: "Retry dispatch" }));
|
||||||
await screen.findByRole("cell", { name: dispatched.dispatchReference });
|
await screen.findByRole("cell", { name: dispatched.dispatchReference });
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { type ReactNode } from "react";
|
import { type ReactNode } from "react";
|
||||||
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
import { act, render, screen, waitFor, within } from "@testing-library/react";
|
||||||
import { Table } from "../src/components/WorkspaceTools";
|
import { Table } from "../src/components/WorkspaceTools";
|
||||||
import { ConfirmAction } from "../src/components/ConfirmAction";
|
import { ConfirmAction } from "../src/components/ConfirmAction";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
|
|
@ -722,17 +722,19 @@ test("a production batch starts, safely retries usage and completes with reconci
|
||||||
await user.click(await screen.findByRole("button", { name: "Start batch" }));
|
await user.click(await screen.findByRole("button", { name: "Start batch" }));
|
||||||
await user.click(screen.getByRole("button", { name: "Confirm" }));
|
await user.click(screen.getByRole("button", { name: "Confirm" }));
|
||||||
await user.selectOptions(await screen.findByRole("combobox", { name: /Usage type/ }), "WASTED");
|
await user.selectOptions(await screen.findByRole("combobox", { name: /Usage type/ }), "WASTED");
|
||||||
fireEvent.change(screen.getByRole("textbox", { name: /Actual quantity/ }), { target: { value: "0.125" } });
|
await user.type(screen.getByRole("textbox", { name: /Actual quantity/ }), "0.125");
|
||||||
fireEvent.change(screen.getByRole("textbox", { name: /Usage reason/ }), { target: { value: "Spill" } });
|
await user.type(screen.getByRole("textbox", { name: /Usage reason/ }), "Spill");
|
||||||
await user.click(screen.getByRole("button", { name: "Record material usage" }));
|
await user.click(screen.getByRole("button", { name: "Record material usage" }));
|
||||||
await user.click(await screen.findByRole("button", { name: "Retry material usage" }));
|
await user.click(await screen.findByRole("button", { name: "Retry material usage" }));
|
||||||
await screen.findByRole("cell", { name: "199.875" });
|
await screen.findByRole("cell", { name: "199.875" });
|
||||||
expect(attempts).toHaveLength(2);
|
expect(attempts).toHaveLength(2);
|
||||||
expect(attempts[0]).toEqual({ bomLineId: id, kind: "WASTED", quantity: "0.125", reason: "Spill", idempotencyKey: expect.any(String) });
|
expect(attempts[0]).toEqual({ bomLineId: id, kind: "WASTED", quantity: "0.125", reason: "Spill", idempotencyKey: expect.any(String) });
|
||||||
expect(attempts[1]).toEqual(attempts[0]);
|
expect(attempts[1]).toEqual(attempts[0]);
|
||||||
fireEvent.change(screen.getByRole("spinbutton", { name: /Good pieces/ }), { target: { value: "18" } });
|
await user.type(screen.getByRole("spinbutton", { name: /Good pieces/ }), "18");
|
||||||
fireEvent.change(screen.getByRole("spinbutton", { name: /Rejected pieces/ }), { target: { value: "2" } });
|
const rejected = screen.getByRole("spinbutton", { name: /Rejected pieces/ });
|
||||||
fireEvent.change(screen.getByRole("textbox", { name: /Rejection reason/ }), { target: { value: "Surface defects" } });
|
await user.clear(rejected);
|
||||||
|
await user.type(rejected, "2");
|
||||||
|
await user.type(screen.getByRole("textbox", { name: /Rejection reason/ }), "Surface defects");
|
||||||
await user.click(screen.getByRole("button", { name: "Complete batch" }));
|
await user.click(screen.getByRole("button", { name: "Complete batch" }));
|
||||||
await screen.findByText(/18 good · 2 rejected · Surface defects/);
|
await screen.findByText(/18 good · 2 rejected · Surface defects/);
|
||||||
expect(screen.queryByRole("button", { name: "Record material usage" })).toBeNull();
|
expect(screen.queryByRole("button", { name: "Record material usage" })).toBeNull();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue