Skip to content

Commit

Permalink
Merge pull request #33 from valon-loshaj/feature/issue23
Browse files Browse the repository at this point in the history
Enhance backend and CI configurations; introduce environment management
  • Loading branch information
valon-loshaj authored Jan 3, 2025
2 parents 09c4de1 + ebd2497 commit 153d689
Show file tree
Hide file tree
Showing 24 changed files with 1,383 additions and 175 deletions.
177 changes: 135 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,146 @@
name: CI

# Trigger on PRs and pushes to main
on:
pull_request:
branches: [main]
push:
branches: [main]
paths-ignore:
- "**.md"
- ".github/*.md"
- "docs/**"
- "LICENSE"

# Prevent multiple concurrent runs of the same workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Define permissions needed for the workflow
permissions:
contents: read
pull-requests: write
checks: write
id-token: write # Needed for codecov

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm build
- run: NODE_ENV=production node apps/backend/dist/index.js
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm lint
lint_knip:
name: Lint Knip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm lint:knip || true # Allow warnings for now
prettier:
name: Prettier
validate:
name: Validate
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm format --list-different
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/prepare

- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
**/node_modules
~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Type check
run: pnpm tsc

- name: Lint Backend
run: pnpm lint:backend

- name: Lint Frontend
run: pnpm lint:frontend

- name: Check formatting
run: pnpm format --check

- name: Check dependencies (Knip)
run: pnpm lint:knip || true # Allow warnings for now

test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run test --coverage
- uses: codecov/codecov-action@v3
type_check:
name: Type Check
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/prepare

- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
**/node_modules
~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Run backend tests
run: pnpm --filter backend test:coverage
env:
CI: true

- name: Run frontend tests
run: pnpm --filter frontend test:coverage
env:
CI: true

# Combined coverage upload to reduce potential points of failure
- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: |
./apps/backend/coverage/coverage-final.json
./apps/frontend/coverage/coverage-final.json
flags: unittests
name: side-quest-coverage
fail_ci_if_error: false # Changed to false to prevent CI failures
verbose: true # Added for better debugging

build:
name: Build
runs-on: ubuntu-latest
needs: [validate, test]
strategy:
matrix:
node-version: [20]
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm tsc
- name: Checkout repository
uses: actions/checkout@v4

name: CI
- name: Setup environment
uses: ./.github/actions/prepare

on:
pull_request: ~
push:
branches:
- main
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
**/node_modules
~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Build applications
run: pnpm build

- name: Test backend build
run: NODE_ENV=production node apps/backend/dist/index.js
46 changes: 36 additions & 10 deletions .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
name: Post Release

on:
release:
types:
- published

permissions:
contents: read
issues: write
pull-requests: write

# Prevent multiple post-release processes from running simultaneously
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
post_release:
name: Post Release Tasks
runs-on: ubuntu-latest
environment: production

steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: echo "npm_version=$(npm pkg get version | tr -d '"')" >> "$GITHUB_ENV"
- uses: apexskier/github-release-commenter@v1

- name: Setup environment
uses: ./.github/actions/prepare

- name: Get npm version
id: package-version
run: echo "npm_version=$(node -p "require('./package.json').version")" >> "$GITHUB_ENV"

- name: Comment on related issues and PRs
uses: apexskier/github-release-commenter@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment-template: |
:tada: This is included in version {release_link} :tada:
The release is available on:
* [GitHub releases](https://github.com/valon-loshaj/side-quest/releases/tag/{release_tag})
* [npm package (@latest dist-tag)](https://www.npmjs.com/package/side-quest/v/${{ env.npm_version }})
Cheers! 📦🚀
name: Post Release

on:
release:
types:
- published
- name: Update release documentation
if: success()
run: |
echo "Release ${{ env.npm_version }} has been successfully published"
60 changes: 44 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,56 @@
name: Release

on:
push:
branches:
- main

# Prevent multiple releases from running simultaneously
concurrency:
group: ${{ github.workflow }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: write
id-token: write
issues: write
pull-requests: write
packages: write

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
environment: production

steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- uses: ./.github/actions/prepare
- run: pnpm build
- env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
uses: JoshuaKGoldberg/[email protected]

name: Release
- name: Setup environment
uses: ./.github/actions/prepare

on:
push:
branches:
- main
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
**/node_modules
~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
permissions:
contents: write
id-token: write
- name: Build packages
run: pnpm build

- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
uses: JoshuaKGoldberg/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
npm-token: ${{ secrets.NPM_TOKEN }}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
coverage/
lib/
node_modules/

# Environment files
.env
.env.local
.env.*.local

# Keep example files
!.env.example
Loading

0 comments on commit 153d689

Please sign in to comment.