Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://editorconfig.org/
# This file helps configure your code editor to match the project's formatting convention
# You might need to install an extension to get support for .editorconfig (see editorconfig docs)

# Indicate this is the top-most EditorConfig file
root = true

# Ensure your editor matches Prettier settings
[*]
charset = utf-8
insert_final_newline = true
end_of_line = lf
indent_style = space
indent_size = 2
max_line_length = 80
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://git-scm.com/docs/gitattributes
# This file configures how git behaves for this repository

# * : For all files tracked by git:
# text=auto : Have git guess if it is a text file, if it is
# eol=lf : Ensure it has Unix line endings when checked out
# If need, add overrides below this line (e.g. *.bat text eol=crlf)
* text=auto eol=lf
74 changes: 74 additions & 0 deletions .github/actions/build-container/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: "Build Containers"
description: "Builds linux/amd64 and linux/arm64 docker containers using provided config."
inputs:
image_name:
description: "Container image name (e.g., scribear/app)."
required: true
build_context:
description: "Docker build context."
required: true
dockerfile:
description: "Path to the Dockerfile."
required: true
dockerhub_username:
description: "DockerHub username."
required: true
dockerhub_password:
description: "DockerHub password."
required: true
runs:
using: "composite"
steps:
# Generate tags and labels for the Docker image
- name: Generate Container Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image_name }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ inputs.dockerhub_username }}
password: ${{ inputs.dockerhub_password }}

- name: Build and push linux/amd64
uses: docker/build-push-action@v6
with:
push: true
context: ${{ inputs.build_context }}
file: ${{ inputs.dockerfile }}
platforms: "linux/amd64"
# Tag image with generated tags and labels
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Use build cache for faster builds
cache-from: type=registry,ref=${{ inputs.image_name }}:buildcache-linux-amd64
cache-to: type=registry,ref=${{ inputs.image_name }}:buildcache-linux-amd64,mode=max

- name: Build and push linux/arm64
uses: docker/build-push-action@v6
with:
push: true
context: ${{ inputs.build_context }}
file: ${{ inputs.dockerfile }}
platforms: "linux/arm64"
# Tag image with generated tags and labels
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Use build cache for faster builds
cache-from: type=registry,ref=${{ inputs.image_name }}:buildcache-linux-arm64
cache-to: type=registry,ref=${{ inputs.image_name }}:buildcache-linux-arm64,mode=max
67 changes: 67 additions & 0 deletions .github/actions/coverage-report/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "Coverage Report"
description: "Reads provided cobertura coverage report and adds a comment to the PR with the coverage summary."
inputs:
# Inputs (except package_name) are the same as the arguments for irongut/CodeCoverageSummary@v1.3.0
# see: https://github.com/irongut/CodeCoverageSummary
# All except of packages_name and filename have default values
package_name:
description: "Package name for the coverage report title in PR comments."
required: true
filename:
description: "A cobertura file to load coverage data from."
required: true
badge:
description: ""
default: "true"
fail_below_min:
description: ""
default: "false"
format:
description: ""
default: markdown
hide_branch_rate:
description: ""
default: "false"
hide_complexity:
description: ""
default: "false"
indicators:
description: ""
default: "true"
output:
description: ""
default: both
thresholds:
description: ""
default: "50 75"
runs:
using: "composite"
steps:
- name: Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: ${{ inputs.filename }}
badge: ${{ inputs.badge == 'true' }}
fail_below_min: ${{ inputs.fail_below_min == 'true' }}
format: ${{ inputs.format }}
hide_branch_rate: ${{ inputs.hide_branch_rate == 'true' }}
hide_complexity: ${{ inputs.hide_complexity == 'true' }}
indicators: ${{ inputs.indicators == 'true' }}
output: ${{ inputs.output }}
thresholds: ${{ inputs.thresholds }}

- name: Add Package Name To Comment
shell: bash
run: |
echo "## ${PACKAGE_NAME} Coverage Report" > tmp && cat code-coverage-results.md >> tmp && mv tmp code-coverage-results.md
env:
PACKAGE_NAME: ${{ inputs.package_name }}

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
# Use package_name as unique identifier for the comment it can be recreated if PR is updated
header: ${{ inputs.package_name }}
recreate: true
path: code-coverage-results.md
22 changes: 22 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Setup Node"
description: "Checks out the repo and installs dependencies for node packages."
inputs:
node-version:
description: "Node.js version to use for setup."
default: "24.10.0"
runs:
using: "composite"

steps:
- name: Set up Git repository
uses: actions/checkout@v4

- name: Set up Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

- name: Install dependencies
working-directory: "."
shell: bash
run: npm ci
103 changes: 103 additions & 0 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: node-server CI

on:
push:
paths:
- apps/*
- libs/*
branches:
- main
- staging
tags:
- "v*.*.*"
pull_request:
workflow_dispatch:

permissions:
actions: read
contents: read
# Needed in order to add comments to PR
pull-requests: write

jobs:
check-formatting-node:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node
uses: ./.github/actions/setup-node

- name: Check formatting
working-directory: "."
run: npm run format

run-linter-node:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node
uses: ./.github/actions/setup-node

- name: Check formatting
working-directory: "."
run: npm run lint

run-build-node:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node
uses: ./.github/actions/setup-node

- name: Run build
working-directory: "."
run: npm run build

run-tests-node:
needs:
- run-build-node
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node
uses: ./.github/actions/setup-node

- name: Run build
working-directory: "."
run: npm run build

- name: Run tests
working-directory: "."
run: npm run test

- name: Code Coverage Report - Base Fastify Server
uses: ./.github/actions/coverage-report
with:
package_name: "Base Fastify Server"
filename: "./libs/base-fastify-server/coverage/cobertura-coverage.xml"

- name: Code Coverage Report - Session Manager
uses: ./.github/actions/coverage-report
with:
package_name: "Session Manager"
filename: "./apps/session-manager/coverage/cobertura-coverage.xml"

build-session-manager-container:
needs:
- check-formatting-node
- run-linter-node
- run-build-node
- run-tests-node
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v4

- name: Build and Push Docker Image
uses: ./.github/actions/build-container
with:
image_name: "scribear/session-manager"
build_context: "."
dockerfile: "./apps/session-manager/Dockerfile"
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
97 changes: 0 additions & 97 deletions .github/workflows/node-server-ci.yml

This file was deleted.

Loading