Compare commits
No commits in common. "1fea301ecfee012931fb23774efcafec22c56782" and "a6b850fddd054bef9cd1e7fdbec4cd37b927b86d" have entirely different histories.
1fea301ecf
...
a6b850fddd
@ -17,6 +17,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DH_REGISTRY: docker.io
|
||||
GH_REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
REPOSITORY: ${{ github.event.repository.name }}
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
permissions:
|
||||
@ -41,23 +43,59 @@ jobs:
|
||||
username: ${{ env.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.GH_REGISTRY }}
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata for release Docker image
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.DOCKER_USERNAME }}/${{ env.REPOSITORY }}
|
||||
${{ env.GH_REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
|
||||
- name: Extract metadata for develop Docker image
|
||||
if: "!startsWith(github.ref, 'refs/tags/v')"
|
||||
id: meta-develop
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.GH_REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
|
||||
- name: Build and push release Docker image
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
target: deploy
|
||||
push: startsWith(github.ref, 'refs/tags/v')
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=${{ github.workflow }}
|
||||
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
|
||||
|
||||
- name: Build and push develop Docker image
|
||||
if: "!startsWith(github.ref, 'refs/tags/v')"
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
target: deploy
|
||||
push: true
|
||||
tags: ${{ steps.meta-develop.outputs.tags }}
|
||||
labels: ${{ steps.meta-develop.outputs.labels }}
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=${{ github.workflow }}
|
||||
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
|
@ -39,22 +39,22 @@ jobs:
|
||||
run: echo "DEPLOY=true" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout repository
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: https://github.com/docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
install: true
|
||||
|
||||
- name: Log in to the Docker Hub
|
||||
uses: https://github.com/docker/login-action@v3
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build Docker image
|
||||
uses: https://github.com/docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: ${{ env.DEPLOY }}
|
||||
pull: true
|
@ -5,13 +5,13 @@ WORKDIR /build
|
||||
COPY ./package*json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build && \
|
||||
RUN node --experimental-strip-types build.ts && \
|
||||
npm exec tsc && \
|
||||
npm ci --only=production --omit=dev
|
||||
|
||||
FROM base AS deploy
|
||||
FROM base as deploy
|
||||
|
||||
WORKDIR /srv/archery
|
||||
WORKDIR /srv/abt
|
||||
|
||||
RUN apk add --no-cache docker-cli
|
||||
COPY --from=build-env /build .
|
||||
|
171
build.ts
Normal file
171
build.ts
Normal file
@ -0,0 +1,171 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import child_process from 'child_process';
|
||||
import uglifyjs from "uglify-js";
|
||||
import * as sass from 'sass';
|
||||
import * as csso from 'csso';
|
||||
|
||||
const spawn = child_process.spawn;
|
||||
const fsp = fs.promises;
|
||||
const STYLESDIR = 'styles';
|
||||
const SCRIPTSDIR = 'scripts';
|
||||
const IMAGESDIR = path.join('assets', 'images');
|
||||
const STYLEOUTDIR = process.env.STYLEOUTDIR || path.join(import.meta.dirname, 'assets', 'css');
|
||||
const SCRIPTSOUTDIR = process.env.SCRIPTSOUTDIR || path.join(import.meta.dirname, 'assets', 'js');
|
||||
const IMAGESOUTDIR = process.env.IMAGESOUTDIR || path.join(import.meta.dirname, 'assets', 'webp');
|
||||
const STYLEOUTFILE = process.env.STYLEOUTFILE || 'styles.css';
|
||||
const SQUASH = new RegExp('^[0-9]+-');
|
||||
|
||||
async function emptyDir(dir: string) {
|
||||
await Promise.all((await fsp.readdir(dir, { withFileTypes: true })).map(f => path.join(dir, f.name)).map(p => fsp.rm(p, {
|
||||
recursive: true,
|
||||
force: true
|
||||
})));
|
||||
}
|
||||
|
||||
async function mkdir(dir: string | string[]) {
|
||||
if (typeof dir === 'string') {
|
||||
await fsp.mkdir(dir, { recursive: true });
|
||||
}
|
||||
else {
|
||||
await Promise.all(dir.map(mkdir));
|
||||
}
|
||||
}
|
||||
|
||||
// Process styles
|
||||
async function styles() {
|
||||
await mkdir([STYLEOUTDIR, STYLESDIR]);
|
||||
await emptyDir(STYLEOUTDIR);
|
||||
let styles: string[] = [];
|
||||
let files = await fsp.readdir(STYLESDIR);
|
||||
await Promise.all(files.map(f => new Promise(async (res, reject) => {
|
||||
let p = path.join(STYLESDIR, f);
|
||||
console.log(`Processing style ${p}`);
|
||||
let style = sass.compile(p).css;
|
||||
if (f.charAt(0) !== '_') {
|
||||
if (SQUASH.test(f)) {
|
||||
styles.push(style);
|
||||
}
|
||||
else {
|
||||
let o = path.join(STYLEOUTDIR, f.substring(0, f.lastIndexOf('.')) + '.css');
|
||||
await fsp.writeFile(o, csso.minify(style).css);
|
||||
console.log(`Wrote ${o}`);
|
||||
}
|
||||
}
|
||||
res(0);
|
||||
})));
|
||||
let out = csso.minify(styles.join('\n')).css;
|
||||
let outpath = path.join(STYLEOUTDIR, STYLEOUTFILE);
|
||||
await fsp.writeFile(outpath, out);
|
||||
console.log(`Wrote ${outpath}`);
|
||||
}
|
||||
|
||||
// Process scripts
|
||||
async function scripts() {
|
||||
await mkdir([SCRIPTSOUTDIR, SCRIPTSDIR]);
|
||||
await emptyDir(SCRIPTSOUTDIR);
|
||||
let files = await fsp.readdir(SCRIPTSDIR);
|
||||
await Promise.all(files.map(f => new Promise(async (res, reject) => {
|
||||
let p = path.join(SCRIPTSDIR, f);
|
||||
let o = path.join(SCRIPTSOUTDIR, f);
|
||||
console.log(`Processing script ${p}`);
|
||||
try {
|
||||
await fsp.writeFile(o, uglifyjs.minify((await fsp.readFile(p)).toString()).code);
|
||||
console.log(`Wrote ${o}`);
|
||||
}
|
||||
catch (ex) {
|
||||
console.log(`error writing ${o}: ${ex}`);
|
||||
}
|
||||
res(0);
|
||||
})));
|
||||
}
|
||||
|
||||
// Process images
|
||||
async function images(dir = '') {
|
||||
let p = path.join(IMAGESDIR, dir);
|
||||
await mkdir(p);
|
||||
if (dir.length === 0) {
|
||||
await mkdir(IMAGESOUTDIR)
|
||||
await emptyDir(IMAGESOUTDIR);
|
||||
}
|
||||
let files = await fsp.readdir(p, {
|
||||
withFileTypes: true
|
||||
});
|
||||
if (files.length) {
|
||||
await Promise.all(files.map(f => new Promise(async (res, reject) => {
|
||||
if (f.isFile()) {
|
||||
let outDir = path.join(IMAGESOUTDIR, dir);
|
||||
let infile = path.join(p, f.name);
|
||||
let outfile = path.join(outDir, f.name.substring(0, f.name.lastIndexOf('.')) + '.webp');
|
||||
await mkdir(outDir);
|
||||
console.log(`Processing image ${infile}`)
|
||||
let process = spawn('cwebp', ['-mt', '-q', '50', infile, '-o', outfile]);
|
||||
let timeout = setTimeout(() => {
|
||||
reject('Timed out');
|
||||
process.kill();
|
||||
}, 30000);
|
||||
process.on('exit', async (code) => {
|
||||
clearTimeout(timeout);
|
||||
if (code === 0) {
|
||||
console.log(`Wrote ${outfile}`);
|
||||
res(null);
|
||||
}
|
||||
else {
|
||||
reject(code);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (f.isDirectory()) {
|
||||
images(path.join(dir, f.name)).then(res).catch(reject);
|
||||
}
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
function isAbortError(err: unknown): boolean {
|
||||
return typeof err === 'object' && err !== null && 'name' in err && err.name === 'AbortError';
|
||||
}
|
||||
|
||||
(async function () {
|
||||
await Promise.all([styles(), scripts(), images()]);
|
||||
if (process.argv.indexOf('--watch') >= 0) {
|
||||
console.log('watching for changes...');
|
||||
(async () => {
|
||||
try {
|
||||
const watcher = fsp.watch(STYLESDIR);
|
||||
for await (const _ of watcher)
|
||||
await styles();
|
||||
} catch (err) {
|
||||
if (isAbortError(err))
|
||||
return;
|
||||
throw err;
|
||||
}
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const watcher = fsp.watch(SCRIPTSDIR);
|
||||
for await (const _ of watcher)
|
||||
await scripts();
|
||||
} catch (err) {
|
||||
if (isAbortError(err))
|
||||
return;
|
||||
throw err;
|
||||
}
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const watcher = fsp.watch(IMAGESDIR, {
|
||||
recursive: true // no Linux ☹️
|
||||
});
|
||||
for await (const _ of watcher)
|
||||
await images();
|
||||
} catch (err) {
|
||||
if (isAbortError(err))
|
||||
return;
|
||||
throw err;
|
||||
}
|
||||
})();
|
||||
}
|
||||
})();
|
@ -1,9 +1 @@
|
||||
{
|
||||
"db": {
|
||||
"host": "postgres",
|
||||
"password": "correcthorse"
|
||||
},
|
||||
"web": {
|
||||
"port": 8080
|
||||
}
|
||||
}
|
||||
{}
|
@ -7,10 +7,8 @@ services:
|
||||
context: ./
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- ./config:/srv/archery/config
|
||||
- ./config:/srv/abt/config
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
PASSWORD: ${POSTGRES_PASSWORD}
|
||||
restart: "no"
|
||||
ports:
|
||||
- 8080:8080
|
||||
|
77
package-lock.json
generated
77
package-lock.json
generated
@ -1,21 +1,21 @@
|
||||
{
|
||||
"name": "archery",
|
||||
"version": "0.1.6",
|
||||
"version": "0.0.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "archery",
|
||||
"version": "0.1.6",
|
||||
"version": "0.0.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.3",
|
||||
"ejs": "3.1.10",
|
||||
"express": "^4.21.2",
|
||||
"express-ws": "^5.0.2",
|
||||
"pg": "^8.15.6",
|
||||
"pg": "^8.13.1",
|
||||
"pg-hstore": "^2.3.4",
|
||||
"sequelize": "^6.37.7"
|
||||
"sequelize": "^6.37.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/csso": "5.0.4",
|
||||
@ -23,7 +23,9 @@
|
||||
"@types/express-ws": "3.0.5",
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/uglify-js": "3.17.5",
|
||||
"forking-build-shit": "0.0.2"
|
||||
"csso": "5.0.5",
|
||||
"sass": "1.83.1",
|
||||
"uglify-js": "3.19.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "5.7.3"
|
||||
@ -1029,21 +1031,6 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/forking-build-shit": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/forking-build-shit/-/forking-build-shit-0.0.2.tgz",
|
||||
"integrity": "sha512-1qpXIK3nX8ZPTbwojsqxjTp5qDITX24MkKaX/8p6mMkIAQiVul1nhdYCAFLpnpnLon87Ru1exlJKhkvIKT7b+A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"csso": "5.0.5",
|
||||
"sass": "1.86.0",
|
||||
"uglify-js": "3.19.3"
|
||||
},
|
||||
"bin": {
|
||||
"build-shit": "bin/build-shit.js"
|
||||
}
|
||||
},
|
||||
"node_modules/forwarded": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
||||
@ -1459,14 +1446,14 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pg": {
|
||||
"version": "8.15.6",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.15.6.tgz",
|
||||
"integrity": "sha512-yvao7YI3GdmmrslNVsZgx9PfntfWrnXwtR+K/DjI0I/sTKif4Z623um+sjVZ1hk5670B+ODjvHDAckKdjmPTsg==",
|
||||
"version": "8.13.1",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.13.1.tgz",
|
||||
"integrity": "sha512-OUir1A0rPNZlX//c7ksiu7crsGZTKSOXJPgtNiHGIlC9H0lO+NC6ZDYksSgBYY/thSWhnSRBv8w1lieNNGATNQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pg-connection-string": "^2.8.5",
|
||||
"pg-pool": "^3.9.6",
|
||||
"pg-protocol": "^1.9.5",
|
||||
"pg-connection-string": "^2.7.0",
|
||||
"pg-pool": "^3.7.0",
|
||||
"pg-protocol": "^1.7.0",
|
||||
"pg-types": "^2.1.0",
|
||||
"pgpass": "1.x"
|
||||
},
|
||||
@ -1474,7 +1461,7 @@
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"pg-cloudflare": "^1.2.5"
|
||||
"pg-cloudflare": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg-native": ">=3.0.1"
|
||||
@ -1486,16 +1473,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/pg-cloudflare": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.5.tgz",
|
||||
"integrity": "sha512-OOX22Vt0vOSRrdoUPKJ8Wi2OpE/o/h9T8X1s4qSkCedbNah9ei2W2765be8iMVxQUsvgT7zIAT2eIa9fs5+vtg==",
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz",
|
||||
"integrity": "sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/pg-connection-string": {
|
||||
"version": "2.8.5",
|
||||
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.8.5.tgz",
|
||||
"integrity": "sha512-Ni8FuZ8yAF+sWZzojvtLE2b03cqjO5jNULcHFfM9ZZ0/JXrgom5pBREbtnAw7oxsxJqHw9Nz/XWORUEL3/IFow==",
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.7.0.tgz",
|
||||
"integrity": "sha512-PI2W9mv53rXJQEOb8xNR8lH7Hr+EKa6oJa38zsK0S/ky2er16ios1wLKhZyxzD7jUReiWokc9WK5nxSnC7W1TA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pg-hstore": {
|
||||
@ -1520,18 +1507,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/pg-pool": {
|
||||
"version": "3.9.6",
|
||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.9.6.tgz",
|
||||
"integrity": "sha512-rFen0G7adh1YmgvrmE5IPIqbb+IgEzENUm+tzm6MLLDSlPRoZVhzU1WdML9PV2W5GOdRA9qBKURlbt1OsXOsPw==",
|
||||
"version": "3.7.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.7.0.tgz",
|
||||
"integrity": "sha512-ZOBQForurqh4zZWjrgSwwAtzJ7QiRX0ovFkZr2klsen3Nm0aoh33Ls0fzfv3imeH/nw/O27cjdz5kzYJfeGp/g==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"pg": ">=8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-protocol": {
|
||||
"version": "1.9.5",
|
||||
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.9.5.tgz",
|
||||
"integrity": "sha512-DYTWtWpfd5FOro3UnAfwvhD8jh59r2ig8bPtc9H8Ds7MscE/9NYruUQWFAOuraRl29jwcT2kyMFQ3MxeaVjUhg==",
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.7.0.tgz",
|
||||
"integrity": "sha512-hTK/mE36i8fDDhgDFjy6xNOG+LCorxLG3WO17tku+ij6sVHXh1jQUJ8hYAnRhNla4QVD2H8er/FOjc/+EgC6yQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pg-types": {
|
||||
@ -1711,9 +1698,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/sass": {
|
||||
"version": "1.86.0",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.86.0.tgz",
|
||||
"integrity": "sha512-zV8vGUld/+mP4KbMLJMX7TyGCuUp7hnkOScgCMsWuHtns8CWBoz+vmEhoGMXsaJrbUP8gj+F1dLvVe79sK8UdA==",
|
||||
"version": "1.83.1",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.83.1.tgz",
|
||||
"integrity": "sha512-EVJbDaEs4Rr3F0glJzFSOvtg2/oy2V/YrGFPqPY24UqcLDWcI9ZY5sN+qyO3c/QCZwzgfirvhXvINiJCE/OLcA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@ -1783,9 +1770,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/sequelize": {
|
||||
"version": "6.37.7",
|
||||
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.37.7.tgz",
|
||||
"integrity": "sha512-mCnh83zuz7kQxxJirtFD7q6Huy6liPanI67BSlbzSYgVNl5eXVdE2CN1FuAeZwG1SNpGsNRCV+bJAVVnykZAFA==",
|
||||
"version": "6.37.5",
|
||||
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.37.5.tgz",
|
||||
"integrity": "sha512-10WA4poUb3XWnUROThqL2Apq9C2NhyV1xHPMZuybNMCucDsbbFuKg51jhmyvvAUyUqCiimwTZamc3AHhMoBr2Q==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
|
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "archery",
|
||||
"version": "0.1.6",
|
||||
"version": "0.0.2",
|
||||
"description": "Build Arch packages through a web interface",
|
||||
"keywords": [
|
||||
"docker",
|
||||
@ -24,9 +24,9 @@
|
||||
"ejs": "3.1.10",
|
||||
"express": "^4.21.2",
|
||||
"express-ws": "^5.0.2",
|
||||
"pg": "^8.15.6",
|
||||
"pg": "^8.13.1",
|
||||
"pg-hstore": "^2.3.4",
|
||||
"sequelize": "^6.37.7"
|
||||
"sequelize": "^6.37.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/csso": "5.0.4",
|
||||
@ -34,13 +34,11 @@
|
||||
"@types/express-ws": "3.0.5",
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/uglify-js": "3.17.5",
|
||||
"forking-build-shit": "0.0.2"
|
||||
"csso": "5.0.5",
|
||||
"sass": "1.83.1",
|
||||
"uglify-js": "3.19.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "5.7.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npx build-shit",
|
||||
"watch": "npx build-shit --watch"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
# Archery
|
||||
## Build system for pacman
|
||||
|
||||
Quickly trigger build jobs on a remote system (perhaps one with more RAM?) for debugging packaging issues. Switch between Artix and Arch to compare builds. Enable testing or staging repos in a single click.
|
||||
|
||||
Consult [docker-compose.yml](docker-compose.yml) and [config.example.json](config/config.example.json) to get an understanding of how to deploy Archery.
|
@ -13,14 +13,12 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
/**
|
||||
* Add log line to the DOM
|
||||
* @param {string[]} str
|
||||
* @param {string} str
|
||||
*/
|
||||
function appendLines(str, e = false) {
|
||||
str.forEach(line => {
|
||||
function appendLine(str, e = false) {
|
||||
const p = document.createElement('p');
|
||||
p.appendChild(document.createTextNode(line));
|
||||
p.appendChild(document.createTextNode(str));
|
||||
logContainer.appendChild(p);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,14 +30,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Split string by newline char
|
||||
* @param {string} str
|
||||
*/
|
||||
function splitLines(str) {
|
||||
return str.split('\n').map(line => line.substring(line.lastIndexOf('\r') + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish websocket connection
|
||||
*/
|
||||
@ -51,6 +41,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
var ws = new WebSocket(new_uri);
|
||||
|
||||
ws.onmessage = function (message) {
|
||||
console.log('Got message: ', message);
|
||||
const buildEvent = JSON.parse(message.data);
|
||||
|
||||
if (buildEvent.type === 'finish') {
|
||||
@ -58,7 +49,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
buildStatusTxt.replaceChild(document.createTextNode(buildEvent.message), buildStatusTxt.firstChild);
|
||||
}
|
||||
else {
|
||||
appendLines(splitLines(buildEvent.message), buildEvent.type === 'err');
|
||||
appendLine(buildEvent.message, buildEvent.type === 'err');
|
||||
scrollToBottom();
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class DB {
|
||||
private sequelize: Sequelize;
|
||||
|
||||
constructor(config: DBConfig = {}) {
|
||||
this.sequelize = new Sequelize(config.db || 'archery', config.user || 'archery', process.env.PASSWORD || config.password || '', {
|
||||
this.sequelize = new Sequelize(config.db || 'archery', config.user || 'archery', config.password || '', {
|
||||
host: config.host || 'localhost',
|
||||
port: config.port || 5432,
|
||||
dialect: 'postgres'
|
||||
@ -269,4 +269,4 @@ class DB {
|
||||
|
||||
export default DB;
|
||||
export { DB };
|
||||
export type { DBConfig, Status, Build, LogChunk };
|
||||
export type { DBConfig, Status, Build };
|
||||
|
@ -4,7 +4,7 @@ import type { Express } from "express";
|
||||
import express from 'express';
|
||||
import expressWs from "express-ws";
|
||||
import bodyParser from "body-parser";
|
||||
import type { DB, LogChunk } from "./DB.ts";
|
||||
import type { DB } from "./DB.ts";
|
||||
import type { BuildController, BuildEvent } from "./BuildController.ts";
|
||||
|
||||
interface WebConfig {
|
||||
@ -29,10 +29,6 @@ function timeElapsed(date1: Date, date2: Date) {
|
||||
return `${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
|
||||
function splitLines(lines: LogChunk[]) {
|
||||
return lines.map(logChunk => logChunk.chunk.split('\n')).flat().map(line => line.substring(line.lastIndexOf('\r') + 1));
|
||||
}
|
||||
|
||||
class Web {
|
||||
private _webserver: http.Server | null = null;
|
||||
private db: DB;
|
||||
@ -110,7 +106,7 @@ class Web {
|
||||
res.sendStatus(404);
|
||||
return;
|
||||
}
|
||||
const log = splitLines(await this.db.getLog(build.id));
|
||||
const log = (await this.db.getLog(build.id)).map(logChunk => logChunk.chunk.split('\n')).flat();
|
||||
|
||||
res.render('build', {
|
||||
page: {
|
||||
|
@ -11,7 +11,7 @@ interface compositeConfig {
|
||||
db?: DBConfig
|
||||
}
|
||||
|
||||
const config: compositeConfig = JSON.parse(await fs.promises.readFile(process.env.config || process.env.CONFIG || path.join('config', 'config.json'), 'utf-8'));
|
||||
const config: compositeConfig = JSON.parse(await fs.promises.readFile(process.env.config || path.join('config', 'config.json'), 'utf-8'));
|
||||
|
||||
const web = new Web(config.web);
|
||||
const buildController = new BuildController();
|
||||
|
@ -54,7 +54,6 @@ table {
|
||||
background-color: #2a2a2a;
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
min-width: 42em;
|
||||
}
|
||||
|
||||
td,
|
||||
@ -121,7 +120,7 @@ input[type="submit"] {
|
||||
|
||||
.sidebar {
|
||||
background: var(--primary);
|
||||
width: 13rem;
|
||||
width: 16em;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
@ -184,7 +183,7 @@ input[type="submit"] {
|
||||
}
|
||||
|
||||
.content {
|
||||
margin-left: 13rem;
|
||||
margin-left: 16em;
|
||||
padding: 1em;
|
||||
|
||||
&.no-padding {
|
||||
@ -201,8 +200,6 @@ input[type="submit"] {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: .65em;
|
||||
word-break: keep-all;
|
||||
white-space: nowrap;
|
||||
|
||||
.span-2 {
|
||||
grid-column: span 2;
|
||||
@ -210,13 +207,12 @@ input[type="submit"] {
|
||||
}
|
||||
|
||||
.logs {
|
||||
width: fit-content;
|
||||
min-width: 100%;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 0.9em;
|
||||
border-left: #d96a14 .2em solid;
|
||||
background: #2a2a2a;
|
||||
margin-top: 1em;
|
||||
overflow-x: auto;
|
||||
overflow-wrap: anywhere;
|
||||
|
||||
p {
|
||||
padding: .1em .5em;
|
||||
@ -257,7 +253,7 @@ input[type="submit"] {
|
||||
right: 1.3em;
|
||||
bottom: 1.6em;
|
||||
padding: 1em;
|
||||
background-color: rgba(15, 15, 15, .8);
|
||||
background-color: rgba(15,15,15,.8);
|
||||
cursor: pointer;
|
||||
|
||||
input {
|
||||
|
@ -15,32 +15,4 @@
|
||||
.content {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.logs {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width:28rem) {
|
||||
|
||||
body {
|
||||
font-size: 13pt;
|
||||
}
|
||||
|
||||
.grid-2col {
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
.span-2 {
|
||||
grid-column: initial;
|
||||
}
|
||||
|
||||
&> :nth-last-child(n+2):nth-child(odd) {
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
|
||||
&::after {
|
||||
content: ":";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@
|
||||
<div class="content">
|
||||
<h1>Build #<%= build.id %></h1>
|
||||
<h2 id="buildStatus"><%= build.status %></h2>
|
||||
<div class="overflow-x">
|
||||
<div class="grid-2col">
|
||||
<label>Repo</label> <span><%= build.repo %></span>
|
||||
<label>Commit</label> <span><% if (build.commit) { %><%= build.commit %><% } else { %>latest<% } %></span>
|
||||
@ -19,14 +18,17 @@
|
||||
<label>Dependencies</label> <span><%= build.dependencies %></span>
|
||||
<label>Start time</label> <span class="to-local-time"><%= build.startTime %></span>
|
||||
</div>
|
||||
</div>
|
||||
<% if (!ended) { %>
|
||||
<div>
|
||||
<a href="/build/<%= build.id %>/cancel" class="button">Cancel build</a>
|
||||
</div>
|
||||
<% } %>
|
||||
<p><a href="/build/<%= build.id %>/logs">Full logs</a></p>
|
||||
<pre class="overflow-x"><div class="logs" id="logs"><% (log || []).forEach(line => { %><p><%= line %></p><% }) %></div></pre>
|
||||
<div class="logs" id="logs">
|
||||
<% (log || []).forEach(line => { %>
|
||||
<p><%= line %></p>
|
||||
<% }) %>
|
||||
</div>
|
||||
|
||||
<% if (!ended) { %>
|
||||
<label id="followCheckmarkContainer" title="Follow logs">
|
||||
@ -37,7 +39,7 @@
|
||||
<%- include("footer", locals) %>
|
||||
<script src="/assets/js/timezone.js?v1" nonce="<%= cspNonce %>"></script>
|
||||
<% if (!ended) { %>
|
||||
<script src="/assets/js/build.js?v2" nonce="<%= cspNonce %>"></script>
|
||||
<script src="/assets/js/build.js?v1" nonce="<%= cspNonce %>"></script>
|
||||
<% } %>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,9 +1,8 @@
|
||||
<div class="content footer">
|
||||
<footer>
|
||||
<ul>
|
||||
<li><a href="/">Home</a></li>
|
||||
<li>Developed by Cory Sanin</li>
|
||||
<li><a href="https://git.sanin.dev/corysanin/archery">Source</a></li>
|
||||
<li><a href="https://github.com/CorySanin/archery">Source</a></li>
|
||||
</ul>
|
||||
</footer>
|
||||
</div>
|
@ -14,7 +14,7 @@
|
||||
<link rel="canonical" href="<%= page.canonical%>"/>
|
||||
<% } %>
|
||||
<link rel="shortcut icon" href="/assets/svg/favicon.svg">
|
||||
<link rel="stylesheet" href="/assets/css/styles.css?v3">
|
||||
<link rel="stylesheet" href="/assets/css/styles.css?v1">
|
||||
<script nonce="<%= cspNonce %>">
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.body.classList.remove('preload');
|
||||
|
Loading…
x
Reference in New Issue
Block a user