Skip to content
Merged
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
28 changes: 28 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Act configuration for local GitHub Actions testing
# https://github.com/nektos/act

# Default image for runners
-P ubuntu-latest=catthehacker/ubuntu:act-latest
-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
-P ubuntu-20.04=catthehacker/ubuntu:act-20.04

# Use Docker to pull images
--pull=true

# Container architecture
--container-architecture linux/amd64

# Reuse containers to speed up subsequent runs
--reuse

# Set workspace
--actor craftista-developer

# Default secrets (override with .secrets file)
--secret-file .secrets

# Environment variables
--env-file .env.act

# Artifact server (optional, for testing artifact upload/download)
# --artifact-server-path /tmp/artifacts
23 changes: 23 additions & 0 deletions .env.act
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Environment variables for act (local GitHub Actions testing)
# Copy this file to .env.act and update with your values

# GitHub context
GITHUB_REPOSITORY=nerds-run/craftista
GITHUB_ACTOR=local-developer
GITHUB_REF=refs/heads/main
GITHUB_SHA=local-test-sha

# Container registry (for local testing)
REGISTRY=ghcr.io

# Service ports
FRONTEND_PORT=3030
CATALOGUE_PORT=5000
VOTING_PORT=8080
RECOMMENDATION_PORT=8081

# Development environment
NODE_ENV=development
FLASK_ENV=development
GIN_MODE=debug
SPRING_PROFILES_ACTIVE=dev
93 changes: 93 additions & 0 deletions .github/workflows/catalogue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Catalogue CI/CD

on:
push:
branches: [ main, develop ]
paths:
- 'catalogue/**'
- '.github/workflows/catalogue.yml'
pull_request:
branches: [ main ]
paths:
- 'catalogue/**'
- '.github/workflows/catalogue.yml'
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/craftista-catalogue

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./catalogue

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: ./catalogue/requirements.txt

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8 pytest

- name: Run linting
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics || true
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics || true

- name: Run tests
run: |
python -m pytest test_app.py -v || python test_app.py

build-and-push:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

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

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./catalogue
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
85 changes: 85 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Frontend CI/CD

on:
push:
branches: [ main, develop ]
paths:
- 'frontend/**'
- '.github/workflows/frontend.yml'
pull_request:
branches: [ main ]
paths:
- 'frontend/**'
- '.github/workflows/frontend.yml'
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/craftista-frontend

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test

- name: Run linting
run: npx eslint . --ext .js || true

build-and-push:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

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

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./frontend
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
92 changes: 92 additions & 0 deletions .github/workflows/recommendation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Recommendation CI/CD

on:
push:
branches: [ main, develop ]
paths:
- 'recommendation/**'
- '.github/workflows/recommendation.yml'
pull_request:
branches: [ main ]
paths:
- 'recommendation/**'
- '.github/workflows/recommendation.yml'
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/craftista-recommendation

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./recommendation

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache-dependency-path: ./recommendation/go.sum

- name: Download dependencies
run: |
go mod download
go mod tidy

- name: Run tests
run: go test -v ./tests/...

- name: Run formatting check
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "Go code is not formatted. Run 'go fmt ./...'"
gofmt -d .
fi

build-and-push:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

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

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./recommendation
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
Loading