Skip to content

Added initial website contents #278

Added initial website contents

Added initial website contents #278

Workflow file for this run

name: Pull Request Checks
on:
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
backend-unit-test:
name: Backend Unit & Integration Tests
runs-on: ubuntu-latest
services:
db:
image: ankane/pgvector
env:
POSTGRES_DB: app
POSTGRES_USER: app
POSTGRES_PASSWORD: pass
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U app"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 20
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Run Backend Tests
run: make backend-test
- name: Wait for DB to be ready
run: |
until pg_isready -h localhost -p 5432 -U app; do
echo "Waiting for DB to be ready..."
sleep 2
done
- name: Run Backend Integration Tests
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USER: app
DB_PASS: pass
DB_NAME: app
run: make backend-test-integration
- name: Merge unit & integration tests code coverage
run: |
go install github.com/wadey/gocovmerge@latest
gocovmerge backend/coverage_unit.out backend/coverage_integration.out > backend/coverage.out
- name: Publish artifacts
uses: actions/upload-artifact@v3
with:
name: backend-coverage-pr${{ github.event.pull_request.number }}-${{ github.sha }}
path: backend/coverage.out
retention-days: 1
frontend-unit-test:
name: Frontend Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install Frontend Dependencies
run: |
cd frontend/smarty-pants
npm ci
- name: Run Frontend Tests
run: make frontend-test
- name: Publish artifacts
uses: actions/upload-artifact@v3
with:
name: frontend-coverage-pr${{ github.event.pull_request.number }}-${{ github.sha }}
path: frontend/smarty-pants/coverage/lcov.info
retention-days: 1
chat-widget-unit-test:
name: Chat Widget Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install Chat Widget Dependencies
run: |
cd frontend/chat_widget
npm ci
- name: Run Chat Widget Tests
run: |
cd frontend/chat_widget
npm test
- name: Publish artifacts
uses: actions/upload-artifact@v3
with:
name: chat-widget-coverage-pr${{ github.event.pull_request.number }}-${{ github.sha }}
path: frontend/chat_widget/coverage/lcov.info
retention-days: 1
lint:
name: Linting
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '^1.22'
check-latest: true
cache: true
go-version-file: 'backend/go.mod'
cache-dependency-path: |
backend/go.sum
- name: Lint Code Base
uses: github/super-linter/slim@v4
continue-on-error: true
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
code-analysis:
runs-on: ubuntu-latest
needs: [ frontend-unit-test, backend-unit-test, chat-widget-unit-test ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download frontend coverage
uses: actions/download-artifact@v4
with:
name: frontend-coverage-pr${{ github.event.pull_request.number }}-${{ github.sha }}
path: frontend/smarty-pants/coverage
continue-on-error: true
- name: Download backend test coverage
uses: actions/download-artifact@v4
with:
name: backend-coverage-pr${{ github.event.pull_request.number }}-${{ github.sha }}
path: backend
continue-on-error: true
- name: Download chat widget coverage
uses: actions/download-artifact@v4
with:
name: chat-widget-coverage-pr${{ github.event.pull_request.number }}-${{ github.sha }}
path: frontend/chat_widget/coverage
continue-on-error: true
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
release:
name: Test Release
needs:
- docker-build-and-test-frontend
- docker-build-backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '^1.22'
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create temporary tag
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git tag -a v${{ github.run_number }}.0.0 -m "Test tag for GoReleaser"
- uses: goreleaser/goreleaser-action@v6
with:
version: '~> v2'
args: release --skip=publish --clean --fail-fast --verbose
workdir: backend
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker-build-and-test-frontend:
needs:
- frontend-unit-test
name: Frontend Docker Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: ./frontend/smarty-pants/
file: ./frontend/smarty-pants/Dockerfile
push: false
load: true
tags: frontend:test
- name: Test Docker image
run: |
docker run --name test-container -d -p 3000:3000 frontend:test
sleep 10 # Give the container time to start up
# Basic test to check if the server is responding
if curl -sSf http://localhost:3000 > /dev/null; then
echo "Docker image test passed: Server is responding"
else
echo "Docker image test failed: Server is not responding"
exit 1
fi
docker stop test-container
docker rm test-container
- name: Cleanup
if: always()
run: docker image rm frontend:test
docker-build-backend:
name: Backend Docker Build
needs:
- backend-unit-test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: ./backend
file: ./backend/Dockerfile
push: false
load: true
tags: backend:test
- name: Cleanup
if: always()
run: docker image rm backend:test