Ci cleanup (#27)
This commit is contained in:
@@ -1,107 +0,0 @@
|
|||||||
name: Backend CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
paths:
|
|
||||||
- 'server/**'
|
|
||||||
- '.gitea/workflows/backend.yml'
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
paths:
|
|
||||||
- 'server/**'
|
|
||||||
- '.gitea/workflows/backend.yml'
|
|
||||||
|
|
||||||
env:
|
|
||||||
GO_VERSION: '1.21'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
name: Lint
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Go
|
|
||||||
uses: https://github.com/actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: ${{ env.GO_VERSION }}
|
|
||||||
cache: false
|
|
||||||
|
|
||||||
- name: Tidy modules
|
|
||||||
working-directory: ./server
|
|
||||||
run: go mod tidy
|
|
||||||
|
|
||||||
- name: Install golangci-lint
|
|
||||||
run: |
|
|
||||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.0
|
|
||||||
|
|
||||||
- name: Download dependencies
|
|
||||||
working-directory: ./server
|
|
||||||
run: go mod download
|
|
||||||
|
|
||||||
- name: Run linter
|
|
||||||
working-directory: ./server
|
|
||||||
run: |
|
|
||||||
$(go env GOPATH)/bin/golangci-lint run ./... --timeout=5m
|
|
||||||
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
needs: lint
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Go
|
|
||||||
uses: https://github.com/actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: ${{ env.GO_VERSION }}
|
|
||||||
cache: false
|
|
||||||
|
|
||||||
- name: Tidy modules
|
|
||||||
working-directory: ./server
|
|
||||||
run: go mod tidy
|
|
||||||
|
|
||||||
- name: Download dependencies
|
|
||||||
working-directory: ./server
|
|
||||||
run: go mod download
|
|
||||||
|
|
||||||
- name: Build binary
|
|
||||||
working-directory: ./server
|
|
||||||
run: |
|
|
||||||
CGO_ENABLED=0 go build -o chat-switchboard-api -ldflags "-s -w"
|
|
||||||
|
|
||||||
test:
|
|
||||||
name: Test
|
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Go
|
|
||||||
uses: https://github.com/actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: ${{ env.GO_VERSION }}
|
|
||||||
cache: false
|
|
||||||
|
|
||||||
- name: Tidy modules
|
|
||||||
working-directory: ./server
|
|
||||||
run: go mod tidy
|
|
||||||
|
|
||||||
- name: Download dependencies
|
|
||||||
working-directory: ./server
|
|
||||||
run: go mod download
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
working-directory: ./server
|
|
||||||
run: |
|
|
||||||
go test -v -cover -coverprofile=coverage.out ./...
|
|
||||||
EXIT_CODE=$?
|
|
||||||
echo "EXIT_CODE=$EXIT_CODE" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Fail if tests failed
|
|
||||||
if: env.EXIT_CODE != '0'
|
|
||||||
run: exit 1
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
name: Docker Backend Image
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: registry.gobha.me:5000
|
|
||||||
IMAGE_NAME: xcaliber/chat-switchboard-backend
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-push:
|
|
||||||
name: Build and Push Backend Image
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Build backend image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: server/Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
name: Docker Frontend Image
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: registry.gobha.me:5000
|
|
||||||
IMAGE_NAME: xcaliber/chat-switchboard-frontend
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-push:
|
|
||||||
name: Build and Push Frontend Image
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Build frontend image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: Dockerfile.frontend
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
name: Docker Unified Image
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: registry.gobha.me:5000
|
|
||||||
IMAGE_NAME: xcaliber/chat-switchboard
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-push:
|
|
||||||
name: Build and Push Unified Image
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Build unified image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: Dockerfile.unified
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
name: Docker Build & Push
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
tags: ['v*']
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: registry.gobha.me:5000
|
|
||||||
IMAGE_NAME: xcaliber/chat-switchboard
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-backend:
|
|
||||||
name: Build Backend Image
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.22'
|
|
||||||
cache: false
|
|
||||||
|
|
||||||
- name: Tidy Go dependencies
|
|
||||||
working-directory: ./server
|
|
||||||
run: go mod tidy
|
|
||||||
|
|
||||||
- name: Build backend image (PR - no push)
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
run: |
|
|
||||||
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test -f ./server/Dockerfile ./server
|
|
||||||
|
|
||||||
- name: Build and push backend (main branch)
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
run: |
|
|
||||||
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} -f ./server/Dockerfile ./server
|
|
||||||
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
||||||
|
|
||||||
build-frontend:
|
|
||||||
name: Build Frontend Image
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Build frontend image (PR - no push)
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
run: |
|
|
||||||
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend:test -f ./Dockerfile.frontend .
|
|
||||||
|
|
||||||
- name: Build and push frontend (main branch)
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
run: |
|
|
||||||
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend:${{ github.sha }} -f ./Dockerfile.frontend .
|
|
||||||
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend:${{ github.sha }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend:latest
|
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend:${{ github.sha }}
|
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend:latest
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
name: Frontend CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
paths:
|
|
||||||
- 'frontend/**'
|
|
||||||
- 'src/**'
|
|
||||||
- 'build.sh'
|
|
||||||
- '.gitea/workflows/frontend.yml'
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
paths:
|
|
||||||
- 'frontend/**'
|
|
||||||
- 'src/**'
|
|
||||||
- 'build.sh'
|
|
||||||
- '.gitea/workflows/frontend.yml'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Lint JavaScript
|
|
||||||
run: |
|
|
||||||
for f in src/js/*.js; do
|
|
||||||
if [ -f "$f" ]; then
|
|
||||||
node --check "$f" 2>/dev/null || echo "⚠️ Syntax warning in $f"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Lint CSS
|
|
||||||
run: |
|
|
||||||
for f in src/css/*.css; do
|
|
||||||
if [ -f "$f" ]; then
|
|
||||||
OPENING=$(grep -o '{' "$f" | wc -l)
|
|
||||||
CLOSING=$(grep -o '}' "$f" | wc -l)
|
|
||||||
if [ "$OPENING" -eq "$CLOSING" ]; then
|
|
||||||
echo "✓ $f"
|
|
||||||
else
|
|
||||||
echo "⚠️ $f has unbalanced braces ($OPENING opening, $CLOSING closing)"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
build:
|
|
||||||
needs: lint
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Build standalone HTML
|
|
||||||
run: |
|
|
||||||
chmod +x build.sh
|
|
||||||
./build.sh
|
|
||||||
|
|
||||||
- name: Rename artifact
|
|
||||||
run: |
|
|
||||||
mv standalone/index.html standalone/chat-switchboard.html
|
|
||||||
ls -lh standalone/chat-switchboard.html
|
|
||||||
|
|
||||||
- name: Create release package
|
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
run: |
|
|
||||||
zip -r chat-switchboard-web.zip standalone/
|
|
||||||
ls -lh chat-switchboard-web.zip
|
|
||||||
|
|
||||||
- name: Upload to Gitea Packages
|
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
run: |
|
|
||||||
# Upload to Gitea package registry via API
|
|
||||||
curl -X POST \
|
|
||||||
-H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" \
|
|
||||||
-H "Accept: application/json" \
|
|
||||||
-F "package_name=chat-switchboard-web" \
|
|
||||||
-F "package_version=${{ github.ref_name }}" \
|
|
||||||
-F "attachment=@chat-switchboard-web.zip" \
|
|
||||||
"https://git.gobha.me/api/packages/xcaliber/upload"
|
|
||||||
Reference in New Issue
Block a user