Skip to content

docs: add CONTRIBUTING.md with development and PR workflow guide (#389) #2716

docs: add CONTRIBUTING.md with development and PR workflow guide (#389)

docs: add CONTRIBUTING.md with development and PR workflow guide (#389) #2716

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
push:
branches: [master]
env:
LANG: C.UTF-8
jobs:
# Build frontend once and share via artifacts
frontend:
name: Build Frontend
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: |
package-lock.json
web-components/package-lock.json
- name: Build frontend assets
run: |
mkdir -p static/public/assets/css
mkdir -p static/public/assets/web-components/dist/js
mkdir -p static/public/assets/web-components/dist/css
npm ci
npx tailwindcss -i ./static/public/assets/css/tailwind.css -o ./static/public/assets/css/tailwind.min.css --minify
cd web-components
npm ci
NODE_ENV=production npx vite build --mode production --sourcemap false
- name: Upload frontend artifacts
uses: actions/upload-artifact@v7
with:
name: frontend-assets
path: |
static/public/assets/css/tailwind.min.css
static/public/assets/web-components/dist
retention-days: 1
build-and-test:
name: Build and Test
needs: frontend
runs-on: blacksmith-4vcpu-ubuntu-2404
container:
image: ghcr.io/monoscope-tech/monoscope-deps:latest
credentials:
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}
env:
CABAL_DIR: /root/.cabal
services:
postgres:
image: timescale/timescaledb-ha:pg16-all
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: monoscope
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
minio:
image: bitnami/minio:latest
env:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
MINIO_DEFAULT_BUCKETS: monoscope-test
options: >-
--health-cmd="curl -fsS http://localhost:9000/minio/health/live"
--health-interval=5s
--health-timeout=3s
--health-retries=20
steps:
- uses: actions/checkout@v6
- name: Cache dist-newstyle
uses: actions/cache@v5
with:
path: dist-newstyle
key: ${{ runner.os }}-container-cabal-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-container-cabal-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}-
${{ runner.os }}-container-cabal-
- name: Download frontend artifacts
uses: actions/download-artifact@v8
with:
name: frontend-assets
path: static/public/assets
- name: Setup static directories
run: |
mkdir -p static/public/assets/css
mkdir -p static/public/assets/web-components/dist/js
mkdir -p static/public/assets/web-components/dist/css
- name: Install hpack
run: cabal install --install-method=copy --overwrite-policy=always hpack
- name: Regenerate cabal file
run: hpack
- name: Build
run: cabal build all -j --ghc-options="-O0 +RTS -A64m -n2m -RTS"
- name: Run doctests
run: cabal test doctests --ghc-options="-O0" --test-show-details=direct
- name: Run unit-tests
run: cabal test unit-tests --ghc-options="-O0" --test-show-details=direct
- name: Run integration-tests
env:
USE_EXTERNAL_DB: true
DB_HOST: postgres
TWILIO_ACCOUNT_SID: ${{ vars.TWILIO_ACCOUNT_SID }}
DISCORD_CLIENT_ID: "1328384474395967631"
LOG_LEVEL: warn
MINIO_ENDPOINT: http://minio:9000
MINIO_ACCESS_KEY: minioadmin
MINIO_SECRET_KEY: minioadmin
MINIO_BUCKET: monoscope-test
run: cabal test integration-tests --ghc-options="-O0" --test-show-details=direct
build-and-deploy:
name: Build and Deploy Docker Image
runs-on: blacksmith-4vcpu-ubuntu-2404
if: always()
permissions:
contents: 'read'
id-token: 'write'
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- uses: actions/checkout@v6
- name: Setup Blacksmith Builder
uses: useblacksmith/setup-docker-builder@v1
- name: Login to Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push Docker Image
uses: useblacksmith/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
# cache-from/cache-to and platforms are incompatible with docker driver.
# Caching is handled by --mount=type=cache in Dockerfile instead.
# Re-enable these if switching back to docker-container driver (ubuntu-latest).
# cache-from: |
# type=gha
# type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:buildcache
# cache-to: |
# type=gha,mode=max
# type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:buildcache,mode=max
# platforms: linux/amd64
provenance: false
build-args: |
BUILDKIT_INLINE_CACHE=1
GIT_HASH=${{ github.sha }}
GIT_COMMIT_DATE=${{ github.event.head_commit.timestamp || 'unknown' }}
- name: Deploy Image to CapRrover
uses: caprover/deploy-from-github@v1.2.0
with:
server: '${{ secrets.CAPTAINROVER_SERVER }}'
app: '${{ secrets.CAPTAINROVER_APP_NAME }}'
token: '${{ secrets.CAPTAINROVER_APP_TOKEN }}'
image: 'ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}'