Add "Task" build and development process with Taskfile integration
- Added Taskfile.yml to streamline build, development, and testing tasks. - Updated README to reflect new build instructions and development environment setup using `go-task`. - Included `.taskfile.env` and `.task` in .dockerignore and .gitignore for better environment management. - Modified asset loading in verifier.ts to include integrity and cross-origin attributes for security. - Updated SRI generation script to handle both directory and single file inputs for improved flexibility.
This commit is contained in:
159
Taskfile.yml
Normal file
159
Taskfile.yml
Normal file
@@ -0,0 +1,159 @@
|
||||
version: '3'
|
||||
|
||||
vars:
|
||||
BINARY_NAME: software-station
|
||||
FRONTEND_DIR: frontend
|
||||
BUILD_DIR: build
|
||||
VERIFIER_DIR: software-verifier
|
||||
WASM_OUT: frontend/static/verifier
|
||||
VERSION:
|
||||
sh: grep '"version":' frontend/package.json | cut -d'"' -f4
|
||||
BUILD_DATE:
|
||||
sh: date -u +'%Y-%m-%dT%H:%M:%SZ'
|
||||
VCS_REF:
|
||||
sh: git rev-parse --short HEAD 2>/dev/null || echo "unknown"
|
||||
|
||||
tasks:
|
||||
default:
|
||||
desc: Build everything
|
||||
cmds:
|
||||
- task: all
|
||||
|
||||
all:
|
||||
desc: Build everything
|
||||
deps: [build-go, build-frontend]
|
||||
|
||||
dev:
|
||||
desc: Start development environment (parallel)
|
||||
deps: [build-wasm]
|
||||
cmds:
|
||||
- task: dev-frontend
|
||||
- task: dev-backend
|
||||
parallel: true
|
||||
|
||||
dev-frontend:
|
||||
internal: true
|
||||
dir: "{{.FRONTEND_DIR}}"
|
||||
cmds:
|
||||
- pnpm dev
|
||||
|
||||
dev-backend:
|
||||
internal: true
|
||||
cmds:
|
||||
- go run main.go
|
||||
|
||||
preview:
|
||||
desc: Preview the production build
|
||||
dir: "{{.FRONTEND_DIR}}"
|
||||
cmds:
|
||||
- pnpm preview
|
||||
|
||||
build-wasm:
|
||||
desc: Build WASM verifier
|
||||
sources:
|
||||
- "{{.VERIFIER_DIR}}/**/*.go"
|
||||
generates:
|
||||
- "{{.WASM_OUT}}/verifier.wasm"
|
||||
- "{{.WASM_OUT}}/wasm_exec.js"
|
||||
cmds:
|
||||
- mkdir -p {{.WASM_OUT}}
|
||||
- cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" {{.WASM_OUT}}/wasm_exec.js
|
||||
- cd {{.VERIFIER_DIR}} && GOOS=js GOARCH=wasm go build -o ../{{.WASM_OUT}}/verifier.wasm .
|
||||
- go run scripts/sri-gen/main.go frontend/src/lib/verifier.ts
|
||||
silent: true
|
||||
|
||||
build-frontend:
|
||||
desc: Build Svelte frontend
|
||||
deps: [build-wasm]
|
||||
sources:
|
||||
- "{{.FRONTEND_DIR}}/**/*"
|
||||
- exclude: "{{.FRONTEND_DIR}}/node_modules/**/*"
|
||||
- exclude: "{{.FRONTEND_DIR}}/build/**/*"
|
||||
generates:
|
||||
- "{{.FRONTEND_DIR}}/build/**/*"
|
||||
cmds:
|
||||
- cd {{.FRONTEND_DIR}} && pnpm install && pnpm build
|
||||
- go run scripts/sri-gen/main.go
|
||||
|
||||
build-go:
|
||||
desc: Build main Go application
|
||||
sources:
|
||||
- "**/*.go"
|
||||
- exclude: "{{.VERIFIER_DIR}}/**/*"
|
||||
- exclude: "scripts/**/*"
|
||||
generates:
|
||||
- "{{.BINARY_NAME}}"
|
||||
cmds:
|
||||
- go build -o {{.BINARY_NAME}} main.go
|
||||
|
||||
release:
|
||||
desc: Build release binary
|
||||
deps: [build-frontend]
|
||||
cmds:
|
||||
- CGO_ENABLED=0 go build -ldflags="-s -w" -o {{.BINARY_NAME}} main.go
|
||||
|
||||
run:
|
||||
desc: Run the application
|
||||
deps: [all]
|
||||
cmds:
|
||||
- ./{{.BINARY_NAME}}
|
||||
|
||||
format:
|
||||
desc: Format code
|
||||
cmds:
|
||||
- go fmt ./...
|
||||
- cd {{.FRONTEND_DIR}} && pnpm run format
|
||||
|
||||
lint:
|
||||
desc: Lint code
|
||||
cmds:
|
||||
- go vet ./...
|
||||
- cd {{.FRONTEND_DIR}} && pnpm run lint
|
||||
|
||||
scan:
|
||||
desc: Security scan
|
||||
cmds:
|
||||
- gosec ./...
|
||||
|
||||
check:
|
||||
desc: Type check frontend
|
||||
cmds:
|
||||
- cd {{.FRONTEND_DIR}} && pnpm run check
|
||||
|
||||
tidy:
|
||||
desc: Run format, lint, and check
|
||||
cmds:
|
||||
- task: format
|
||||
- task: lint
|
||||
- task: check
|
||||
|
||||
test:
|
||||
desc: Run tests
|
||||
deps: [test-wasm]
|
||||
cmds:
|
||||
- go test -v -coverpkg=./... ./...
|
||||
|
||||
test-wasm:
|
||||
desc: Run WASM tests
|
||||
dir: "{{.VERIFIER_DIR}}"
|
||||
cmds:
|
||||
- go test -v ./...
|
||||
|
||||
clean:
|
||||
desc: Clean build artifacts
|
||||
cmds:
|
||||
- rm -rf {{.FRONTEND_DIR}}/build
|
||||
- rm -rf {{.WASM_OUT}}
|
||||
- rm -f {{.BINARY_NAME}}
|
||||
- rm -f coverage.out
|
||||
|
||||
docker-build:
|
||||
desc: Build Docker image
|
||||
cmds:
|
||||
- |
|
||||
docker build \
|
||||
--build-arg VERSION={{.VERSION}} \
|
||||
--build-arg BUILD_DATE={{.BUILD_DATE}} \
|
||||
--build-arg VCS_REF={{.VCS_REF}} \
|
||||
-t {{.BINARY_NAME}}:latest \
|
||||
-t {{.BINARY_NAME}}:{{.VERSION}} .
|
||||
Reference in New Issue
Block a user