diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..436650f --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @xuhdev diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..53d990f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,52 @@ +# @license AGPL-3.0-or-later +# +# Copyright(C) 2025 Hong Xu +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +name: Lint + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + lint: + name: Lint + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Use Node.js + uses: actions/setup-node@v4.1.0 + with: + node-version: 22 + cache: "npm" + + - name: Install Dependencies + run: npm ci + + - name: Install Caddy + run: | + sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl + curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg + curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list + sudo apt update + sudo apt install caddy + + - name: Lint + run: npm run lint diff --git a/.github/workflows/runtime.yml b/.github/workflows/runtime.yml new file mode 100644 index 0000000..d92ffd9 --- /dev/null +++ b/.github/workflows/runtime.yml @@ -0,0 +1,53 @@ +# @license AGPL-3.0-or-later +# +# Copyright(C) 2025 Hong Xu +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +name: Runtime + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + test: + name: Runtime + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Use Node.js + uses: actions/setup-node@v4.1.0 + with: + node-version: 22 + cache: "npm" + + - name: Install podman + run: sudo apt-get update && sudo apt-get install -y podman + + - name: Build + run: npm run build + + - name: Start the container + run: podman run --detach -p 3000:80 -p 3001:443 app + + - name: Install npm dependencies + run: npm ci + + - name: Run test + run: npm run test diff --git a/package.json b/package.json index 0dd8366..aab2035 100644 --- a/package.json +++ b/package.json @@ -7,14 +7,12 @@ "author": "Hong Xu ", "type": "module", "scripts": { - "lint": "eslint *.ts *.mjs && prettier . --check", + "lint": "eslint *.ts *.mjs && prettier . --check && caddy fmt --diff Caddyfile.base", "build": "podman build . -t app", "start": "podman run -it --rm -p 3000:80 -p 3001:443 app", "test": "vitest --run index.test.ts", - "test_live": "vitest --run docker.test.ts", - "format": "eslint --fix *.ts *.mjs && prettier . --write", - "compile": "tsc -p tsconfig.json", - "dev": "npm run build && node dist/index.js" + "format": "eslint --fix *.ts *.mjs && prettier . --write && caddy fmt --overwrite Caddyfile.base", + "compile": "tsc -p tsconfig.json" }, "devDependencies": { "@types/eslint": "^9.6.1",