Compare commits
9 Commits
346d7b8bcd
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| e7eb9b8b16 | |||
| 726d9c5a09 | |||
| 7826018d61 | |||
| 16d72f40ce | |||
| 50cee580de | |||
| fb4bb63335 | |||
| f07e688bf1 | |||
| 7d1c7a6c75 | |||
| e90ffabf8b |
@ -4,7 +4,7 @@ on: [push]
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: rust-latest
|
||||
runs-on: rust-nextest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./backend
|
||||
@ -23,7 +23,7 @@ jobs:
|
||||
|
||||
|
||||
build:
|
||||
runs-on: rust-latest
|
||||
runs-on: rust-nextest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./backend
|
||||
@ -41,7 +41,7 @@ jobs:
|
||||
run: cargo build --release --locked
|
||||
|
||||
test:
|
||||
runs-on: rust-latest
|
||||
runs-on: rust-nextest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./backend
|
||||
@ -55,8 +55,8 @@ jobs:
|
||||
~/.cargo/git
|
||||
backend/target
|
||||
key: ${{ runner.os }}-cargo-test-${{ hashFiles('backend/Cargo.lock') }}
|
||||
- name: Build Binary with Shutdown
|
||||
run: cargo build --features shutdown --bin nuchat
|
||||
- name: Build Binary
|
||||
run: cargo build --locked --bin nuchat
|
||||
- name: Run Tests
|
||||
run: ./scripts/test.sh
|
||||
- name: Upload Test Logs
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
.env
|
||||
package/
|
||||
*.tar.zst
|
||||
|
||||
@ -28,5 +28,6 @@ path = "src/main.rs"
|
||||
name ="nuchat"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = [ "shutdown" ]
|
||||
all = ["shutdown"]
|
||||
shutdown = []
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
build:
|
||||
cargo build --features shutdown
|
||||
cargo build
|
||||
|
||||
run:
|
||||
cargo run --features shutdown
|
||||
cargo run
|
||||
|
||||
start:
|
||||
cargo run --features shutdown 2>&1 > logs/nuchat.log
|
||||
cargo run 2>&1 > logs/nuchat.log
|
||||
|
||||
test:
|
||||
./scripts/test.sh
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
# Backend
|
||||
|
||||
Generate random secret using. This secret will be used to authenticate users on all `/admin` routes
|
||||
Generate random secret using openssl. This secret will be used to authenticate users on all `/admin` routes.
|
||||
If no secret is given then no authentication will be required
|
||||
|
||||
```bash
|
||||
ADMIN_SECRET=$(openssl rand --base64 32)
|
||||
nuchat --admin-secret $(openssl rand --base64 32)
|
||||
```
|
||||
|
||||
## Features
|
||||
@ -11,5 +12,5 @@ ADMIN_SECRET=$(openssl rand --base64 32)
|
||||
### shutdown
|
||||
this feature enables an endpoint that allows you to shutdown the server.
|
||||
|
||||
**WARNING**: If the `ADMIN_SECRET` env var is not set then this endpoint is completely exposed and allows anyone to shutdown the server.
|
||||
**WARNING**: If the `admin-secret` flag is not set then this endpoint is completely exposed and allows anyone to shutdown the server.
|
||||
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if ! command -v cargo-nextest > /dev/null 2>&1; then
|
||||
echo "Command not found cargo-nextest"
|
||||
echo "Try installing with cargo install cargo-nextest"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d logs ]; then
|
||||
mkdir logs
|
||||
fi
|
||||
@ -8,7 +14,7 @@ fi
|
||||
curl -s -X POST localhost:7001/admin/shutdown 2>&1 > /dev/null
|
||||
|
||||
# start server
|
||||
cargo run --features shutdown -- --port 7001 2>&1 > logs/nuchat.log &
|
||||
cargo run -- --port 7001 2>&1 > logs/nuchat.log &
|
||||
|
||||
# run tests
|
||||
cargo nextest run 2>&1 | tee logs/test-output.log
|
||||
cargo nextest run --color=always 2>&1 | tee logs/test-output.log
|
||||
|
||||
36
scripts/environ.sh
Normal file
36
scripts/environ.sh
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function check_tags() {
|
||||
TAGS="$(git tag --points-at HEAD)"
|
||||
if [ -n "$TAGS" ]; then
|
||||
TAG=$(echo "$TAGS" | grep -E '^v[0-9]+.[0-9]+.[0-9]+$' | sort -V | tail -1)
|
||||
else
|
||||
echo "No release tag found"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function package() {
|
||||
PACKAGE_DIR="${PACKAGE_DIR:-package}"
|
||||
mkdir "$PACKAGE_DIR" > /dev/null 2>&1
|
||||
|
||||
pushd backend
|
||||
cargo build --release
|
||||
cp -v target/release/nuchat ../package/
|
||||
popd
|
||||
|
||||
pushd ui
|
||||
npm ci
|
||||
npm run build
|
||||
cp -rv .output ../package/ui
|
||||
popd
|
||||
|
||||
|
||||
OUT_FILE="${OUT_FILE:-package.tar.zst}"
|
||||
if [ -f "$OUT_FILE" ]; then
|
||||
rm "$OUT_FILE" > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
tar -cf - package/ | zstd -19 -T0 -o "${OUT_DIR}${OUT_FILE}"
|
||||
}
|
||||
|
||||
25
scripts/release.sh
Executable file
25
scripts/release.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. ./scripts/environ.sh
|
||||
|
||||
check_tags
|
||||
if [ -n "$TAG" ]; then
|
||||
echo "Found tag $TAG"
|
||||
RELEASE_VERSION=$(echo "$TAG" | sed 's/v//')
|
||||
echo "Releasing $RELEASE_VERSION"
|
||||
echo ""
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
package
|
||||
|
||||
if [ ! -f package.tar.zst ]; then
|
||||
echo "failed to generate package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl -s -X PUT \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
--upload-file "$OUT_DIR$OUT_FILE" \
|
||||
"https://git.molloy.xyz/api/packages/fergus-molloy/generic/nuchat/$RELEASE_VERSION/nuchat.tar.zst"
|
||||
@ -2,11 +2,5 @@
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: '2025-07-15',
|
||||
devtools: { enabled: true },
|
||||
|
||||
modules: [
|
||||
'@nuxt/eslint',
|
||||
'@nuxt/icon',
|
||||
'@nuxt/image',
|
||||
'@nuxt/test-utils'
|
||||
]
|
||||
})
|
||||
modules: ['@nuxt/eslint', '@nuxt/icon', '@nuxt/test-utils']
|
||||
})
|
||||
|
||||
14387
ui/package-lock.json
generated
Normal file
14387
ui/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,11 +11,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nuxt/eslint": "1.6.0",
|
||||
"@nuxt/icon": "1.15.0",
|
||||
"@nuxt/image": "1.10.0",
|
||||
"@nuxt/test-utils": "3.19.2",
|
||||
"eslint": "^9.31.0",
|
||||
"nuxt": "^4.0.0",
|
||||
"@nuxt/icon": "^1.15.0",
|
||||
"@nuxt/test-utils": "^3.19.2",
|
||||
"nuxt": "^4.0.1",
|
||||
"vue": "^3.5.17",
|
||||
"vue-router": "^4.5.1"
|
||||
}
|
||||
|
||||
9958
ui/pnpm-lock.yaml
generated
9958
ui/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user