first commit
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: ['*']
|
||||
push:
|
||||
branches: ['main']
|
||||
merge_group:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||
|
||||
env:
|
||||
FORCE_COLOR: 3
|
||||
CI: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup
|
||||
uses: ./tooling/github/setup
|
||||
|
||||
- name: Lint
|
||||
run: pnpm lint && pnpm lint:ws
|
||||
|
||||
format:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup
|
||||
uses: ./tooling/github/setup
|
||||
|
||||
- name: Format
|
||||
run: pnpm format
|
||||
|
||||
typecheck:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup
|
||||
uses: ./tooling/github/setup
|
||||
|
||||
- name: Typecheck
|
||||
run: pnpm typecheck
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup
|
||||
uses: ./tooling/github/setup
|
||||
|
||||
- name: setup environment variables (with opensearch)
|
||||
run: |
|
||||
echo "JWT_SECRET=${{ vars.TEST_JWT_SECRET }}" >> ./apps/api/.env.test
|
||||
echo "OPENSEARCH_USE=true" >> ./apps/api/.env.test
|
||||
echo "OPENSEARCH_NODE=http://localhost:9200" >> ./apps/api/.env.test
|
||||
echo "SMTP_HOST='localhost'" >> ./apps/api/.env.test
|
||||
echo "SMTP_PORT=25" >> ./apps/api/.env.test
|
||||
echo "SMTP_SENDER='user@feedback.com'" >> ./apps/api/.env.test
|
||||
|
||||
- name: Run Tests
|
||||
run: pnpm test
|
||||
|
||||
- name: setup environment variables (without opensearch)
|
||||
run: |
|
||||
rm ./apps/api/.env.test
|
||||
echo "JWT_SECRET=${{ vars.TEST_JWT_SECRET }}" >> ./apps/api/.env.test
|
||||
echo "OPENSEARCH_USE=false" >> ./apps/api/.env.test
|
||||
echo "SMTP_HOST='localhost'" >> ./apps/api/.env.test
|
||||
echo "SMTP_PORT=25" >> ./apps/api/.env.test
|
||||
echo "SMTP_SENDER='user@feedback.com'" >> ./apps/api/.env.test
|
||||
|
||||
- name: Run Tests
|
||||
run: pnpm test
|
||||
@@ -0,0 +1,57 @@
|
||||
name: Docker Dev Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '**-dev'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
with:
|
||||
driver: docker-container
|
||||
|
||||
- name: Docker meta for API
|
||||
id: api-meta
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: line/abc-user-feedback-api
|
||||
bake-target: api
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
- name: Docker meta for Web
|
||||
id: web-meta
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: line/abc-user-feedback-web
|
||||
bake-target: web
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Bake and push multi-platform Docker images
|
||||
uses: docker/bake-action@v7
|
||||
with:
|
||||
files: |
|
||||
./docker/docker-bake.hcl
|
||||
push: true
|
||||
set: |
|
||||
api.tags=${{ steps.api-meta.outputs.tags }}
|
||||
web.tags=${{ steps.web-meta.outputs.tags }}
|
||||
@@ -0,0 +1,58 @@
|
||||
name: Docker Prod Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
- '!**-beta'
|
||||
- '!**-dev'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
with:
|
||||
driver: docker-container
|
||||
|
||||
- name: Docker meta for API
|
||||
id: api-meta
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: line/abc-user-feedback-api
|
||||
bake-target: api
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
- name: Docker meta for Web
|
||||
id: web-meta
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: line/abc-user-feedback-web
|
||||
bake-target: web
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Bake and push multi-platform Docker images
|
||||
uses: docker/bake-action@v7
|
||||
with:
|
||||
files: |
|
||||
./docker/docker-bake.hcl
|
||||
cwd://${{ steps.api-meta.outputs.bake-file }}
|
||||
cwd://${{ steps.web-meta.outputs.bake-file }}
|
||||
push: true
|
||||
@@ -0,0 +1,67 @@
|
||||
name: E2E Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [dev, main]
|
||||
|
||||
jobs:
|
||||
e2e-test:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0.39
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: userfeedback
|
||||
MYSQL_DATABASE: e2e
|
||||
MYSQL_USER: userfeedback
|
||||
MYSQL_PASSWORD: userfeedback
|
||||
TZ: UTC
|
||||
ports:
|
||||
- 13307:3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
smtp:
|
||||
image: rnwood/smtp4dev:v3
|
||||
ports:
|
||||
- 5080:80
|
||||
- 25:25
|
||||
- 143:143
|
||||
opensearch:
|
||||
image: opensearchproject/opensearch:2.4.1
|
||||
env:
|
||||
discovery.type: single-node
|
||||
bootstrap.memory_lock: 'true'
|
||||
plugins.security.disabled: 'true'
|
||||
options: >-
|
||||
--health-cmd="curl -s http://localhost:9200/_cluster/health | grep -q '\"status\":\"green\"'"
|
||||
--health-interval=10s
|
||||
--health-timeout=5s
|
||||
--health-retries=3
|
||||
ports:
|
||||
- 9200:9200
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Setup
|
||||
uses: ./tooling/github/setup
|
||||
|
||||
- name: Cache Playwright browsers
|
||||
uses: actions/cache@v3
|
||||
id: playwright-cache
|
||||
with:
|
||||
path: ~/.cache/ms-playwright
|
||||
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
- name: Install Playwright Browsers
|
||||
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
||||
run: pnpm exec playwright install --with-deps chromium
|
||||
|
||||
- name: Run e2e tests
|
||||
run: |
|
||||
CI=true pnpm test:e2e
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always() && !cancelled()
|
||||
with:
|
||||
name: playwright-report
|
||||
path: apps/e2e/playwright-report/
|
||||
retention-days: 7
|
||||
@@ -0,0 +1,77 @@
|
||||
name: Integration Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [dev, main]
|
||||
|
||||
jobs:
|
||||
integration-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: userfeedback
|
||||
MYSQL_DATABASE: e2e
|
||||
MYSQL_USER: userfeedback
|
||||
MYSQL_PASSWORD: userfeedback
|
||||
TZ: UTC
|
||||
ports:
|
||||
- 13307:3306
|
||||
options: >-
|
||||
--health-cmd="mysqladmin ping"
|
||||
--health-interval=10s
|
||||
--health-timeout=5s
|
||||
--health-retries=3
|
||||
|
||||
smtp:
|
||||
image: rnwood/smtp4dev:v3
|
||||
ports:
|
||||
- 5080:80
|
||||
- 25:25
|
||||
- 143:143
|
||||
|
||||
opensearch:
|
||||
image: opensearchproject/opensearch:2.17.1
|
||||
env:
|
||||
discovery.type: single-node
|
||||
bootstrap.memory_lock: 'true'
|
||||
plugins.security.disabled: 'true'
|
||||
OPENSEARCH_INITIAL_ADMIN_PASSWORD: 'UserFeedback123!@#'
|
||||
options: >-
|
||||
--health-cmd="curl -s http://localhost:9200/_cluster/health | grep -q '\"status\":\"green\"'"
|
||||
--health-interval=10s
|
||||
--health-timeout=5s
|
||||
--health-retries=3
|
||||
ports:
|
||||
- 9200:9200
|
||||
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup integration test (with opensearch)
|
||||
run: |
|
||||
npm install -g corepack@latest
|
||||
corepack enable
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm build
|
||||
echo "JWT_SECRET=DEV" >> ./apps/api/.env
|
||||
echo "OPENSEARCH_USE=true" >> ./apps/api/.env
|
||||
echo "OPENSEARCH_NODE=http://localhost:9200" >> ./apps/api/.env
|
||||
echo "SMTP_HOST='localhost'" >> ./apps/api/.env
|
||||
echo "SMTP_PORT=25" >> ./apps/api/.env
|
||||
echo "SMTP_SENDER='user@feedback.com'" >> ./apps/api/.env
|
||||
|
||||
- name: Run integration tests (with opensearch)
|
||||
run: |
|
||||
npm run test:integration
|
||||
|
||||
- name: Setup integration test (without opensearch)
|
||||
run: |
|
||||
echo "OPENSEARCH_USE=false" >> ./apps/api/.env
|
||||
|
||||
- name: Run integration tests (without opensearch)
|
||||
run: |
|
||||
npm run test:integration
|
||||
@@ -0,0 +1,45 @@
|
||||
name: Publish Api Docs to GitHub Pages
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
publish-api-docs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: userfeedback
|
||||
MYSQL_DATABASE: userfeedback
|
||||
MYSQL_USER: userfeedback
|
||||
MYSQL_PASSWORD: userfeedback
|
||||
TZ: UTC
|
||||
ports:
|
||||
- 13306:3306
|
||||
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Build app and swagger docs
|
||||
run: |
|
||||
npm install -g corepack@latest
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm build
|
||||
cd apps/api
|
||||
cp .env.example .env
|
||||
npx ts-node -r tsconfig-paths/register src/scripts/build-swagger-docs.ts
|
||||
|
||||
- name: Run Redocly CLI
|
||||
uses: fluximus-prime/redocly-cli-github-action@v1
|
||||
with:
|
||||
args: 'build-docs apps/api/swagger.json --output docs/index.html'
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: docs
|
||||
Reference in New Issue
Block a user